public void VolumesExcludedCurrentContractBillingMonths()
        {
            var currentContract     = ContractReaderStub.Contract();
            var contracts           = ContractReaderStub.Contracts();
            var previousSiteVolumes =
                ContractProductSiteVolumeReaderStub.PreviousSiteVolumes();
            var currentContractSiteVolumes =
                ContractProductSiteVolumeReaderStub.CurrentSiteVolume();
            var previousContractForTheClient =
                SiteVolumeCalculator.PreviousContractForClient(currentContract,
                                                               contracts);
            var previousContractSiteVolumes =
                SiteVolumeCalculator.SiteVolumesForContract(
                    previousContractForTheClient,
                    previousSiteVolumes);
            var currentContractBillingMonths =
                SiteVolumeCalculator.BillingMonths(
                    currentContractSiteVolumes);

            var actualResult =
                SiteVolumeCalculator
                .VolumesExcludedCurrentContractBillingMonths(
                    currentContractBillingMonths, previousContractSiteVolumes);

            //march 3rd 2015
            Assert.AreEqual(50, actualResult.ElementAt(0).Volume);
            Assert.AreEqual(30, actualResult.ElementAt(0).SiteId);
            Assert.AreEqual(new DateTime(2015, 3, 1),
                            actualResult.ElementAt(0).BillingMonth);
        }
        public void NoProductAvailableForTheContract()
        {
            var contract = ContractReaderStub.Contract();
            var products = ContractProductReaderStub.NoProducts();

            SiteVolumeCalculator.NoProductAvailableForContract(contract, products);
        }
        public void IsContractHasStartDate()
        {
            var contract = ContractReaderStub.Contract();

            var actualResult =
                SiteVolumeCalculator.IsContractHasStartDate(contract);

            Assert.AreEqual(true, actualResult);
        }
        public void IsContractHasSomeVolume()
        {
            var contract = ContractReaderStub.Contract();
            var volumes  = ContractProductSiteVolumeReaderStub.SomeVolumes();

            var actualResult =
                SiteVolumeCalculator.IsContractHasSomeVolume(contract, volumes);

            Assert.AreEqual(true, actualResult);
        }
Пример #5
0
        public void IsContractFileAvailable()
        {
            var filePath = string.Empty;

            var reader   = new ContractReaderStub(filePath);
            var dataFile = new ContractData(reader);

            var result = dataFile.IsFileExist();

            Assert.IsTrue(result);
        }
        public void PreviousContractForTheClient()
        {
            var contract  = ContractReaderStub.Contract();
            var contracts = ContractReaderStub.Contracts();

            var previousContract =
                SiteVolumeCalculator.PreviousContractForClient(
                    contract, contracts);

            Assert.AreEqual(33, previousContract.ClientId);
            Assert.AreEqual(new DateTime(2015, 3, 1), previousContract.EndDate);
        }
        public void SiteVolumesForTheContract()
        {
            var contract = ContractReaderStub.Contract();
            var volumes  = ContractProductSiteVolumeReaderStub.AllVolumes();

            var actualResult =
                SiteVolumeCalculator.SiteVolumesForContract(contract,
                                                            volumes);

            Assert.AreEqual(200, actualResult.ElementAt(0).Volume);
            Assert.AreEqual(100, actualResult.ElementAt(1).Volume);
        }
        public void ExpectedBillingMonthsForTheContract()
        {
            var contract = ContractReaderStub.Contract();

            var expectedBillingMonths =
                SiteVolumeCalculator.ExpectedBillingMonthsForTheContract(contract);

            Assert.AreEqual(1, expectedBillingMonths[0].Item1);
            Assert.AreEqual(2016, expectedBillingMonths[0].Item2);
            Assert.AreEqual(2, expectedBillingMonths[1].Item1);
            Assert.AreEqual(2016, expectedBillingMonths[1].Item2);
        }
        public void ProductsForTheContract()
        {
            var contract = ContractReaderStub.Contract();
            var products = ContractProductReaderStub.Products();


            var result =
                SiteVolumeCalculator.ContractProducts(contract,
                                                      products);

            Assert.AreEqual(1, result.ElementAt(0).ContractAmendmentId);
            Assert.AreEqual(1, result.ElementAt(1).ContractAmendmentId);
        }
        public void IsNoVolumeContract()
        {
            var contract = ContractReaderStub.Contract();
            var volumes  = ContractProductSiteVolumeReaderStub.NoVolumes();
            var allSiteVolumesForTheContract =
                SiteVolumeCalculator.SiteVolumesForContract(contract,
                                                            volumes);

            var result =
                SiteVolumeCalculator.IsNoVolumeContract(allSiteVolumesForTheContract);

            Assert.AreEqual(true, result);
        }
