public void IndexShould_CallFactoryMethodCreateNavigationViewModel() { 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.Index(); factoryMock.Verify(f => f.CreateNavigationViewModel(false, false, false, "", ""), Times.Once); }
public void IndexShould_CallAuthProviderPropertyCurrentUsername_WhenUserIsAdmin() { var authProviderMock = new Mock <IAuthenticationProvider>(); var factoryMock = new Mock <IViewModelFactory>(); var model = new NavigationViewModel(true, false, true, "", ""); 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); factoryMock.Setup(f => f.CreateNavigationViewModel(true, false, true, username, userId)).Returns(model); var controller = new Web.Controllers.NavigationController(authProviderMock.Object, factoryMock.Object); controller.Index(); authProviderMock.Verify(ap => ap.CurrentUserUsername, Times.Once); }