示例#1
0
        public void ShouldNot_DeletePricingStrategy_NotFound()
        {
            PricingStrategy testPricingStrategy = new PricingStrategy {
                Id = 10
            };

            Mock <IUnitOfWork> mock = new Mock <IUnitOfWork>();

            mock.Setup(f => f.PricingStrategies.GetById(10)).Returns((PricingStrategy)null);

            PricingStrategiesController controller = new PricingStrategiesController(mock.Object);
            var result = controller.DeletePricingStrategy(10);

            Assert.IsType <NotFoundResult>(result);
        }
示例#2
0
        public void Should_DeletePricingStrategy()
        {
            PricingStrategy testPricingStrategy = new PricingStrategy {
                Id = 1
            };

            Mock <IUnitOfWork> mock = new Mock <IUnitOfWork>();

            mock.Setup(f => f.PricingStrategies.GetById(1)).Returns(testPricingStrategy);
            mock.Setup(f => f.PricingStrategies.Delete(testPricingStrategy)).Returns(true);

            PricingStrategiesController controller = new PricingStrategiesController(mock.Object);
            var result = controller.DeletePricingStrategy(1);

            Assert.IsType <OkObjectResult>(result);
        }
示例#3
0
        public void ShouldNot_DeletePricingStrategy_ModelStateError()
        {
            PricingStrategy testPricingStrategy = new PricingStrategy {
                Id = 1
            };

            Mock <IUnitOfWork> mock = new Mock <IUnitOfWork>();

            mock.Setup(f => f.PricingStrategies.Delete(testPricingStrategy)).Returns(true);

            PricingStrategiesController controller = new PricingStrategiesController(mock.Object);

            controller.ModelState.AddModelError("TestError", "Error");
            var result = controller.DeletePricingStrategy(1);

            Assert.IsType <BadRequestObjectResult>(result);
        }