private static Func <ISession <PrivateAuthentication>, ITest, Task <HrbcRecordCreator.IRecordEntries> > BeforeTest(Func <IRequest <CreateRecordRequest, CreateRecordResponse> > requestSupplier, Func <List <long> > userIds) { return(async(session, test) => { HrbcRecordCreator.IRecordEntries result = await HrbcRecordCreator.CreateRecords(requestSupplier)(session, test); foreach (var entry in result.GroupBy(entry => entry.Value.ResourceType, entry => entry.Value.Id)) { await HrbcImportResource.ImportFile(entry.ToList(), userIds(), true, entry.Key, "_Deleted")(session, test); /* For debug * string path = $"{Directory.GetCurrentDirectory()}\\log_{entry.Key}.text"; * using (TextWriter te = File.CreateText(path)) * { * te.WriteLine(entry.Key.ToString()); * te.WriteLine(string.Join(",", entry.ToList().Select(e => e.ToString()))); * } */ } await HrbcRecordCreator.DeleteRecords(session, test, result); return result; }); }
private static Func <ISession <PrivateAuthentication>, ITest, Task <HrbcRecordCreator.IRecordEntries> > BeforeTest(Func <IRequest <CreateRecordRequest, CreateRecordResponse> > requestSupplier) { return(async(session, test) => { HrbcRecordCreator.IRecordEntries result = await HrbcRecordCreator.CreateRecords(requestSupplier)(session, test); await HrbcRecordCreator.DeleteRecords(session, test, result); return result; }); }
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 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; }); }