public void Should_return_a_view_for_the_index() { var controller = new HomeController(MockRepository.GenerateMock<ISharedSettings>()); var result = controller.Index(); Assert.IsInstanceOfType(typeof (ViewResult), result); }
public void Index() { // Arrange HomeController controller = new HomeController(); // Act ViewResult result = controller.Index() as ViewResult; // Assert Assert.AreEqual("Welcome to Gallery 202/Westerville Artists Unit Administration!", result.ViewBag.Message); }
public void Index() { // Arrange HomeController controller = new HomeController(); // Act ViewResult result = controller.Index() as ViewResult; // Assert Assert.IsNotNull(result); }
public void Index_should_display_three_upcoming_booked_presentations() { var controller = new HomeController { Session = documentStore.OpenSession() }; var result = controller.Index() as ViewResult; var model = result.Model as IEnumerable<Presentation>; Assert.That(model.Count(), Is.EqualTo(3)); Assert.That(model.All(x => x.Booked), Is.True); Assert.That(model.All(x => x.PresentationDate > DateTime.Today), Is.True); Assert.That(model.Select(x => x.PresentationDate), Is.EquivalentTo(model.OrderBy(x => x.PresentationDate).Select(x => x.PresentationDate))); }
public void Index() { // Arrange var controller = new HomeController (); // Act var result = (ViewResult)controller.Index (); var mvcName = typeof(Controller).Assembly.GetName (); var isMono = Type.GetType ("Mono.Runtime") != null; var expectedVersion = mvcName.Version.Major; var expectedRuntime = isMono ? "Mono" : ".NET"; // Assert Assert.AreEqual (expectedVersion, result.ViewData ["Version"]); Assert.AreEqual (expectedRuntime, result.ViewData ["Runtime"]); }
public void Index_should_display_three_upcoming_booked_presentations() { var presentations = new[] { new Presentation { Booked = true, PresentationDate = DateTime.Today.AddMonths(-1)}, new Presentation { Booked = true, PresentationDate = DateTime.Today}, new Presentation { Booked = true, PresentationDate = DateTime.Today.AddMonths(1)}, new Presentation { Booked = true, PresentationDate = DateTime.Today.AddMonths(2)}, new Presentation { Booked = true, PresentationDate = DateTime.Today.AddMonths(3)}, }; PrepareSession(presentations); var controller = new HomeController(documentStore.OpenSession()); var result = controller.Index() as ViewResult; var model = result.Model as IEnumerable<Presentation>; Assert.That(model.Count(), Is.EqualTo(3)); Assert.That(model.All(x => x.Booked), Is.True); Assert.That(model.All(x => x.PresentationDate > DateTime.Today.AddDays(-7)), Is.True); Assert.That(model.Select(x => x.PresentationDate), Is.EquivalentTo(model.OrderBy(x => x.PresentationDate).Select(x => x.PresentationDate))); }
public void TestMethod1() { var controller = new HomeController(); var result = controller.Index(); }
public void Index_Build_View_Model_Succeed() { //Arrange var eventOne = new Event {EventId = 1, Title = "Test event 1"}; var eventTwo = new Event {EventId = 2, Title = "Test event 2"}; var hostingEvent = new Event { EventId = 3, Title = "My own event"}; var personResults = new List<Person> { new Person{PersonId = 1, FirstName = "Joe", LastName = "Smith", MyEvents = new List<Event> {hostingEvent}, MyInvitations = new List<Event> { eventOne, eventTwo }, AmAttending = new List<Event> { eventOne }, HaveDeclined = new List<Event> { eventTwo } } }; A.CallTo(() => PersonRepo.GetAll()).Returns(personResults.AsQueryable()); A.CallTo(() => UserService.GetCurrentUserId("")).Returns(1); var controller = new HomeController(RepositoryFactory, UserService, NotifyService, EventService); //Act var result = controller.Index(null) as ViewResult; var model = result.Model as HomeViewModel; //Assert var acceptedInvitationsCount = model.MyInvitations.Count(x => x.HasAccepted == true && x.HasDeclined == false); var declinedInvitationsCount = model.MyInvitations.Count(x => x.HasAccepted == false && x.HasDeclined == true); Assert.AreEqual(string.Empty, result.ViewBag.StatusMessage); Assert.AreEqual(model.MyEvents.Count, 1); Assert.AreEqual(model.MyInvitations.Count, 2); Assert.AreEqual(model.HaveDeclined.Count, 1); Assert.AreEqual(model.AmAttending.Count, 1); Assert.AreEqual(acceptedInvitationsCount, 1); Assert.AreEqual(declinedInvitationsCount, 1); }
public void Index_Build_View_Model_Fail() { //Arrange A.CallTo(() => PersonRepo.GetAll()).Throws(new Exception("I can't find the database!")); var controller = new HomeController(RepositoryFactory, UserService, NotifyService, EventService); //Act var result = controller.Index(null) as ViewResult; //Assert Assert.AreEqual(Constants.BASE_BUILD_VIEW_FAIL, result.ViewBag.StatusMessage); }