Example #1
0
        public void Should_PostPricingStrategy()
        {
            PricingStrategy testPricingStrategy = new PricingStrategy {
                Id = 1, Name = "Test1", Description = "Test", PricingStrategyItems = new List <PricingStrategyItem>()
            };

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

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

            PricingStrategiesController controller = new PricingStrategiesController(mock.Object);
            var pricingStrategy = controller.PostPricingStrategy(testPricingStrategy);

            Assert.IsType <CreatedAtActionResult>(pricingStrategy);
        }
Example #2
0
        public void ShouldNot_PostPricingStrategy_ModelStateError()
        {
            PricingStrategy testPricingStrategy = new PricingStrategy {
                Id = 1, Name = "Test1", Description = "Test", PricingStrategyItems = new List <PricingStrategyItem>()
            };

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

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

            PricingStrategiesController controller = new PricingStrategiesController(mock.Object);

            controller.ModelState.AddModelError("TestError", "Error");
            var pricingStrategy = controller.PostPricingStrategy(testPricingStrategy);

            Assert.IsType <BadRequestObjectResult>(pricingStrategy);
        }