Esempio n. 1
0
        public async Task CanGetContractsByContractor()
        {
            // arrange
            var expectedContractor = new Contractor
            {
                Name      = "name",
                Reference = "reference"
            };
            var generator = new Generator <Contract>();

            generator
            .AddDefaultGenerators()
            .AddValue(expectedContractor, (Contract c) => c.Contractor)
            .AddValue(null, (Contract c) => c.PropertyMap)
            .AddValue(null, (Contract c) => c.SorCodeMap);

            var expectedContracts = generator.GenerateList(10);
            await InMemoryDb.Instance.Contractors.AddAsync(expectedContractor);

            await InMemoryDb.Instance.Contracts.AddRangeAsync(expectedContracts);

            await InMemoryDb.Instance.SaveChangesAsync();

            // act
            var result = await _classUnderTest.GetContracts(expectedContractor.Reference);

            // assert
            result.Should().BeEquivalentTo(expectedContracts.Select(c => c.ContractReference));
        }
 public void Setup()
 {
     _generator = new Generator <ScheduleOfRatesModel>();
     _generator.AddDefaultGenerators();
     _mockScheduleOfRatesGateway = new Mock <IScheduleOfRatesGateway>();
     _classUnderTest             = new ListScheduleOfRatesUseCase(_mockScheduleOfRatesGateway.Object);
 }
Esempio n. 3
0
        public async Task CanGetCosts()
        {
            // arrange
            var      generator = new Generator <SORContract>();
            Contract contract  = new Contract
            {
                ContractorReference = "contractor",
                ContractReference   = "contract",
                TerminationDate     = DateTime.UtcNow.Date.AddYears(1),
                EffectiveDate       = DateTime.UtcNow.Date.AddDays(-7)
            };

            ScheduleOfRates sor = new ScheduleOfRates
            {
                Code            = "code",
                Cost            = 1,
                Enabled         = true,
                LongDescription = "",
            };

            generator
            .AddDefaultGenerators()
            .AddValue(sor, (SORContract c) => c.SorCode)
            .AddValue(contract, (SORContract c) => c.Contract);
            var expectedContract = generator.Generate();

            await InMemoryDb.Instance.SORContracts.AddAsync(expectedContract);

            await InMemoryDb.Instance.SaveChangesAsync();

            // act
            var result = await _classUnderTest.GetCost(contract.ContractorReference, sor.Code);

            // assert
            result.Should().Be(expectedContract.Cost);
        }
Esempio n. 4
0
        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);
        }