private Post ( RetrieveDataClass value ) : void | ||
value | RetrieveDataClass | |
Результат | void |
public async Task Post_PostIsNull_ReturnNotFound() { _unitOfWork .Setup(x => x.PostRepository.GetById(It.IsAny <int>())) .ReturnsAsync((Post)null); var result = await _controller.Post(It.IsAny <int>()); result .Should() .BeOfType <NotFoundResult>(); }
public void Put() { BlogController controller = new BlogController(); var b1 = CreateNewBlog(); //crio um cara para existir um e pegar o id controller.Post(b1); var id1 = b1._Id; var b2 = CreateNewBlog(); var owner = "zzzzzzzz" + DateTime.Now.ToLongTimeString(); b2.OwnerName = owner; b2.Description = "zzzzzzzz" + DateTime.Now.ToLongTimeString(); var count = controller.Put(id1.ToString(), b2); Assert.AreEqual(count, 1); var b3 = controller.Get(id1.ToString()); Assert.AreEqual(b1._Id, b2._Id); Assert.AreNotEqual(b1.OwnerName, b3.OwnerName); }
public void Post() { BlogController controller = new BlogController(); var blog = CreateNewBlog(); controller.Post(blog); }
public void T1_CadastrarBlogComUmUsuario() { var ownerName = "Teste1 VariasPostagens"; var login = $"emanuel1_{DateTime.Now.ToString("hhMMss")}"; var password = "******"; var description = "Blog teste para validação do projeto"; BlogController blogCtr = new BlogController(); BlogModel blog = new BlogModel { OwnerName = ownerName, Login = login, Password = password, Description = description, }; var idBlog = blogCtr.Post(blog); // V A L I D A Ç Ã O /////////////////////// var leituraBlog = blogCtr.Get(idBlog); Assert.IsNotNull(leituraBlog); Assert.AreEqual(ownerName, leituraBlog.OwnerName); Assert.AreEqual(login, leituraBlog.Login); Assert.AreEqual(password, leituraBlog.Password); Assert.AreEqual(description, leituraBlog.Description); }
public void T3_SecoesAninhadas() { var ownerName = "Teste3 VariasPostagens"; var login = $"emanuel3_{DateTime.Now.ToString("hhMMss")}"; var password = "******"; var description = "T3 Blog teste para validação do projeto"; BlogController blogCtr = new BlogController(); var idBlog = blogCtr.Post( new BlogModel { OwnerName = ownerName, Login = login, Password = password, Description = description }); PostController postCtr = new PostController(); var postagem = new PostModel { IdBlog = idBlog, Datahora = DateTime.Now, Titulo = $"T3_Post[{DateTime.Now.ToLongTimeString()}]" }; // 4 filhas com 3 netas em cada uma for (int i = 0; i < 4; i++) { postagem.addSecao(new SecaoModel { SubTitulo = $"T3_SecaoFilha[{i}]", Conteudo = "Teste3 com algum texto qualquer" }); for (int j = 0; j < 3; j++) { postagem.Secoes[i].addSecao(new SecaoModel { SubTitulo = $"T3_SecaoNeta[{i},{j}]", Conteudo = "Teste3 com algum texto qualquer" }); } } var idPost = postCtr.Post(idBlog, postagem); // V A L I D A Ç Ã O /////////////////////// // várias leituras diferentes var secao_0_1 = postCtr.Get(idBlog, idPost).Secoes[0].Secoes[1]; var secao_2_2 = postCtr.Get(idBlog, idPost).Secoes[2].Secoes[2]; var secao_3_0 = postCtr.Get(idBlog, idPost).Secoes[3].Secoes[0]; // Conferindo os títulos gerados Assert.IsNotNull(secao_0_1); Assert.AreEqual("T3_SecaoNeta[0,1]", secao_0_1.SubTitulo); Assert.AreEqual("T3_SecaoNeta[2,2]", secao_2_2.SubTitulo); Assert.AreEqual("T3_SecaoNeta[3,0]", secao_3_0.SubTitulo); }
/// <summary> /// Busca ou cria um blog. /// </summary> /// <returns></returns> private BlogModel GetOneBlog() { BlogController ctr = new BlogController(); var blog = ctr.Get().FirstOrDefault(); if (blog == null) { blog = Tests.Controllers.BlogControllerTest.CreateNewBlog(); ctr.Post(blog); } return(blog); }
public async void PostTest() { BlogArticle blogArticle = new BlogArticle() { bCreateTime = DateTime.Now, bUpdateTime = DateTime.Now, btitle = "xuint :test controller addEntity", }; var res = await blogController.Post(blogArticle); Assert.True(res.success); var data = res.response; Assert.NotNull(data); }
public void TestPost() { this.Setup(); var context2 = CreateContext(nameDB); Post post = new Post { Title = "PostNew", Body = "BodyNew", Date = DateTime.Now.Date, AuthorId = 1 }; var controller = new BlogController(context2); var result = controller.Post(post).Result; Assert.AreEqual(6, result.Value.Count()); }
public void Delete() { BlogController controller = new BlogController(); var blog = CreateNewBlog(); //blog.Id = "999"; controller.Post(blog); Assert.IsNotNull(blog._Id); var id1 = blog._Id; controller.Remove(id1.ToString()); var b2 = controller.Get(id1.ToString()); Assert.IsNull(b2); }
public void T2_VariasPostagens() { // REQ4 var ownerName = "Teste2 VariasPostagens"; var login = $"emanuel2_{DateTime.Now.ToString("hhMMss")}"; var password = "******"; var description = "T2 Blog teste para validação do projeto"; BlogController blogCtr = new BlogController(); var idBlog = blogCtr.Post( new BlogModel { OwnerName = ownerName, Login = login, Password = password, Description = description }); PostController postCtr = new PostController(); for (int i = 0; i < 100; i++) { postCtr.Post(idBlog, new PostModel { IdBlog = idBlog, Datahora = DateTime.Now, Titulo = "T3" + DateTime.Now.ToLongTimeString() }); } // V A L I D A Ç Ã O /////////////////////// var listaPosts = postCtr.Get(idBlog); Assert.IsNotNull(listaPosts); Assert.AreEqual(100, listaPosts.Count); Assert.AreEqual(idBlog, listaPosts[99].IdBlog); }
public void T4_Login() { var ownerName = "Teste4 VariasPostagens"; var login = $"emanuel4{DateTime.Now.ToString("hhMMss")}"; var password = "******"; var description = "T4 Blog teste para validação do projeto"; BlogController blogCtr = new BlogController(); var idBlog = blogCtr.Post(new BlogModel { OwnerName = ownerName, Login = login, Password = password, Description = description }); // V A L I D A Ç Ã O /////////////////////// var tokenInvalido = blogCtr.Login(idBlog, login, "senhaInvalida"); var token = blogCtr.Login(idBlog, login, "1234"); Assert.AreEqual("", tokenInvalido); Assert.IsTrue(token.Length == 24); }