コード例 #1
0
        public void ShouldNotRegisterNewCPriceHistoryIfItExists()
        {
            // Arrange
            var phTableRepository         = Substitute.For <ITableRepository <PriceHistory> >();
            var DTOMethods                = Substitute.For <IDTOMethodsforPriceHistory>();
            PriceHistoryService phService = new PriceHistoryService(phTableRepository, DTOMethods);
            PriceInfo           priceInfo = new PriceInfo
            {
                StockId       = 1,
                DateTimeBegin = new DateTime(2019, 8, 20, 09, 55, 00),
                DateTimeEnd   = new DateTime(2019, 8, 20, 19, 30, 00),
                Price         = 200
            };

            // Act
            phService.AddPriceInfo(priceInfo);

            phTableRepository.ContainsDTO(Arg.Is <PriceHistory>(
                                              w => w.StockID == 1 &&
                                              w.DateTimeBegin == new DateTime(2019, 8, 20, 09, 55, 00) &&
                                              w.DateTimeEnd == new DateTime(2019, 8, 20, 19, 30, 00) &&
                                              w.Price == 200)).Returns(true);
            phService.AddPriceInfo(priceInfo);
        }
コード例 #2
0
        public void ShouldAddNewPriceHistory()
        {
            //Arrange
            var phTableRepository         = Substitute.For <ITableRepository <PriceHistory> >();
            var DTOMethods                = Substitute.For <IDTOMethodsforPriceHistory>();
            PriceHistoryService phService = new PriceHistoryService(phTableRepository, DTOMethods);
            PriceInfo           priceInfo = new PriceInfo
            {
                StockId       = 1,
                DateTimeBegin = new DateTime(2019, 8, 20, 09, 55, 00),
                DateTimeEnd   = new DateTime(2019, 8, 20, 19, 30, 00),
                Price         = 200
            };

            //Act
            phService.AddPriceInfo(priceInfo);
            //Assert
            phTableRepository.Received(1).Add(Arg.Is <PriceHistory>(
                                                  w => w.StockID == 1 &&
                                                  w.DateTimeBegin == new DateTime(2019, 8, 20, 09, 55, 00) &&
                                                  w.DateTimeEnd == new DateTime(2019, 8, 20, 19, 30, 00) &&
                                                  w.Price == 200
                                                  ));
        }