AirTNG.Web.Tests.Controllers.VacationPropertiesControllerTest.GivenAnEditAction_WhenTheModelStateIsValid_ThenItRedirectsToIndex C# (CSharp) Method

GivenAnEditAction_WhenTheModelStateIsValid_ThenItRedirectsToIndex() private method

        public void GivenAnEditAction_WhenTheModelStateIsValid_ThenItRedirectsToIndex()
        {
            var model = new VacationPropertyViewModel();
            var vacationProperty = new VacationProperty();

            var mockRepository = new Mock<IVacationPropertiesRepository>();
            mockRepository.Setup(r => r.FindAsync(It.IsAny<int>())).ReturnsAsync(vacationProperty);
            mockRepository.Setup(r => r.UpdateAsync(It.IsAny<VacationProperty>())).ReturnsAsync(1);

            var controller = new VacationPropertiesController(mockRepository.Object);

            controller.WithCallTo(c => c.Edit(model))
                .ShouldRedirectTo(c => c.Index());

            mockRepository.Verify(r => r.UpdateAsync(It.IsAny<VacationProperty>()), Times.Once);
        }