public void Index_Get_Should_Return_View() { // arrange FakeConnectionRepository connectionRepository = new FakeConnectionRepository(); ConnectionController connectionController = new ConnectionController(connectionRepository); // act ViewResult viewResult = connectionController.Index() as ViewResult; // assert Assert.IsNotNull(viewResult); }
public void Index_Get_Should_Display_Connections() { FakeConnectionRepository connectionRepository = new FakeConnectionRepository(); connectionRepository.AddConnection(new ConnectionModel() { ConnectionId = 1, Name = "connection1" }); connectionRepository.AddConnection(new ConnectionModel() { ConnectionId = 2, Name = "connection2" }); ConnectionController connectionController = new ConnectionController(connectionRepository); // act ViewResult viewResult = connectionController.Index() as ViewResult; IEnumerable<ConnectionModel> connectionList = viewResult.ViewData.Model as IEnumerable<ConnectionModel>; // assert Assert.IsNotNull(connectionList); Assert.IsTrue(connectionList.Count() == 2); }