@@ -11,14 +11,20 @@ public class MockedProject
1111 public User Player { get ; } = new User ( ) { UserId = 1 , PrefferedName = "Player" , Email = "[email protected] " , Claims = new HashSet < Claim > ( ) } ; 1212 public User Master { get ; } = new User ( ) { UserId = 2 , PrefferedName = "Master" , Email = "[email protected] " , Claims = new HashSet < Claim > ( ) } ; 1313 public ProjectField MasterOnlyField { get ; }
14+
15+ public ProjectFieldInfo MasterOnlyFieldInfo { get ; set ; }
1416 public ProjectField CharacterField { get ; }
1517 public ProjectField HideForUnApprovedClaim { get ; }
18+ public ProjectFieldInfo HideForUnApprovedClaimInfo { get ; set ; }
19+
20+ public ProjectFieldInfo CharacterFieldInfo { get ; set ; }
1621 public ProjectField PublicField { get ; }
22+ public ProjectFieldInfo PublicFieldInfo { get ; set ; }
1723
1824 public Character Character { get ; }
1925 public Character CharacterWithoutGroup { get ; }
2026
21- public ProjectInfo ProjectInfo { get ; }
27+ public ProjectInfo ProjectInfo { get ; private set ; }
2228
2329 private static void FixProjectSubEntities ( Project project1 )
2430 {
@@ -129,8 +135,16 @@ public MockedProject()
129135
130136 Character . ParentCharacterGroupIds = new [ ] { Group . CharacterGroupId } ;
131137
132- ProjectInfo = ProjectRepository . CreateInfoFromProject ( Project , new ( Project . ProjectId ) ) ;
138+ ReInitProjectInfo ( ) ;
139+ }
133140
141+ public void ReInitProjectInfo ( )
142+ {
143+ ProjectInfo = ProjectRepository . CreateInfoFromProject ( Project , new ( Project . ProjectId ) ) ;
144+ PublicFieldInfo = ProjectInfo . GetFieldById ( new ( ProjectInfo . ProjectId , PublicField . ProjectFieldId ) ) ;
145+ HideForUnApprovedClaimInfo = ProjectInfo . GetFieldById ( new ( ProjectInfo . ProjectId , HideForUnApprovedClaim . ProjectFieldId ) ) ;
146+ CharacterFieldInfo = ProjectInfo . GetFieldById ( new PrimitiveTypes . ProjectFieldIdentification ( ProjectInfo . ProjectId , CharacterField . ProjectFieldId ) ) ;
147+ MasterOnlyFieldInfo = ProjectInfo . GetFieldById ( new PrimitiveTypes . ProjectFieldIdentification ( ProjectInfo . ProjectId , MasterOnlyField . ProjectFieldId ) ) ;
134148 }
135149
136150 public CharacterGroup CreateCharacterGroup ( CharacterGroup ? characterGroup = null )
@@ -147,24 +161,34 @@ public CharacterGroup CreateCharacterGroup(CharacterGroup? characterGroup = null
147161 return characterGroup ;
148162 }
149163
150- public ProjectField CreateConditionalField ( ProjectField field , CharacterGroup conditionGroup )
164+ public ProjectFieldInfo CreateConditionalField ( Action < ProjectField > setup , CharacterGroup conditionGroup )
151165 {
152- field = CreateField ( field ) ;
153- field . AvailableForCharacterGroupIds = new [ ] { conditionGroup . CharacterGroupId } ;
154- return field ;
166+ return AddField ( f => { f . AvailableForCharacterGroupIds = new [ ] { conditionGroup . CharacterGroupId } ; setup ( f ) ; } ) ;
155167 }
156168
157- public ProjectField CreateField ( ProjectField ? field = null )
169+ public ProjectFieldInfo CreateConditionalField ( CharacterGroup conditionGroup )
158170 {
159- field ??= new ProjectField ( ) ;
171+ return AddField ( f => f . AvailableForCharacterGroupIds = new [ ] { conditionGroup . CharacterGroupId } ) ;
172+ }
173+
174+ public ProjectFieldInfo AddField ( Action < ProjectField > setup )
175+ {
176+ var field = new ProjectField ( ) ;
160177 field . Project = Project ;
161178 field . ProjectId = Project . ProjectId ;
162179 field . ProjectFieldId = Project . ProjectFields . GetNextId ( ) ;
163180 field . FieldName ??= "test_" + field . ProjectFieldId ;
164181 field . AvailableForCharacterGroupIds = Array . Empty < int > ( ) ;
165182 field . IsActive = true ;
183+ setup ( field ) ;
166184 Project . ProjectFields . Add ( field ) ;
167- return field ;
185+ ReInitProjectInfo ( ) ;
186+ return ProjectInfo . GetFieldById ( new PrimitiveTypes . ProjectFieldIdentification ( new PrimitiveTypes . ProjectIdentification ( Project . ProjectId ) , field . ProjectFieldId ) ) ;
187+ }
188+
189+ public ProjectFieldInfo AddField ( )
190+ {
191+ return AddField ( f => { } ) ;
168192 }
169193
170194 public Claim CreateClaim ( Character mockCharacter , User mockUser )
@@ -215,29 +239,30 @@ public Claim CreateCheckedInClaim(Character character, User player)
215239 return claim ;
216240 }
217241
218- public ProjectField CreateConditionalHeader ( )
242+ public ProjectFieldInfo CreateConditionalHeader ( )
219243 {
220- return CreateConditionalField ( new ProjectField ( )
244+ return CreateConditionalField ( f =>
221245 {
222- CanPlayerEdit = true ,
223- CanPlayerView = true ,
224- ShowOnUnApprovedClaims = true ,
225- FieldBoundTo = FieldBoundTo . Character ,
226- FieldType = ProjectFieldType . Header ,
227- FieldName = "Conditional" ,
246+ f . CanPlayerEdit = true ;
247+ f . CanPlayerView = true ;
248+ f . ShowOnUnApprovedClaims = true ;
249+ f . FieldBoundTo = FieldBoundTo . Character ;
250+ f . FieldType = ProjectFieldType . Header ;
251+ f . FieldName = "Conditional" ;
228252 } ,
229253 Group ) ;
230254 }
231255
232- public ProjectField CreateConditionalField ( )
256+ public ProjectFieldInfo CreateConditionalField ( )
233257 {
234- return CreateConditionalField ( new ProjectField ( )
258+ return CreateConditionalField ( f =>
235259 {
236- CanPlayerEdit = true ,
237- CanPlayerView = true ,
238- IsActive = true ,
239- ShowOnUnApprovedClaims = true ,
240- FieldBoundTo = FieldBoundTo . Character ,
260+
261+ f . CanPlayerEdit = true ;
262+ f . CanPlayerView = true ;
263+ f . IsActive = true ;
264+ f . ShowOnUnApprovedClaims = true ;
265+ f . FieldBoundTo = FieldBoundTo . Character ;
241266 } ,
242267 Group ) ;
243268 }
0 commit comments