public void GetsAListForFilteredOnLoggedInUser() { IRepository <Client> clientRepository = new LocalRepository <Client>(); IRepository <Budget> budgetRepository = new LocalRepository <Budget>(); var userManager = new Mock <IIdentityMembershipProvider>(); var consultantGuid = Guid.NewGuid(); Client client1 = new Client(); client1.IsActive = true; client1.Consultant = new InsideUser() { Id = consultantGuid.ToString() }; client1.Budgets.Add(new Budget() { Value = 1000, Month = new DateTime(2014, 1, 1) }); client1.Budgets.Add(new Budget() { Value = 2000, Month = new DateTime(2014, 2, 1) }); Client client2 = new Client(); client2.IsActive = true; client2.Consultant = new InsideUser() { Id = consultantGuid.ToString() }; Client client3 = new Client(); client3.IsActive = true; client3.Consultant = new InsideUser() { Id = Guid.NewGuid().ToString() }; clientRepository.Add(client1); clientRepository.Add(client2); clientRepository.Add(client3); var claim = new Claim("test", consultantGuid.ToString()); userManager.Setup(um => um.GetRoles(consultantGuid.ToString())).Returns(new List <string> { "mockRole" }); var controller = new BudgetController(clientRepository, budgetRepository, userManager.Object); ModelHelper.SetClaimAsCurrentUserForController(claim, controller); var result = controller.Index("") as ViewResult; var resultModel = result.Model as ClientsWithBudgetsViewModel; Assert.AreEqual(2, resultModel.Clients.Count); var result2 = controller.Index("", showAll: true) as ViewResult; var result2Model = result2.Model as ClientsWithBudgetsViewModel; Assert.AreEqual(3, result2Model.Clients.Count); }