Beispiel #1
0
        public void CommentsNotEquals()
        {
            var Comment = new CommentModel()
            {
                Author     = 1,
                AuthorName = "Milos Hlava",
                Date       = new DateTime(2019, 1, 4),
                Id         = 1,
                Text       = "Testovaci koment"
            };

            var NotTheSameComment = new CommentModel()
            {
                Author     = 1,
                AuthorName = "Milos Hlava",
                Date       = new DateTime(2019, 1, 4),
                Id         = 1,
                Text       = "Testovaci koment je toto"
            };

            Assert.False(Comment.Equals(NotTheSameComment));
        }
Beispiel #2
0
        public void CommentsEquals()
        {
            var Comment = new CommentModel()
            {
                Author     = 1,
                AuthorName = "Milos Hlava",
                Date       = new DateTime(2019, 1, 4),
                Id         = 1,
                Text       = "Testovaci koment"
            };

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

            Assert.True(Comment.Equals(TheSameComment));
            Assert.Equal(Comment.GetHashCode(), Comment.GetHashCode());
        }
Beispiel #3
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));
        }
Beispiel #4
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));
        }