Exemple #1
0
        public async void CallDeleteAddressModelWithAValidModel()
        {
            var result = await sut.DeleteConfirmed(It.IsAny <int>());

            fixture.repositoryWrapper.Verify(x => x.Address.DeleteAddress(It.IsAny <Address>()), Times.Once);
            fixture.repositoryWrapper.Verify(y => y.SaveAsync(), Times.Once);
            Assert.IsAssignableFrom <RedirectToActionResult>(result);
        }
        public void Delete_Post_Action_Calls_DeleteRecord()
        {
            //Arrange
            _addressServiceMock.Setup(x => x.DeleteRecord(It.IsAny <Address>()));

            //Act
            var result = (RedirectToRouteResult)objController.DeleteConfirmed(1);

            //Assert
            _addressServiceMock.Verify(x => x.DeleteRecord(It.IsAny <Address>()), Times.Once);
            Assert.Equal(Constant.Controller.Index, result.RouteValues[Constant.Controller.Action]);
        }
        public void AddressDeleteTest()
        {
            //setup
            var id      = 1;
            var address = new Address {
                Id = id
            };

            var repo = new Mock <IGenericRepository <Address> >();

            repo.Setup(x => x.Delete(id));
            _addressController = new AddressController(repo.Object);

            //execute
            _addressController.DeleteConfirmed(id);

            //assert
            repo.Verify(x => x.Delete(id), Times.Once);
        }