Ejemplo n.º 1
0
        public void ExistingUserAuthenticatingShouldUseExistingUser()
        {
            var authenticatedUser = new AuthenticatedUser(Guid.NewGuid(), "user1", "email1", "picture", new List<AuthenticationProvider>()
            {
                new AuthenticationProvider(Guid.NewGuid(), "Facebook", "12345"),
            });

            var authenticatedClient = new AuthenticatedClient("Facebook")
            {
                UserInformation = new UserInformation()
                {
                    Id = "12345",
                    Name = "user1",
                    Email = "email",
                    Picture = "picture",
                }
            };
            SaveEntities(authenticatedUser);

            var sut = new UserMapper(() => Session);
            AuthenticatedUser actual = sut.MapUser(authenticatedClient);

            actual.ShouldEqual(authenticatedUser);

            int count = Session.QueryOver<AuthenticatedUser>()
                .RowCount();

            Assert.That(count, Is.EqualTo(1));
        }
Ejemplo n.º 2
0
        public void NewUserAuthenticatingShouldCreateNewUser()
        {
            var authenticatedUser = new AuthenticatedUser(Guid.NewGuid(), "user1", "Email1", "picture", new List<AuthenticationProvider>()
            {
                new AuthenticationProvider(Guid.NewGuid(), "Facebook", "12345"),
            });

            var authenticatedClient = new AuthenticatedClient("Facebook")
            {
                UserInformation = new UserInformation()
                {
                    Id = "12345",
                    Name = "user1",
                    Email = "email",
                    Picture = "picture",
                }
            };

            OpenTransaction();
            var sut = new UserMapper(() => Session);
            AuthenticatedUser actual = sut.MapUser(authenticatedClient);
            CommitTransaction();

            actual.ShouldEqual(authenticatedUser);

            int count = Session.QueryOver<AuthenticatedUser>()
                .RowCount();

            Assert.That(count, Is.EqualTo(1));

            AuthenticatedUser userInDb = Session.QueryOver<AuthenticatedUser>()
                .Where(x => x.UserName == authenticatedUser.UserName)
                .SingleOrDefault();

            userInDb.ShouldEqual(authenticatedUser);

        }