コード例 #1
0
ファイル: UserTest.cs プロジェクト: bagheera/getin
        public void UserShouldBeAbleToComputeSimilarityScoreWithAnotherUser()
        {
            LoginId loginId1 = new LoginId("*****@*****.**");
            string firstname1 = "firstName";
            string lastname1 = "lastName";
            Name name1 = new Name(firstname1, lastname1);

            Like[] likes1 = new Like[]
                               {
                                   new Like() {UserId = loginId1, Text = "Like1"},
                                   new Like() {UserId = loginId1, Text = "Like2"},
                                   new Like() {UserId = loginId1, Text = "Like3"},
                               };

            Dislike[] dlikes1 = new Dislike[]
                                   {
                                       new Dislike() {UserId = loginId1, Text = "Dislike1"},
                                       new Dislike() {UserId = loginId1, Text = "Dislike2"},
                                       new Dislike() {UserId = loginId1, Text = "Dislike3"},
                                   };

            User currentUser = new User(loginId1, name1)
            {
                Likes = new HashedSet<Like>(likes1),
                Dislikes = new HashedSet<Dislike>(dlikes1),
            };

            LoginId loginId2 = new LoginId("*****@*****.**");
            Like[] likes2 = new Like[]
                               {
                                   new Like() {UserId = loginId2, Text = "Like1"},
                                   new Like() {UserId = loginId2, Text = "Like2"},
                                   new Like() {UserId = loginId2, Text = "Like4"},
                               };
            Dislike[] dlikes2 = new Dislike[]
                                   {
                                       new Dislike() {UserId = loginId2, Text = "Dislike1"},
                                       new Dislike() {UserId = loginId2, Text = "Dislike4"},
                                       new Dislike() {UserId = loginId2, Text = "Dislike5"},
                                   };

            User anotherUser = new User(loginId2, new Name("anotherFirstName", "anotherLastName"))
            {
                Likes = new HashedSet<Like>(likes2),
                Dislikes = new HashedSet<Dislike>(dlikes2),
            };

            Assert.AreEqual(2.7d, currentUser.SimilarityScore(anotherUser));
        }
コード例 #2
0
ファイル: UserTest.cs プロジェクト: bagheera/getin
        public void TwoLikessAreSameIfTextInLikesAreEqualAndIsNotDependantOnUserId()
        {
            Like like1 = new Like(){Text="Like1"};
            Like like2 = new Like(){Text="Like1"};

            Assert.True(like1.Equals(like2));
        }
コード例 #3
0
ファイル: UserTest.cs プロジェクト: bagheera/getin
        public void ShouldBeAbleToSetUserProperties()
        {
            LoginId loginid = new LoginId("*****@*****.**");
            string firstname = "firstName";
            string lastname = "lastName";
            Name name = new Name(firstname, lastname);

            Like[] likes = new Like[]
                               {
                                   new Like() {UserId = loginid, Text = "Like1"},
                                   new Like() {UserId = loginid, Text = "Like2"},
                                   new Like() {UserId = loginid, Text = "Like3"},
                               };

            Dislike[] dlikes = new Dislike[]
                               {
                                   new Dislike() {UserId = loginid, Text = "Dislike1"},
                                   new Dislike() {UserId = loginid, Text = "Dislike2"},
                                   new Dislike() {UserId = loginid, Text = "Dislike3"},
                               };

            Image image = new Bitmap(1, 1);

            User user = new User(loginid, name)
                            {
                                DateOfBirth = new GetInDate(DateTime.Today.AddYears(-25)),
                                Location = new Location { City = "Banglore" },
                                Gender = new Gender(),
                                Likes = new HashedSet<Like>(likes),
                                Dislikes = new HashedSet<Dislike>(dlikes),
                                Picture = new Photo { Bytes = new byte[] { 1, 2, 3, 4, 5 } },
                                Profile = new Profile("Big Profile")
                            };
        }
