Ejemplo n.º 1
0
        public void creates_user_when_first_posting()
        {
            var socialNetwork = new SocialNetwork();
            var userName      = "******";
            var message       = "Ola Mundo";

            socialNetwork.Compute($"{userName} -> {message}");

            Assert.NotEmpty(socialNetwork._socialEngine._registeredUsers);
            Assert.Equal(socialNetwork._socialEngine._registeredUsers.FirstOrDefault().Name, userName);
        }
Ejemplo n.º 2
0
        public void post_new_message_to_existing_user_timeline()
        {
            var socialNetwork = new SocialNetwork();
            var userName      = "******";
            var message       = "Ola Mundo";
            var user          = new User(userName);

            user.Account.AddPost(userName, message);
            socialNetwork._socialEngine._registeredUsers.Add(user);
            var newMessage = "Hello World";

            socialNetwork.Compute($"{userName} -> {newMessage}");

            Assert.NotEmpty(socialNetwork._socialEngine._registeredUsers);
            Assert.NotNull(socialNetwork._socialEngine._registeredUsers.FirstOrDefault(u => u.Name.Equals(userName)));
            Assert.NotNull(socialNetwork._socialEngine._registeredUsers.First(u => u.Name.Equals(userName)).Account.Timeline.FirstOrDefault(p => p.Item3.Equals(newMessage)));
        }
Ejemplo n.º 3
0
        public void follow_user()
        {
            var socialNetwork = new SocialNetwork();
            var userName01    = "Andre";
            var userName02    = "Graziano";
            var message01     = "Ola Mundo";
            var message02     = "Ciao Mondo";
            var user01        = new User(userName01);
            var user02        = new User(userName02);

            user01.Account.AddPost(userName01, message01);
            user02.Account.AddPost(userName02, message02);
            socialNetwork._socialEngine._registeredUsers.Add(user01);
            socialNetwork._socialEngine._registeredUsers.Add(user02);

            socialNetwork.Compute($"{userName01} follows {userName02}");

            Assert.NotEmpty(socialNetwork._socialEngine._registeredUsers.FirstOrDefault(u => u.Name.Equals(userName01)).Account.FollowedUsers);
            Assert.NotNull(socialNetwork._socialEngine._registeredUsers.FirstOrDefault(u => u.Name.Equals(userName01)).Account.FollowedUsers.FirstOrDefault(u => u.Name.Equals(userName02)));
        }