private static Func <ISession <PrivateAuthentication>, ITest, Task <IReadOnlyDictionary <object, ResourceRecordPhaseEntry> > > BeforeTest(Func <IRequest <CreateRecordRequest, CreateRecordResponse> > requestSupplier) { return(async(session, test) => { HrbcRecordCreator.IRecordEntries result = await HrbcRecordCreator.CreateRecords(requestSupplier)(session, test); IReadOnlyDictionary <object, List <PhaseEntryContent> > phaseResult = await HrbcPhaseEntryReader.ReadPhases(() => PhaseHelpers.InitPhaseEntryReader(result))(session, test); Dictionary <object, ResourceRecordPhaseEntry> combineResult = new Dictionary <object, ResourceRecordPhaseEntry>(); return phaseResult.ToDictionary(x => x.Key, x => new ResourceRecordPhaseEntry(result[x.Key], phaseResult[x.Key])); }); }
private static UpdateRecordRequest.IBuilderWithResource initRecordsUpdater(HrbcRecordCreator.IRecordEntries records, Dictionary <Enums.ResourceType, ulong> optionIds) { UpdateRecordRequest.IBuilder result = ResourceRequest.UpdateRecords(); foreach (var value in records.Values.Where(val => val.ResourceType != Enums.ResourceType.Contract)) { result.AddContent(value.ResourceType.ToPrivateEnum(), value.Id, content => content.AddField( new HrbcField(value.ResourceType.ToPrivateEnum(), "P_PhaseDate", ResourceType.Standard), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") ). AddField( new HrbcField(value.ResourceType.ToPrivateEnum(), "P_Phase", ResourceType.Standard), optionIds[value.ResourceType] ) ); } return(result as UpdateRecordRequest.IBuilderWithResource); }
private static Func <ISession <PrivateAuthentication>, ITest, Task <IReadOnlyDictionary <object, DeletedRecordMultiplePhaseEntry> > > BeforeTest(Func <IRequest <CreateRecordRequest, CreateRecordResponse> > requestSupplier, Dictionary <Enums.ResourceType, ulong> optionIds) { return(async(session, test) => { HrbcRecordCreator.IRecordEntries result = await HrbcRecordCreator.CreateRecords(requestSupplier)(session, test); await HrbcRecordUpdater.UpdateRecords(() => initRecordsUpdater(result, optionIds))(session, test); IReadOnlyDictionary <object, List <PhaseEntryContent> > phaseResult = await HrbcPhaseEntryReader.ReadPhases(() => PhaseHelpers.InitPhaseEntryReader(result))(session, test); await HrbcRecordCreator.DeleteRecords(session, test, result); Dictionary <object, DeletedRecordMultiplePhaseEntry> combineResult = new Dictionary <object, DeletedRecordMultiplePhaseEntry>(); return phaseResult.ToDictionary(x => x.Key, x => new DeletedRecordMultiplePhaseEntry(result[x.Key], x.Value)); }); }
private static Func <ISession <PrivateAuthentication>, ITest, Task <IReadOnlyDictionary <object, DeletedRecordPhaseEntry> > > BeforeTest(Func <IRequest <CreateRecordRequest, CreateRecordResponse> > requestSupplier) { return(async(session, test) => { HrbcRecordCreator.IRecordEntries result = await HrbcRecordCreator.CreateRecords(requestSupplier)(session, test); IReadOnlyDictionary <object, List <PhaseEntryContent> > phaseResult = await HrbcPhaseEntryReader.ReadPhases(() => initPhaseEntryReader(result))(session, test); await HrbcRecordCreator.DeleteRecords(session, test, result); Dictionary <object, DeletedRecordPhaseEntry> combineResult = new Dictionary <object, DeletedRecordPhaseEntry>(); foreach (var key in phaseResult.Keys) { var recordPhase = new DeletedRecordPhaseEntry(result[key], phaseResult[key]); combineResult.Add(key, recordPhase); } return combineResult; }); }
private static Dictionary <object, GetPhaseEntryRequest.IBuilderWithData> initPhaseEntryReader(HrbcRecordCreator.IRecordEntries recordData) { Dictionary <object, GetPhaseEntryRequest.IBuilderWithData> result = new Dictionary <object, GetPhaseEntryRequest.IBuilderWithData>(); foreach (var key in recordData.Keys.Where(key => recordData[key].ResourceType != Enums.ResourceType.Contract)) { var builder = GetPhaseEntryRequest.Builder(); builder.AddResource((int)recordData[key].ResourceType).AddParentId(recordData[key].Id.ToString()).AppendField("Phase.flag").AppendField("Phase.P_Phase").AppendField("Phase.P_PhaseMemo").AppendField("Phase.P_PhaseDate").AppendField("Phase.P_UpdateDate").AppendField("Phase.P_UpdateId"); result.Add(key, builder); } return(result); }
public static void GetTotalMinMaxOfRecords(ItemState itemState, Enums.ResourceType resourceType, HrbcRecordCreator.IRecordEntries recordsOver, HrbcRecordCreator.IRecordEntries recordsIn, HrbcRecordCreator.IRecordEntries recordsDeleted, out int total, out ulong min, out ulong max) { if (itemState == ValidTestCases.ItemState.Existing || itemState == ValidTestCases.ItemState.Default) { var existingOver = ValidTestCases.GetMinMaxOfRecords(recordsOver); var existingIn = ValidTestCases.GetMinMaxOfRecords(recordsIn); total = recordsOver.Count / 9 + recordsIn.Count / 9; min = existingOver[resourceType]["Min"]; max = existingIn[resourceType]["Max"]; } else if (itemState == ValidTestCases.ItemState.All) { var existingIn = ValidTestCases.GetMinMaxOfRecords(recordsIn); var deleted = ValidTestCases.GetMinMaxOfRecords(recordsDeleted); total = recordsIn.Count / 9 + recordsDeleted.Count / 9; min = existingIn[resourceType]["Min"]; max = deleted[resourceType]["Max"]; } else { var deleted = ValidTestCases.GetMinMaxOfRecords(recordsDeleted); total = recordsDeleted.Count / 9; min = deleted[resourceType]["Min"]; max = deleted[resourceType]["Max"]; } }
public static Dictionary <Enums.ResourceType, Dictionary <string, ulong> > GetMinMaxOfRecords(HrbcRecordCreator.IRecordEntries records) { var result = records.GroupBy( rec => rec.Value.ResourceType) .ToDictionary( g => g.Key, g => new Dictionary <string, ulong> { ["Max"] = g.Max(item => item.Value.Id), ["Min"] = g.Min(item => item.Value.Id) }); return(result); }