Exemple #1
0
        public void DeleteSaleModelNotFoundTest()
        {
            // Arrange
            var mockRepository = new Mock <IStorage <SaleModel> >().Object;
            var controller     = new SaleAPIController(mockRepository);
            var id             = Guid.NewGuid();
            // Act
            var actionResult = controller.DeleteSaleModel(id) as NotFoundResult;

            // Assert
            Assert.NotNull(actionResult);
            Assert.Equal((int)HttpStatusCode.NotFound, actionResult.StatusCode);
        }
Exemple #2
0
        public void DeleteSaleModelBadRequestTest()
        {
            var id = Guid.NewGuid();
            // Arrange
            var mockRepository = new Mock <IStorage <SaleModel> >();
            var controller     = new SaleAPIController(mockRepository.Object);

            controller.ModelState.AddModelError("Error", "Error");
            // Act
            var actionResult = controller.DeleteSaleModel(id) as BadRequestObjectResult;

            // Assert
            Assert.NotNull(actionResult);
            Assert.Equal((int)HttpStatusCode.BadRequest, actionResult.StatusCode);
        }
Exemple #3
0
        public void DeleteSaleModelTest()
        {
            var id = Guid.NewGuid();
            // Arrange
            var mockRepository = new Mock <IStorage <SaleModel> >();

            mockRepository.Setup(x => x.Get(id)).Returns(new SaleModel()
            {
                Id = id
            });
            mockRepository.Setup(x => x.Remove(It.IsAny <Guid>()));
            var controller = new SaleAPIController(mockRepository.Object);
            // Act
            var actionResult = controller.DeleteSaleModel(id) as OkObjectResult;

            // Assert
            Assert.NotNull(actionResult);
            Assert.Equal((int)HttpStatusCode.OK, actionResult.StatusCode);
            Assert.NotNull(actionResult.Value);
            Assert.IsType <SaleModel>(actionResult.Value);
            Assert.Equal(id, (actionResult.Value as SaleModel).Id);
        }