private static async Task <SorCodeTrade> SeedTrade(string expectedTradeCode, string name = "trade") { var expectedTrade = new SorCodeTrade { Code = expectedTradeCode, Name = name }; await InMemoryDb.Instance.Trades.AddAsync(expectedTrade); return(expectedTrade); }
private async Task GetAndValidateCodes(string expectedProperty, SorCodeTrade expectedTrade, string contractorReference, List <ScheduleOfRates> expectedCodes, bool?isRaisable = null) { // act var result = await _classUnderTest.GetSorCodes(expectedProperty, expectedTrade.Code, contractorReference, isRaisable); // assert var expectedResult = expectedCodes.Select(sor => new ScheduleOfRatesModel { Code = sor.Code, ShortDescription = sor.ShortDescription, LongDescription = sor.LongDescription, Priority = new RepairsApi.V2.Domain.SORPriority { PriorityCode = sor.Priority?.PriorityCode, Description = sor.Priority?.Description, }, Cost = sor.Cost }).ToList(); result.Should().BeEquivalentTo(expectedResult); }
private static async Task <List <ScheduleOfRates> > SeedSorCodes( SORPriority expectedPriority, string expectedProperty, SorCodeTrade expectedTrade, Contract expectedContract = null, bool enabled = true, bool isRaisable = true) { var expectedGenerator = new Generator <ScheduleOfRates>(); expectedGenerator .AddDefaultGenerators() .AddValue(expectedPriority, (ScheduleOfRates sor) => sor.Priority) .AddValue(expectedProperty, (PropertyContract pc) => pc.PropRef) .AddValue(expectedTrade, (ScheduleOfRates sor) => sor.Trade) .AddValue(enabled, (ScheduleOfRates sor) => sor.Enabled) .AddValue(isRaisable, (ScheduleOfRates sor) => sor.IsRaisable) .AddGenerator(() => GenerateJoinEntry(expectedContract), (ScheduleOfRates sor) => sor.SorCodeMap); var expectedCodes = expectedGenerator.GenerateList(10); await InMemoryDb.Instance.SORCodes.AddRangeAsync(expectedCodes); return(expectedCodes); }