Ejemplo n.º 1
0
        public void PostNotEqualsComment()
        {
            var User = new UserListModel()
            {
                Id   = 4,
                Name = "Anton"
            };

            var Team = new TeamDetailModel()
            {
                Id      = 2,
                Leader  = User.Id,
                Members = new Collection <UserListModel>(),
                Name    = "Team1"
            };
            var CommentAuthor = new UserListModel()
            {
                Id   = 1,
                Name = "Igor",
            };

            var Post = new PostModel()
            {
                Id         = 4,
                Author     = User.Id,
                AuthorName = User.Name,
                Comments   = new Collection <CommentModel>(),
                Date       = new DateTime(2019, 4, 1),
                Team       = Team.Id,
                Text       = "Toto je testovaci prispevok",
                Title      = "Titulok"
            };

            var Comment = new CommentModel()
            {
                Author     = CommentAuthor.Id,
                AuthorName = CommentAuthor.Name,
                Date       = new DateTime(2019, 1, 4),
                Id         = 1,
                Text       = "Testovaci koment"
            };

            var TeamListModel = new TeamListModel()
            {
                Id   = Team.Id,
                Name = Team.Name
            };
            var UserListModel = new UserListModel()
            {
                Id   = User.Id,
                Name = User.Name
            };
            var CommentAuthorListModel = new UserListModel()
            {
                Id   = CommentAuthor.Id,
                Name = CommentAuthor.Name
            };

            Team.Members.Add(User);
            Team.Members.Add(CommentAuthor);
            Post.Comments.Add(Comment);

            Assert.False(Comment.Equals(Post));
            Assert.False(Post.Equals(Comment));
        }
Ejemplo n.º 2
0
        public void UserProfileModel()
        {
            var userMapper = new UserMapper();

            Assert.Null(userMapper.EntityToProfileModel(null));
            var UserEntity = new UserEntity()
            {
                Id       = 12,
                Comments = new Collection <CommentEntity>(),
                Name     = "Milos Hlava",
                Email    = "*****@*****.**",
                Password = "******",
                Posts    = new Collection <PostEntity>()
            };

            var Comment1 = new CommentEntity()
            {
                Author     = 12,
                AuthorName = UserEntity.Name,
                Date       = new DateTime(2019, 1, 4),
                Id         = 1,
                Text       = "Testovaci koment"
            };
            var Comment2 = new CommentEntity()
            {
                Author     = 12,
                AuthorName = UserEntity.Name,
                Date       = new DateTime(2019, 5, 4),
                Id         = 2,
                Text       = "Testovaci koment cislo 2"
            };

            var CommentModel = new CommentModel()
            {
                Author     = 12,
                AuthorName = "Milos Hlava",
                Date       = new DateTime(2019, 5, 4),
                Id         = 2,
                Text       = "Testovaci koment cislo 2"
            };
            var CommentModel1 = new CommentModel()
            {
                Author     = 12,
                AuthorName = "Milos Hlava",
                Date       = new DateTime(2019, 1, 4),
                Id         = 1,
                Text       = "Testovaci koment"
            };

            var PostEntity = new PostEntity()
            {
                Id         = 6,
                Author     = 12,
                AuthorName = "Milos Hlava",
                Comments   = new Collection <CommentEntity>(),
                Date       = new DateTime(2019, 5, 4),
                Team       = 2,
                Text       = "Post",
                Title      = "Titulok"
            };

            PostEntity.Comments.Add(Comment1);
            PostEntity.Comments.Add(Comment2);

            var PostModel = new PostModel()
            {
                Id         = 6,
                Author     = 12,
                AuthorName = "Milos Hlava",
                Comments   = new Collection <CommentModel>(),
                Date       = new DateTime(2019, 5, 4),
                Team       = 2,
                Text       = "Post",
                Title      = "Titulok"
            };

            PostModel.Comments.Add(CommentModel1);
            PostModel.Comments.Add(CommentModel);

            UserEntity.Comments.Add(Comment1);
            UserEntity.Comments.Add(Comment2);
            UserEntity.Posts.Add(PostEntity);

            var UserProfile = new UserProfileModel()
            {
                Id          = 12,
                Name        = "Milos Hlava",
                Email       = "*****@*****.**",
                LastComment = CommentModel,
                LastPost    = PostModel
            };

            Assert.Equal(UserProfile, userMapper.EntityToProfileModel(UserEntity));
            Assert.True(CommentModel.Equals(userMapper.EntityToProfileModel(UserEntity).LastComment));
            Assert.True(PostModel.Equals(userMapper.EntityToProfileModel(UserEntity).LastPost));
        }
