Example #1
0
        public async void Registered_User_Should_Be_Able_To_Log_In()
        {
            string        testUserName = "******";
            string        testPassword = "******";
            Result <User> authenticationResult;

            var testUser = new User((Nickname)testUserName, (FullName)"test1 user1", Password.Create(testPassword).Value, (Email)"*****@*****.**", "bio1");

            using (var session = _testFixture.OpenSession(_output))
            {
                await session.SaveAsync(testUser);
            }

            using (var session = _testFixture.OpenSession(_output))
            {
                var sut = new DatabaseAuthenticationService(session, Log.Logger);
                authenticationResult = await sut.AuthenticateUser(testUserName, testPassword);
            }

            using (new AssertionScope())
            {
                authenticationResult.IsSuccess.Should().BeTrue();
                authenticationResult.Value.Should().NotBeNull();
                authenticationResult.Value.ID.Should().Be(testUser.ID);
            }
        }
Example #2
0
        public async void Unregistered_User_Should_Not_Be_Able_To_Log_In()
        {
            Result <User> authenticationResult;

            using (var session = _testFixture.OpenSession(_output))
            {
                var sut = new DatabaseAuthenticationService(session, Log.Logger);
                authenticationResult = await sut.AuthenticateUser("not_existing_user", "xxx42");
            }

            authenticationResult.IsSuccess.Should().BeFalse();
        }
Example #3
0
        public async void Registered_User_Should_Not_Be_Able_To_Log_In_With_Wrong_Password()
        {
            string        testUserName = "******";
            string        testPassword = "******";
            Result <User> authenticationResult;

            var testUser = new User((Nickname)testUserName, (FullName)"test3 user3", Password.Create(testPassword).Value, (Email)"*****@*****.**", "bio3");

            using (var session = _testFixture.OpenSession(_output))
            {
                await session.SaveAsync(testUser);
            }

            using (var session = _testFixture.OpenSession(_output))
            {
                var sut = new DatabaseAuthenticationService(session, Log.Logger);
                authenticationResult = await sut.AuthenticateUser(testUserName, "xxx42");
            }

            authenticationResult.IsSuccess.Should().BeFalse();
        }