Пример #1
0
        public void SetOrderToUpdateIsProceededValueToTrue()
        {
            //Arrange
            var mockedOrderDataProvider = new Mock <IEfComicShopDataProvider <Order> >();
            var mockedComicDataProvider = new Mock <IEfComicShopDataProvider <Comic> >();
            var orderId             = 5;
            var mockedOrderToUpdate = new Order()
            {
                Id = orderId, isProceeded = false
            };


            mockedOrderDataProvider.Setup(x => x.GetById(orderId)).Returns(mockedOrderToUpdate);

            //Act
            var actualOrderService = new ComicShop.Data.Services.OrderService(
                mockedOrderDataProvider.Object,
                mockedComicDataProvider.Object,
                mockedOrderToUpdate);

            actualOrderService.ProceedOrderById(orderId);

            //Assert
            Assert.AreEqual(mockedOrderToUpdate.isProceeded, true);
        }
Пример #2
0
        public void CallOrderDataProviderSaveChangesMethod()
        {
            //Arrange
            var mockedOrderDataProvider = new Mock <IEfComicShopDataProvider <Order> >();
            var mockedComicDataProvider = new Mock <IEfComicShopDataProvider <Comic> >();
            var orderId             = 5;
            var mockedOrderToUpdate = new Order()
            {
                Id = orderId
            };


            mockedOrderDataProvider.Setup(x => x.GetById(orderId)).Returns(mockedOrderToUpdate);

            //Act
            var actualOrderService = new ComicShop.Data.Services.OrderService(
                mockedOrderDataProvider.Object,
                mockedComicDataProvider.Object,
                mockedOrderToUpdate);

            actualOrderService.ProceedOrderById(orderId);

            //Assert
            mockedOrderDataProvider.Verify(x => x.SaveChanges(), Times.Once);
        }