示例#1
0
        public void GetDetails_ShouldThrow_IfThemNotExist()
        {
            var themsRepoBuilder = new ThemsRepositoryBuilder();
            var themsRepo        = themsRepoBuilder
                                   .WithAll()
                                   .Build();

            var themCommentRepoBuilder = new ThemCommentsRepositoryBuilder();
            var themCommentsRepo       = themCommentRepoBuilder
                                         .WithAll()
                                         .Build();

            var usersRepoBuilder = new GoUserRepositoryBuilder();
            var usersRepo        = usersRepoBuilder
                                   .WithAll()
                                   .Build();

            var sut = new ThemService(themsRepo, usersRepo, themCommentsRepo, Mapper);

            var user = new GoUser {
                Id = "7"
            };

            var ex = Assert.Throws <ArgumentException>(() => sut.GetDetails("7", user));

            Assert.Equal("Theme not exist!", ex.Message);

            themsRepoBuilder.ThemsRepoMock.Verify();
        }
示例#2
0
        public void GetDetails_ShouldReturnCorrect_ThemDetailsViewModel()
        {
            var themsRepoBuilder = new ThemsRepositoryBuilder();
            var themsRepo        = themsRepoBuilder
                                   .WithAll()
                                   .Build();

            var themCommentRepoBuilder = new ThemCommentsRepositoryBuilder();
            var themCommentsRepo       = themCommentRepoBuilder
                                         .WithAll()
                                         .Build();

            var usersRepoBuilder = new GoUserRepositoryBuilder();
            var usersRepo        = usersRepoBuilder
                                   .WithAll()
                                   .Build();

            var sut = new ThemService(themsRepo, usersRepo, themCommentsRepo, Mapper);

            var user = new GoUser {
                Id = "7"
            };

            var actual = sut.GetDetails("1", user);

            var expected = new ThemDetailsViewModel
            {
                Id          = "1",
                Description = "Niki otiva na more",
                Date        = DateTime.Parse("07/02/2018"),
                AuthorId    = "7",
                Author      = "Slavqna ",
                Comments    = new List <ThemCommentViewModel>
                {
                    new ThemCommentViewModel
                    {
                        Id       = "6",
                        Content  = "Niki otiva na more",
                        ThemId   = "1",
                        Date     = DateTime.Parse("08/02/2018"),
                        AuthorId = "11",
                        Author   = "Koni "
                    },
                    new ThemCommentViewModel
                    {
                        Id       = "7",
                        Content  = "Nikiiiiiiiiiii",
                        ThemId   = "1",
                        Date     = DateTime.Parse("09/02/2018"),
                        AuthorId = "8",
                        Author   = "Niki "
                    },
                }
            };

            Assert.Equal(expected, actual, new ThemDetailsViewModelComparer());
            Assert.Equal(expected.Comments, actual.Comments, new ThemCommentViewModelComparer());

            themsRepoBuilder.ThemsRepoMock.Verify();
            themCommentRepoBuilder.ThemCommentsRepoMock.Verify();
            usersRepoBuilder.UsersRepoMock.Verify();
        }