public void AddEventPostShouldReutrnCorrectViewWhenModelStateIsNotValid() { AutoMapperConfig autoMapperConfig = GetAutoMapper(); autoMapperConfig.Execute(typeof(EventsPrivateController).Assembly); EventChangeViewModel model = new EventChangeViewModel(); var controller = new EventsPrivateController(eventsServiceMock.Object, usersServiceMock.Object, citiesServiceMock.Object, sportCategoriesServiceMock.Object, facilitiesServiceMock.Object); controller.ModelState.AddModelError("key", "error"); controller.WithCallTo(x => x.AddEvent(model)) .ShouldRenderView("AddEvent") .WithModel<EventChangeViewModel>(); }
public void AddEventShouldreutrnCorrectiewWihCorrectNumberOfSportCategories() { AutoMapperConfig autoMapperConfig = GetAutoMapper(); autoMapperConfig.Execute(typeof(EventsPrivateController).Assembly); sportCategoriesServiceMock.Setup(x => x.All()) .Returns(new List<SportCategory> { new SportCategory() { Name = "Test", Description = "TestDescription" }, new SportCategory{ Name = "Test", Description = "TestDescription" } }.AsQueryable); var controller = new EventsPrivateController(eventsServiceMock.Object, usersServiceMock.Object, citiesServiceMock.Object, sportCategoriesServiceMock.Object, facilitiesServiceMock.Object); controller.WithCallTo(x => x.AddEvent()) .ShouldRenderView("AddEvent") .WithModel<EventChangeViewModel>( viewModel => { Assert.AreEqual(2, viewModel.SportCategoriesDropDown.Count()); }).AndNoModelErrors(); }