SimilarityScore() public méthode

public SimilarityScore ( User user ) : double
user User
Résultat double
Exemple #1
0
        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));
        }