Пример #1
0
        public void TestValidationPublicationBadTitle()
        {
            var badPublication = PublicationBuilder.New().WithTitle("  ").Build();

            var resultValidation = new PublicationValidator().Validate(badPublication);

            Assert.False(resultValidation.IsValid);
        }
Пример #2
0
        public void TestValidationPublication()
        {
            var okPublication = PublicationBuilder.New().Build();

            var resultValidation = new PublicationValidator().Validate(okPublication);

            Assert.True(resultValidation.IsValid);
        }
Пример #3
0
        public void TestValidationPublicationNotExistOnDB()
        {
            var badPublication = PublicationBuilder.New().Build();

            var resultValidation = new PublicationExistValidator().Validate(badPublication.Id);

            Assert.False(resultValidation.IsValid);
        }
Пример #4
0
        public void GetByIdReturnsOk()
        {
            var publication = PublicationBuilder.New().Build();

            creator.CreateNewRegister(publication);

            var result = controller.Get(publication.Id);

            Assert.IsType <OkObjectResult>(result.Result);
        }
Пример #5
0
        public void PutReturnsOk()
        {
            var publication = PublicationBuilder.New().Build();

            new CreatePublication().CreateNewRegister(publication);

            var result = controller.Put(publication.Id, "Nome Put", publication.Content, publication.Topic.Id);

            Assert.IsType <OkObjectResult>(result.Result);
        }
Пример #6
0
        public void PutReturnsBadRequest_PublicationNotValid()
        {
            var publication = PublicationBuilder.New().Build();

            creator.CreateNewRegister(publication);

            var result = controller.Put(publication.Id, "", "Conteudo", publication.Topic.Id);

            Assert.IsType <BadRequestObjectResult>(result.Result);
        }
Пример #7
0
        public void TestGetById()
        {
            Publication publication = PublicationBuilder.New().Build();

            // Produção através dos métodos
            new CreatePublication().CreateNewRegister(publication);
            var idGet = new GetPublication().GetRegisterById(publication.Id);

            Assert.IsNotNull(idGet);
        }
Пример #8
0
        public void TestValidationPublicationBadUser()
        {
            var badUser = UserBuilder.New().WithEmail("emailemail.com").Build();

            var badPublication = PublicationBuilder.New().WithAutor(badUser).Build();

            var resultValidation2 = new PublicationValidator().Validate(badPublication);

            Assert.False(resultValidation2.IsValid);
        }
Пример #9
0
        public void TestValidationPublicationExistOnDB()
        {
            var okPublication = PublicationBuilder.New().Build();

            new PublicationRepository().Create(okPublication);

            var resultValidation = new PublicationExistValidator().Validate(okPublication.Id);

            Assert.True(resultValidation.IsValid);
        }
Пример #10
0
        public void TestEntityDelete()
        {
            var pub = PublicationBuilder.New().Build();

            var mockTeste = new Mock <IDeleteDB <Publication> >();

            var publicationRepository = new PublicationRepository(mockTeste.Object);

            publicationRepository.Delete(pub);

            mockTeste.Verify(x => x.DeleteRegister(It.IsAny <Publication>()));
        }
Пример #11
0
        public void TestCreateWithId()
        {
            Publication publication = PublicationBuilder.New().Build();

            Assert.True(publication.Id != null && publication.Id != Guid.Empty);
            Assert.True(publication.Autor.Id != Guid.Empty && publication.Autor.Id != null);
            Assert.True(publication.Title == "TestPost");
            Assert.True(publication.Content == "Test Post Builder");
            Assert.True(publication.DateCreated.Date == DateTime.Today);
            Assert.True(publication.Comments != null && publication.Comments.Count == 0);
            Assert.True(publication.Topic.Id != Guid.Empty && publication.Topic.Id != null);
        }
Пример #12
0
        public void TestUpdate()
        {
            Publication publication = PublicationBuilder.New().Build();

            new CreatePublication().CreateNewRegister(publication);

            var publicationAlter = PublicationBuilder.New().WithId(publication.Id).WithTitle("Teste API").Build();

            new UpdatePublication().UpdateRegister(publicationAlter);

            Assert.IsTrue(publicationAlter.Title.ToString() != publication.Title.ToString());
            Assert.IsTrue(publicationAlter.Id.ToString() == publication.Id.ToString());
        }
Пример #13
0
        public void TestGetAll()
        {
            Publication publicationFirst  = PublicationBuilder.New().Build();
            Publication publicationSecond = PublicationBuilder.New().Build();
            Publication publicationThird  = PublicationBuilder.New().Build();

            // Produção através dos métodos
            new CreatePublication().CreateNewRegister(publicationFirst);
            new CreatePublication().CreateNewRegister(publicationSecond);
            new CreatePublication().CreateNewRegister(publicationThird);
            List <Publication> listPublications = new GetPublication().GetAllRegister();

            Assert.IsTrue(3 == listPublications.Count);
        }
Пример #14
0
        public void PostReturnsBadRequest_CommentInvalid()
        {
            var user = UserBuilder.New().Build();

            new CreateUser().CreateNewRegister(user);

            var publication = PublicationBuilder.New().Build();

            new CreatePublication().CreateNewRegister(publication);

            var result = controller.Post(user.Id, "", publication.Id);

            Assert.IsType <BadRequestObjectResult>(result.Result);
        }
Пример #15
0
        public void PostReturnsOk()
        {
            var user = UserBuilder.New().Build();

            new CreateUser().CreateNewRegister(user);

            var publication = PublicationBuilder.New().Build();

            new CreatePublication().CreateNewRegister(publication);

            var result = controller.Post(user.Id, "Conteudo", publication.Id);

            Assert.IsType <CreatedAtActionResult>(result.Result);
        }
Пример #16
0
    public static CommentBuilder New()
    {
        var user = UserBuilder.New().Build();

        new CreateUser().CreateNewRegister(user);

        var publication = PublicationBuilder.New().Build();

        new CreatePublication().CreateNewRegister(publication);

        return(new CommentBuilder()
        {
            Id = Guid.NewGuid(),
            Autor = user,
            Content = "TestContent",
            PublicationId = publication.Id
        });
    }