public void Add_AddsEmployeeAndReturnsARedirect_WhenModelStateIsValid()
        {
            //Arrange
            var mockStorageService = new Mock <IService <IRepository <Storage>, Storage> >();

            mockStorageService.Setup(repo => repo.GetByIdAsync(1)).ReturnsAsync(GetStorage())
            .Verifiable();
            var httpContext = new DefaultHttpContext();
            var tempData    = new TempDataDictionary(httpContext, Mock.Of <ITempDataProvider>());
            var controller  = new StorageController(mockStorageService.Object)
            {
                TempData = tempData
            };

            controller.ModelState.AddModelError("Quantity", "Required");
            var inputModel = new PCItemInputModel()
            {
                Id = 1, Quantity = 1
            };

            // Act
            var result = controller.Add(inputModel);

            // Assert
            Assert.IsType <JsonResult>(result.Result);
            mockStorageService.Verify();
        }
        public async Task AddStorageTestAsync()
        {
            // Arrange
            Mock <Storage>    mockStorage = new Mock <Storage>();
            StorageController controller  = new StorageController(mockStorageService.Object);

            // Act
            var result = await controller.Add(await StorageTestHelper.GetStorageCreateNormal());

            var okResult = Assert.IsType <OkObjectResult>(result);

            // Assert
            Assert.IsType <OkObjectResult>(result);
            mockStorageService.Verify(
                mock => mock.Add(mockStorage.Object), Times.Never());
        }
        public void Add_ReturnsBadRequestResult_WhenModelStateIsInvalid()
        {
            // Arrange
            var mockStorageService = new Mock <IService <IRepository <Storage>, Storage> >();
            var inputModel         = new PCItemInputModel()
            {
                Id = 0, Quantity = 0
            };
            var controller = new StorageController(mockStorageService.Object);

            controller.ModelState.AddModelError("Quantity", "Required");

            // Act
            var result = controller.Add(inputModel);

            // Assert
            var badRequestResult = Assert.IsType <BadRequestResult>(result.Result);
        }
        public void Add_ModelAdded()
        {
            controller.Add(new ModelMock());

            Assert.That(controller.Count(), Is.EqualTo(modelsCount + 1));
        }