public void CanGetAListOfBudgetsForClientOrderedByHandleStatusIgnoreInactiveClients() { IRepository <Client> clientRepository = new LocalRepository <Client>(); IRepository <Budget> budgetRepository = new LocalRepository <Budget>(); var userManager = new Mock <IIdentityMembershipProvider>(); var budget1 = new Budget() { Value = 1000, Month = new DateTime(2014, 1, 1), ClientId = 1, IsHandled = false }; var budget2 = new Budget() { Value = 2000, Month = new DateTime(2014, 2, 1), ClientId = 1 }; var budget3 = new Budget() { Value = 4000, Month = new DateTime(2014, 3, 1), ClientId = 2, IsHandled = false }; var budget4 = new Budget() { Value = 4000, Month = new DateTime(2014, 3, 1), ClientId = 3 }; budgetRepository.Add(budget1); budgetRepository.Add(budget2); budgetRepository.Add(budget3); budgetRepository.Add(budget4); Client client1 = new Client(); client1.Id = 1; client1.IsActive = true; client1.FeeFixedMonthly = 250; client1.FeePercent = 0.1m; client1.Budgets.Add(budget1); client1.Budgets.Add(budget2); budget1.Client = client1; budget2.Client = client1; Client client2 = new Client(); client2.IsActive = true; client2.Id = 2; client2.Budgets.Add(budget3); Client client3 = new Client(); client2.IsActive = false; client2.Id = 3; client2.Budgets.Add(budget4); clientRepository.Add(client1); clientRepository.Add(client2); clientRepository.Add(client3); var claim = new Claim("test", "AnyId"); userManager.Setup(um => um.GetRoles(It.IsAny <string>())).Returns(new List <string> { "mockRole" }); var controller = new BudgetController(clientRepository, budgetRepository, userManager.Object); ModelHelper.SetClaimAsCurrentUserForController(claim, controller); var result = controller.List(1, "Potential error message") as ViewResult; var resultModel = result.Model as ClientBudgetListViewModel; Assert.AreEqual(2, resultModel.Budgets.Count()); Assert.AreEqual(2000, resultModel.Budgets[1].Value); Assert.AreEqual(1800, resultModel.Budgets[1].AdSpent); Assert.AreEqual(1000, resultModel.Budgets[0].Value); Assert.AreEqual(900, resultModel.Budgets[0].AdSpent); Assert.AreEqual(new DateTime(2014, 2, 1), resultModel.Budgets[1].Month); Assert.AreEqual(new DateTime(2014, 1, 1), resultModel.Budgets[0].Month); Assert.AreEqual(1, resultModel.ClientId); Assert.AreEqual("Potential error message", resultModel.Error); }