public void IndexShould_ReturnPartialViewWithCorrectModel_WhenUserIsManager() { var authProviderMock = new Mock <IAuthenticationProvider>(); var factoryMock = new Mock <IViewModelFactory>(); authProviderMock.Setup(p => p.IsAuthenticated).Returns(true); var userId = Guid.NewGuid().ToString(); var username = "******"; authProviderMock.Setup(p => p.CurrentUserId).Returns(userId); authProviderMock.Setup(p => p.CurrentUserUsername).Returns(username); authProviderMock.Setup(p => p.IsInRole(userId, "Admin")).Returns(false); authProviderMock.Setup(p => p.IsInRole(userId, "Manager")).Returns(true); var model = new NavigationViewModel(true, true, false, username, userId); factoryMock.Setup(f => f.CreateNavigationViewModel(true, true, false, username, userId)) .Returns(model); var controller = new Web.Controllers.NavigationController(authProviderMock.Object, factoryMock.Object); controller .WithCallTo(c => c.Index()) .ShouldRenderPartialView("Navigation") .WithModel(model); }
public void IndexShould_ReturnPartialViewWithCorrectModel() { var authProviderMock = new Mock <IAuthenticationProvider>(); var factoryMock = new Mock <IViewModelFactory>(); var model = new NavigationViewModel(false, false, false, "", ""); authProviderMock.Setup(p => p.IsAuthenticated).Returns(false); factoryMock.Setup(f => f.CreateNavigationViewModel(false, false, false, "", "")).Returns(model); var controller = new Web.Controllers.NavigationController(authProviderMock.Object, factoryMock.Object); controller .WithCallTo(c => c.Index()) .ShouldRenderPartialView("Navigation") .WithModel(model); }