AirTNG.Web.Tests.Controllers.VacationPropertiesControllerTest.GivenACreateAction_WhenTheModelStateIsValid_ThenItRedirectsToIndex C# (CSharp) Метод

GivenACreateAction_WhenTheModelStateIsValid_ThenItRedirectsToIndex() приватный Метод

private GivenACreateAction_WhenTheModelStateIsValid_ThenItRedirectsToIndex ( ) : void
Результат void
        public void GivenACreateAction_WhenTheModelStateIsValid_ThenItRedirectsToIndex()
        {
            var model = new VacationPropertyViewModel();
            var mockRepository = new Mock<IVacationPropertiesRepository>();
            mockRepository.Setup(r => r.CreateAsync(It.IsAny<VacationProperty>())).ReturnsAsync(1);

            var controller = new VacationPropertiesController(mockRepository.Object)
            {
                UserId = () => "bob-id"
            };

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

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