public async Task ShouldGetIndexPage() { //Arrange var mockFundManRepo = new Mock <IFundManagerRepository>(); IEnumerable <FundManager> fundManagerModels = new FundManager[0]; mockFundManRepo.Setup(m => m.GetAll()) .Returns(Task.FromResult(fundManagerModels)) .Verifiable(); var mockFundRepo = new Mock <IFundRepository>(); IEnumerable <Fund> emptyFunds = new List <Fund>(); mockFundRepo.Setup(m => m.GetFunds(new Guid())) .Returns(Task.FromResult(emptyFunds)) .Verifiable(); var controller = new FundManagerController(mockFundManRepo.Object, mockFundRepo.Object); //NUnit-IS.EqualTo compares single dimensional arrays, so this will match. var expected = new FundManager[0]; //Act var actual = await controller.Index(); //Assert Assert.That(actual, Is.TypeOf <ViewResult>()); Assert.That(((ViewResult)actual).Model, Is.EqualTo(expected)); mockFundManRepo.Verify(); }
public async void ShouldGetIndexPage() { var mock = new Mock <IFundManagerModelRepository>(); var fundManagerModels = new FundManagerModel[0].AsEnumerable(); mock.Setup(m => m.GetAll()).Returns(Task.FromResult(fundManagerModels)); var controller = new FundManagerController(mock.Object); var result = await controller.Index(1, string.Empty, null); Assert.That(result, Is.TypeOf <ViewResult>()); mock.Verify(); Assert.That(((ViewResult)result).Model, Is.EqualTo(fundManagerModels)); }
public async void ShouldGetIndexPage() { //Arrange var mock = new Mock <IFundManagerRepository>(); IEnumerable <FundManager> fundManagerModels = new FundManager[0]; mock.Setup(m => m.GetAll()) .Returns(Task.FromResult(fundManagerModels)) .Verifiable(); var controller = new FundManagerController(mock.Object); //Act var result = await controller.Index(); //Assert Assert.That(result, Is.TypeOf <ViewResult>()); Assert.That(((ViewResult)result).Model, Is.EqualTo(fundManagerModels)); mock.Verify(); }