@@ -9,11 +9,203 @@ namespace ElectionGuard.Encryption.Tests.Utils
99{
1010 public class ManifestGenerator
1111 {
12- public static Manifest GetJeffersonCountyManifest ( )
12+ /// <summary>
13+ /// A test manifest that is loaded from a json file
14+ /// </summary>
15+ public static Manifest GetJeffersonCountyManifest_FromFile ( )
1316 {
1417 var path = Path . Combine ( AppContext . BaseDirectory , "Data" , "election_manifest_jefferson_county.json" ) ;
1518 var text = File . ReadAllText ( path ) ;
1619 return new Manifest ( text ) ;
1720 }
21+
22+ /// <summary>
23+ /// A minimal test manifest demonstrating a single contest with two choices and a writein
24+ /// </summary>
25+ public static Manifest GetJeffersonCountyManifest_Minimal ( )
26+ {
27+ var gpUnits = new List < GeopoliticalUnit >
28+ {
29+ new GeopoliticalUnit ( "jefferson-county" , "Jefferson County" , ReportingUnitType . county )
30+ } ;
31+
32+ var candidates = new List < Candidate >
33+ {
34+ new Candidate ( "benjamin-franklin" , isWriteIn : false ) ,
35+ new Candidate ( "john-adams" , isWriteIn : false ) ,
36+ new Candidate ( "write-in" , isWriteIn : true )
37+ } ;
38+
39+ var contests = new List < ContestDescription >
40+ {
41+ new ContestDescription (
42+ objectId : "justice-supreme-court" ,
43+ electoralDistrictId : gpUnits [ 0 ] . ObjectId ,
44+ sequenceOrder : 0 ,
45+ VoteVariationType . n_of_m ,
46+ numberElected : 1 ,
47+ name : "Justice of the Supreme Court" ,
48+ selections : new [ ]
49+ {
50+ new SelectionDescription (
51+ "benjamin-franklin-selection" , candidates [ 0 ] . CandidateId , sequenceOrder : 0 ) ,
52+ new SelectionDescription (
53+ "john-adams-selection" , candidates [ 1 ] . CandidateId , sequenceOrder : 1 ) ,
54+ new SelectionDescription (
55+ "write-in-selection" , candidates [ 2 ] . CandidateId , sequenceOrder : 2 )
56+ } )
57+ } ;
58+
59+ var ballotStyles = new List < BallotStyle >
60+ {
61+ new BallotStyle (
62+ "jefferson-county-ballot-style" ,
63+ new [ ] { gpUnits [ 0 ] . ObjectId } )
64+ } ;
65+
66+
67+ return new Manifest (
68+ "jefferson-county-open-primary" ,
69+ ElectionType . primary ,
70+ startDate : DateTime . UtcNow ,
71+ endDate : DateTime . UtcNow . AddDays ( 1 ) ,
72+ gpUnits . ToArray ( ) ,
73+ ( new List < Party > ( ) ) . ToArray ( ) ,
74+ candidates . ToArray ( ) ,
75+ contests . ToArray ( ) ,
76+ ballotStyles . ToArray ( )
77+ ) ;
78+ }
79+
80+ /// <summary>
81+ /// A test manifest demonstrating multiple ballot styles.
82+ /// In the ElectionGuard data structure each contest belongs
83+ /// to a Geopolitical Unit, and then each Geopolitical Unit is part of
84+ /// a ballot style. This example also adds some more metadata
85+ /// such as language transaltions for certain objects
86+ /// </summary>
87+ public static Manifest GetJeffersonCountyManifest_MultipleBallotStyles ( )
88+ {
89+ var gpUnits = new List < GeopoliticalUnit >
90+ {
91+ new GeopoliticalUnit ( "jefferson-county" , "Jefferson County" , ReportingUnitType . county ) ,
92+ new GeopoliticalUnit (
93+ "jefferson-county-school-district-1" , "Jefferson County School District 1" , ReportingUnitType . school )
94+ } ;
95+
96+ var parties = new List < Party >
97+ {
98+ new Party ( "federalist-party" ) ,
99+ new Party ( "whig-party" )
100+ } ;
101+
102+ var candidates = new List < Candidate >
103+ {
104+ new Candidate ( "benjamin-franklin" , isWriteIn : false ) ,
105+ new Candidate ( "john-adams" , isWriteIn : false ) ,
106+ // The write-in candidate can be reused for all contests
107+ new Candidate ( "write-in" , isWriteIn : true ) ,
108+ new Candidate ( "referendum-pineapple-affirmative" , new InternationalizedText (
109+ new [ ] {
110+ // Adding language info isn't requred for the library to function
111+ // but is useful for providing what data was displayed to users
112+ // since it is included in the manifest hash.
113+ new Language ( "Pineapple should be banned on pizza" , "en" ) ,
114+ // TODO: #176: new Language("La piña debe prohibirse en la pizza", "es"),
115+ } ) , parties [ 0 ] . ObjectId , "some-image-uri-for-logo" , isWriteIn : false ) ,
116+ new Candidate ( "referendum-pineapple-negative" , new InternationalizedText (
117+ new [ ] {
118+ new Language ( "Pineapple should not be banned on pizza" , "en" ) ,
119+ // new Language("La piña no debe prohibirse en la pizza", "es"),
120+ } ) , parties [ 1 ] . ObjectId , "some-image-uri-for-logo" , isWriteIn : false )
121+ } ;
122+
123+ var contests = new List < ContestDescription >
124+ {
125+ // Justice Supreme Court
126+ new ContestDescription (
127+ objectId : "justice-supreme-court" ,
128+ electoralDistrictId : gpUnits [ 0 ] . ObjectId , // jefferson-county
129+ sequenceOrder : 0 ,
130+ VoteVariationType . n_of_m ,
131+ numberElected : 1 ,
132+ name : "Justice of the Supreme Court" ,
133+ selections : new [ ]
134+ {
135+ new SelectionDescription (
136+ "benjamin-franklin-selection" ,
137+ candidates [ 0 ] . CandidateId , // benjamin-franklin
138+ sequenceOrder : 0 ) ,
139+ new SelectionDescription (
140+ "john-adams-selection" ,
141+ candidates [ 1 ] . CandidateId , // john-adams
142+ sequenceOrder : 1 ) ,
143+ new SelectionDescription (
144+ "write-in-selection" ,
145+ candidates [ 2 ] . CandidateId , // write-in
146+ sequenceOrder : 2 )
147+ } ) ,
148+
149+ // Pineapple Referendum
150+ new ContestDescription (
151+ objectId : "referendum-pineapple" ,
152+ electoralDistrictId : gpUnits [ 1 ] . ObjectId , // jefferson-county-school-district-1
153+ sequenceOrder : 1 ,
154+ VoteVariationType . n_of_m ,
155+ numberElected : 1 ,
156+ votesAllowed : 1 ,
157+ name : "The Pineapple Question" ,
158+ ballotTitle : new InternationalizedText (
159+ new [ ] {
160+ new Language ( "Should pineapple be banned on pizza?" , "en" ) ,
161+ // TODO: #176: new Language("¿Debería prohibirse la piña en la pizza?", "es"),
162+ } ) ,
163+ ballotSubtitle : new InternationalizedText (
164+ new [ ] {
165+ new Language ( "The township considers this issue to be very important" , "en" ) ,
166+ // TODO: #176: new Language("El municipio considera que esta cuestión es muy importante", "es"),
167+ } ) ,
168+ selections : new [ ]
169+ {
170+ new SelectionDescription (
171+ "referendum-pineapple-affirmative-selection" ,
172+ // Use Linq to lookup the value
173+ candidates . First (
174+ i => i . ObjectId == "referendum-pineapple-affirmative"
175+ ) . CandidateId ,
176+ sequenceOrder : 0 ) ,
177+ new SelectionDescription (
178+ "referendum-pineapple-negative-selection" ,
179+ // Or just use the known string
180+ "referendum-pineapple-negative" ,
181+ sequenceOrder : 1 )
182+ } )
183+ } ;
184+
185+ var ballotStyles = new List < BallotStyle >
186+ {
187+ new BallotStyle (
188+ "jefferson-county-ballot-style" ,
189+ new [ ] { gpUnits [ 0 ] . ObjectId } ) ,
190+ new BallotStyle (
191+ "jefferson-county-school-district-1" ,
192+ new [ ] {
193+ gpUnits [ 0 ] . ObjectId ,
194+ gpUnits [ 1 ] . ObjectId ,
195+ } )
196+ } ;
197+
198+ return new Manifest (
199+ "jefferson-county-open-primary" ,
200+ ElectionType . primary ,
201+ startDate : DateTime . UtcNow ,
202+ endDate : DateTime . UtcNow . AddDays ( 1 ) ,
203+ gpUnits . ToArray ( ) ,
204+ parties . ToArray ( ) ,
205+ candidates . ToArray ( ) ,
206+ contests . ToArray ( ) ,
207+ ballotStyles . ToArray ( )
208+ ) ;
209+ }
18210 }
19211}
0 commit comments