public void AddEventShouldReutrnCorrectiewWihCorrectNumberOfCities() { AutoMapperConfig autoMapperConfig = GetAutoMapper(); autoMapperConfig.Execute(typeof(EventsPrivateController).Assembly); citiesServiceMock.Setup(x => x.All()) .Returns(new List<City> { new City() { Name = "Test1" }, new City{ Name = "Test2" }, new City{ Name = "Test3" } }.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(3, viewModel.CitiesDropDown.Count()); }).AndNoModelErrors(); }
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>(); }