Example #1
0
        public void UpdatePrices_OnlyExtremaFlaggedAsUpdatedAreSendToRepository()
        {
            //Arrange
            QuotationUpdateTester quotationRepository = new QuotationUpdateTester();
            PriceUpdateTester     priceRepository     = new PriceUpdateTester();

            List <DataSet> dataSets = new List <DataSet>();
            DataSet        ds1      = utf.getDataSet(1);
            Quotation      q1       = utf.getQuotation(ds1);
            Price          p1       = utf.getPrice(ds1);

            DataSet   ds2 = utf.getDataSet(2);
            Quotation q2  = utf.getQuotation(ds2);
            Price     p2  = utf.getPrice(ds2);
            Extremum  ex2 = new Extremum(p2, ExtremumType.PeakByClose);

            DataSet   ds3 = utf.getDataSet(3);
            Quotation q3  = utf.getQuotation(ds3);
            Price     p3  = utf.getPrice(ds3);
            Extremum  ex3 = new Extremum(p3, ExtremumType.PeakByHigh);

            DataSet   ds4 = utf.getDataSet(4);
            Quotation q4  = utf.getQuotation(ds4);
            Price     p4  = utf.getPrice(ds4);

            dataSets.AddRange(new DataSet[] { ds1, ds2, ds3, ds4 });

            //Act
            p2.Updated  = true;
            p3.Updated  = true;
            ex3.Updated = true;
            p4.New      = true;


            IDataSetService service = new DataSetService();

            service.InjectQuotationRepository(quotationRepository);
            service.InjectPriceRepository(priceRepository);
            service.UpdateDataSets(dataSets);

            //Assert
            IEnumerable <ExtremumDto> extremumDtos         = priceRepository.GetExtremumDtosPassedForUpdate();
            List <ExtremumDto>        expectedExtremumDtos = new List <ExtremumDto>();

            expectedExtremumDtos.AddRange(new ExtremumDto[] { ex3.ToDto() });
            bool areEqual = expectedExtremumDtos.HasEqualItems(extremumDtos);

            Assert.IsTrue(areEqual);
        }
Example #2
0
        public void UpdateDataSets_OnlyQuotationsFlaggedAsUpdatedAreSendToRepository()
        {
            //Arrange
            QuotationUpdateTester quotationRepository = new QuotationUpdateTester();
            PriceUpdateTester     priceRepository     = new PriceUpdateTester();

            List <DataSet> dataSets = new List <DataSet>();
            DataSet        ds1      = utf.getDataSet(1);
            Quotation      q1       = utf.getQuotation(ds1);
            Price          p1       = utf.getPrice(ds1);

            DataSet   ds2 = utf.getDataSet(2);
            Quotation q2  = utf.getQuotation(ds2);
            Price     p2  = utf.getPrice(ds2);

            DataSet   ds3 = utf.getDataSet(3);
            Quotation q3  = utf.getQuotation(ds3);
            Price     p3  = utf.getPrice(ds3);

            DataSet   ds4 = utf.getDataSet(4);
            Quotation q4  = utf.getQuotation(ds4);
            Price     p4  = utf.getPrice(ds4);

            dataSets.AddRange(new DataSet[] { ds1, ds2, ds3, ds4 });

            //Act
            q1.Updated = true;
            q3.Updated = true;
            q4.New     = true;

            IDataSetService service = new DataSetService();

            service.InjectQuotationRepository(quotationRepository);
            service.InjectPriceRepository(priceRepository);
            service.UpdateDataSets(dataSets);

            //Assert
            IEnumerable <QuotationDto> passedDtos   = quotationRepository.GetQuotationDtosPassedForUpdate();
            List <QuotationDto>        expectedDtos = new List <QuotationDto>();

            expectedDtos.AddRange(new QuotationDto[] { q1.ToDto(), q3.ToDto(), q4.ToDto() });
            bool areEqual = expectedDtos.HasEqualItems(passedDtos);

            Assert.IsTrue(areEqual);
        }