Example #1
0
        public void GetCurrentUser_Should_ReturnsNullIfNotLoggedIn()
        {
            // Arrange DAL to always return null ensuring that user does not exist
            mockUserDal.Setup(m => m.GetUser(It.IsAny <string>())).Returns <User>(null);

            var provider = new SessionAuthProvider(mockAccessor.Object, mockUserDal.Object);

            Assert.IsNull(provider.GetCurrentUser());
        }
Example #2
0
        public void GetCurrentUser_Should_ReturnsUserIfLoggedIn()
        {
            // Arrange DAL to have user named "test"
            AddUserToDAL("test");
            AddUserToSession("test");

            var provider = new SessionAuthProvider(mockAccessor.Object, mockUserDal.Object);

            // Call our method to test
            var user = provider.GetCurrentUser();

            // Assert
            Assert.IsNotNull(user);
            Assert.AreEqual("test", user.Username);
        }