Ejemplo n.º 3
0
        public void PostEquals()
        {
            var User = new UserListModel()
            {
                Id   = 4,
                Name = "Anton"
            };

            var Team = new TeamDetailModel()
            {
                Id      = 2,
                Leader  = User.Id,
                Members = new Collection <UserListModel>(),
                Name    = "Team1"
            };
            var CommentAuthor = new UserListModel()
            {
                Id   = 1,
                Name = "Igor",
            };

            var Post = new PostModel()
            {
                Id         = 4,
                Author     = User.Id,
                AuthorName = User.Name,
                Comments   = new Collection <CommentModel>(),
                Date       = new DateTime(2019, 4, 1),
                Team       = Team.Id,
                Text       = "Toto je testovaci prispevok",
                Title      = "Titulok"
            };

            var Comment1 = new CommentModel()
            {
                Author     = CommentAuthor.Id,
                AuthorName = CommentAuthor.Name,
                Date       = new DateTime(2019, 1, 4),
                Id         = 1,
                Text       = "Testovaci koment"
            };
            var Comment2 = new CommentModel()
            {
                Author     = CommentAuthor.Id,
                AuthorName = CommentAuthor.Name,
                Date       = new DateTime(2019, 1, 4),
                Id         = 1,
                Text       = "Testovaci koment cislo 2"
            };

            Team.Members.Add(User);
            Team.Members.Add(CommentAuthor);
            Post.Comments.Add(Comment1);
            Post.Comments.Add(Comment2);

            var TheSameUser = new UserListModel()
            {
                Id   = 4,
                Name = "Anton"
            };

            var TheSameTeam = new TeamDetailModel()
            {
                Id      = 2,
                Leader  = TheSameUser.Id,
                Members = new Collection <UserListModel>(),
                Name    = "Team1"
            };
            var TheSameCommentAuthor = new UserListModel()
            {
                Id   = 1,
                Name = "Igor",
            };

            var TheSamePost = new PostModel()
            {
                Id         = 4,
                Author     = TheSameUser.Id,
                AuthorName = TheSameUser.Name,
                Comments   = new Collection <CommentModel>(),
                Date       = new DateTime(2019, 4, 1),
                Team       = TheSameTeam.Id,
                Text       = "Toto je testovaci prispevok",
                Title      = "Titulok"
            };

            var TheSameComment1 = new CommentModel()
            {
                Author     = TheSameCommentAuthor.Id,
                AuthorName = TheSameCommentAuthor.Name,
                Date       = new DateTime(2019, 1, 4),
                Id         = 1,
                Text       = "Testovaci koment"
            };
            var TheSameComment2 = new CommentModel()
            {
                Author     = TheSameCommentAuthor.Id,
                AuthorName = TheSameCommentAuthor.Name,
                Date       = new DateTime(2019, 1, 4),
                Id         = 1,
                Text       = "Testovaci koment cislo 2"
            };

            TheSameTeam.Members.Add(TheSameUser);
            TheSameTeam.Members.Add(TheSameCommentAuthor);
            TheSamePost.Comments.Add(TheSameComment1);
            TheSamePost.Comments.Add(TheSameComment2);

            Assert.True(Post.Equals(TheSamePost));
            Assert.Equal(Post.GetHashCode(), Post.GetHashCode());
        }