Пример #11
0
        public void ContractForContractId()
        {
            var filePath   = "Contracts.xml";
            var reader     = new ContractReaderStub(filePath);
            var datafile   = new ContractData(reader);
            var repository = new ContractRepository(datafile);
            var result     = repository.Contract(x => x.Id == 1);

            Assert.AreEqual(1, result.Id);
            Assert.AreEqual(30, result.ClientId);
            Assert.AreEqual(new DateTime(2017, 1, 1), result.StartDate);
            Assert.AreEqual(new DateTime(2018, 1, 1), result.EndDate);
        }
Пример #12
0
        public void AllContracts()
        {
            var filePath = string.Empty;;
            var reader   = new ContractReaderStub(filePath);
            var dataFile = new ContractData(reader);

            var result = dataFile.Records();

            Assert.AreEqual(1, result.ElementAt(0).Id);
            Assert.AreEqual(30, result.ElementAt(0).ClientId);
            Assert.AreEqual(new DateTime(2017, 1, 1), result.ElementAt(0).StartDate);
            Assert.AreEqual(new DateTime(2018, 1, 1), result.ElementAt(0).EndDate);
        }
Пример #13
0
        public void AllContracts()
        {
            var filePath   = "Contracts.xml";
            var reader     = new ContractReaderStub(filePath);
            var datafile   = new ContractData(reader);
            var repository = new ContractRepository(datafile);
            var result     = repository.Contracts();

            Assert.AreEqual(1, result.ElementAt(0).Id);
            Assert.AreEqual(30, result.ElementAt(0).ClientId);
            Assert.AreEqual(new DateTime(2017, 1, 1), result.ElementAt(0).StartDate);
            Assert.AreEqual(new DateTime(2018, 1, 1), result.ElementAt(0).EndDate);
        }
        public void MissingBillingMonths()
        {
            var contract = ContractReaderStub.Contract();
            var volumes  = ContractProductSiteVolumeReaderStub.NoVolumes();

            var expectedBillingMonths =
                SiteVolumeCalculator.ExpectedBillingMonthsForTheContract(contract);
            var actualBillingMonths = SiteVolumeCalculator.BillingMonths(volumes);

            var missingBillingMonths =
                SiteVolumeCalculator.MissingBillingMonths(
                    expectedBillingMonths, actualBillingMonths);

            Assert.AreEqual(2, missingBillingMonths);
        }
        public void CurrentContractVolumes()
        {
            var contract = ContractReaderStub.Contract();
            var volumes  = ContractProductSiteVolumeReaderStub.AllVolumes();

            var actualResult =
                SiteVolumeCalculator.CurrentContractVolumes(contract,
                                                            volumes);

            Assert.AreEqual(200, actualResult.ElementAt(0).Volume);
            Assert.AreEqual(20, actualResult.ElementAt(0).SiteId);
            Assert.AreEqual(new DateTime(2016, 1, 1), actualResult.ElementAt(0).BillingMonth);
            Assert.AreEqual(100, actualResult.ElementAt(1).Volume);
            Assert.AreEqual(20, actualResult.ElementAt(1).SiteId);
            Assert.AreEqual(new DateTime(2016, 2, 1), actualResult.ElementAt(1).BillingMonth);
        }
        public void CurrentContractBillingMonths()
        {
            var contract    = ContractReaderStub.Contract();
            var volumes     = ContractProductSiteVolumeReaderStub.SomeVolumes();
            var siteVolumes =
                SiteVolumeCalculator.SiteVolumesForContract(contract,
                                                            volumes);

            var billingMonths =
                SiteVolumeCalculator.BillingMonths(
                    siteVolumes);


            Assert.AreEqual(1, billingMonths[0].Item1);
            Assert.AreEqual(2016, billingMonths[0].Item2);
        }
        public void TotalSiteVolume()
        {
            var contract = ContractReaderStub.Contract();
            var volumes  = ContractProductSiteVolumeReaderStub.AllVolumes();

            var allSiteVolumesForTheContract =
                SiteVolumeCalculator.SiteVolumesForContract(contract,
                                                            volumes);
            var groupedSiteVolumes =
                SiteVolumeCalculator.GroupedSiteVolumes(allSiteVolumesForTheContract);


            var totalContractedSiteVolume =
                SiteVolumeCalculator.TotalSiteVolume(groupedSiteVolumes);

            Assert.AreEqual(300, totalContractedSiteVolume);
        }
        public void TotalContractedVolumeForNoVolumeAvailableContract()
        {
            var contract  = ContractReaderStub.Contract();
            var contracts = ContractReaderStub.Contracts();
            var products  = ContractProductReaderStub.Products();
            var sites     = ContractProductSiteReaderStub.Sites();
            var volumes   = ContractProductSiteVolumeReaderStub.PreviousSiteVolumes();

            var forecaster =
                new SiteVolumeCalculator();

            var totalContractedSiteVolume =
                forecaster.TotalContractedVolume(contract,
                                                 contracts,
                                                 products, sites, volumes);

            Assert.AreEqual(150, totalContractedSiteVolume);
        }
        public void IsAllVolumesExistForTheContract()
        {
            var contract = ContractReaderStub.Contract();
            var volumes  = ContractProductSiteVolumeReaderStub.AllVolumes();


            var expectedBillingMonths =
                SiteVolumeCalculator.ExpectedBillingMonthsForTheContract(contract);
            var actualBillingMonths = SiteVolumeCalculator.BillingMonths(volumes);

            var totalNumberOfMissingBillingMonths =
                SiteVolumeCalculator.MissingBillingMonths(
                    expectedBillingMonths, actualBillingMonths);

            var actualResult =
                SiteVolumeCalculator.IsAllVolumesExistForTheContract(
                    totalNumberOfMissingBillingMonths);

            Assert.AreEqual(true, actualResult);
        }
        public void DecoupleSiteVolumeCalculatorFromForecaster()
        {
            var contract  = ContractReaderStub.Contract();
            var contracts = ContractReaderStub.Contracts();
            var products  = ContractProductReaderStub.Products();
            var sites     = ContractProductSiteReaderStub.Sites();
            var volumes   = ContractProductSiteVolumeReaderStub.SomeVolumes();

            var volumeCalculator =
                new SiteVolumeCalculator();
            var volumeForecaster = new SiteVolumeForecaster(volumeCalculator);

            var actualResult = volumeForecaster.TotalContractedVolume(
                contract, contracts,
                products,
                sites,
                volumes);

            Assert.AreEqual(250, actualResult);
        }
        public void GroupedSiteVolumes()
        {
            var contract = ContractReaderStub.Contract();
            var volumes  = ContractProductSiteVolumeReaderStub.AllVolumes();

            var allSiteVolumesForTheContract =
                SiteVolumeCalculator.SiteVolumesForContract(contract,
                                                            volumes);

            var groupedSiteVolumes =
                SiteVolumeCalculator.GroupedSiteVolumes(allSiteVolumesForTheContract);

            Assert.AreEqual(200, groupedSiteVolumes.ElementAt(0).Volume);
            Assert.AreEqual(new DateTime(2016, 1, 1),
                            groupedSiteVolumes.ElementAt(0).BillingMonth);
            Assert.AreEqual(20, groupedSiteVolumes.ElementAt(0).SiteId);
            Assert.AreEqual(100, groupedSiteVolumes.ElementAt(1).Volume);
            Assert.AreEqual(new DateTime(2016, 2, 1),
                            groupedSiteVolumes.ElementAt(1).BillingMonth);
            Assert.AreEqual(20, groupedSiteVolumes.ElementAt(1).SiteId);
        }
        [TestMethod] public void NotAllVolumesAvailableAndNotNoVolumesAvailableContract()
        {
            var contract  = ContractReaderStub.Contract();
            var contracts = ContractReaderStub.Contracts();
            var products  = ContractProductReaderStub.Products();
            var sites     = ContractProductSiteReaderStub.Sites();
            var volumes   = ContractProductSiteVolumeReaderStub.NotAllVolumeNotNoVolume();

            var forecaster =
                new SiteVolumeCalculator();

            var actualResult =
                forecaster.TotalContractedVolume(
                    contract, contracts,
                    products,
                    sites,
                    volumes
                    );

            Assert.AreEqual(250, actualResult);
        }
        public void TotalContractedVolumeForAllVolumeAvailableContract()
        {
            var contract  = ContractReaderStub.Contract();
            var contracts = ContractReaderStub.Contracts();
            var products  = ContractProductReaderStub.Products();
            var sites     = ContractProductSiteReaderStub.Sites();
            var volumes   = ContractProductSiteVolumeReaderStub.AllVolumes();

            var forecaster =
                new SiteVolumeCalculator();

            var actualResult =
                forecaster.TotalContractedVolume(
                    contract, contracts,
                    products,
                    sites,
                    volumes
                    );

            Assert.AreEqual(300, actualResult);
        }