コード例 #4
0
ファイル: UserTest.cs プロジェクト: bagheera/getin
        public void ShouldBeAbleToRegisterUser()
        {
            LoginId loginid = new LoginId("*****@*****.**");
            string firstname = "firstName";
            string lastname = "lastName";
            Name name = new Name(firstname, lastname);

            Image image = new Bitmap(1, 1);

            Like[] likes = new Like[]
                               {
                                   new Like() {UserId = loginid, Text = "Like1"},
                                   new Like() {UserId = loginid, Text = "Like2"},
                                   new Like() {UserId = loginid, Text = "Like3"},
                               };

            Dislike[] dlikes = new Dislike[]
                               {
                                   new Dislike() {UserId = loginid, Text = "Dislike1"},
                                   new Dislike() {UserId = loginid, Text = "Dislike2"},
                                   new Dislike() {UserId = loginid, Text = "Dislike3"},
                               };

            User user = new User(loginid, name)
                            {
                                DateOfBirth = new GetInDate(DateTime.Today.AddYears(-25)),
                                Location = new Location { City = "Banglore" },
                                Gender = new Gender(),
                                Likes = new HashedSet<Like>(likes),
                                Dislikes = new HashedSet<Dislike>(dlikes),
                                Picture = new Photo { Bytes = new byte[] { 1, 2, 3, 4, 5 } },
                                Profile = new Profile("Big Profile")
                            };

            var repositoryMock = new Moq.Mock<IUserRepository>();
            repositoryMock.Setup(p => p.LookupUsers(It.IsAny<User>())).Returns(new List<User>());
            repositoryMock.Setup(p => p.Save(user));

            user.Repository = repositoryMock.Object;

            user.Register();
            repositoryMock.VerifyAll();
        }
コード例 #5
0
ファイル: UserTest.cs プロジェクト: bagheera/getin
        public void ShouldBeAbleToRegisterUser()
        {
            LoginId loginid = new LoginId("*****@*****.**");
            string firstname = "firstName";
            string lastname = "lastName";
            Name name = new Name(firstname, lastname);

            Like[] likes = new Like[]
                               {
                                   new Like() {UserId = loginid, Text = "Like1"},
                                   new Like() {UserId = loginid, Text = "Like2"},
                                   new Like() {UserId = loginid, Text = "Like3"},
                               };

            Dislike[] dlikes = new Dislike[]
                                   {
                                       new Dislike() {UserId = loginid, Text = "Dislike1"},
                                       new Dislike() {UserId = loginid, Text = "Dislike2"},
                                       new Dislike() {UserId = loginid, Text = "Dislike3"},
                                   };

            Image image = new Bitmap(1, 1);

            IUserRepository repository = new UserRepository(session);
            User user = new User(loginid, name)
                            {
                                DateOfBirth = new GetInDate(DateTime.Today.AddYears(-25)),
                                Location = new Location { City = "Banglore" },
                                Gender = new Gender(),
                                Likes = new HashedSet<Like>(likes),
                                Dislikes = new HashedSet<Dislike>(dlikes),
                                Picture = new Photo { Bytes = new byte[] { 1, 2, 3, 4, 5 } },
                                Profile = new Profile("Big Profile"),
                                Repository = repository
                            };
            repository.Save(user);

            session.Flush();
            session.Evict(user);

            User savedUser = repository.LookupUsers(user)[0];

            Assert.AreEqual(savedUser.LoginId, user.LoginId);
            Assert.AreEqual(savedUser.Location.City, user.Location.City);
            Assert.AreEqual(savedUser.Location.Country, user.Location.Country);
            Assert.AreEqual(savedUser.DateOfBirth.Value, user.DateOfBirth.Value);
            Assert.AreEqual(savedUser.Picture.Bytes.Length, user.Picture.Bytes.Length);
            for (int i = 0; i < savedUser.Picture.Bytes.Length; i++)
                Assert.AreEqual(savedUser.Picture.Bytes[i], user.Picture.Bytes[i]);

            Assert.AreEqual(savedUser.Likes.Count, user.Likes.Count);
            var arraylikes1 = savedUser.Likes.ToArray();
            var arraylikes2 = user.Likes.ToArray();
            for (int i = 0; i < arraylikes1.Length; i++)
                Assert.AreEqual(arraylikes1[i].Text, arraylikes2[i].Text);

            Assert.AreEqual(savedUser.Dislikes.Count, user.Dislikes.Count);
            var arraydislikes1 = savedUser.Dislikes.ToArray();
            var arraydislikes2 = user.Dislikes.ToArray();
            for (int i = 0; i < arraydislikes1.Length; i++)
                Assert.AreEqual(arraydislikes1[i].Text, arraydislikes2[i].Text);

            Assert.AreEqual(savedUser.Name.FirstName, user.Name.FirstName);
            Assert.AreEqual(savedUser.Name.LastName, user.Name.LastName);

            Assert.AreEqual(savedUser.Gender.Code, user.Gender.Code);
        }
コード例 #6
0
ファイル: User.cs プロジェクト: bagheera/getin
 public virtual bool Equals(Like other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return Equals(other.Text, Text);
 }