public async Task <bool> Testfor_ValidatePostId() { //Arrange bool res = false; try { //Assigning values for new post //Act mockservice.Setup(repo => repo.Create(_blogPost)).ReturnsAsync(_blogPost); var result = await _services.Create(_blogPost); if (result.PostId == _blogPost.PostId) { res = true; } //Assert //writing tset boolean output in text file, that is present in project directory File.AppendAllText("../../../output_boundary_revised.txt", "Testfor_ValidatePostId=" + res + "\n"); } catch (Exception ex) { throw (ex); } return(res); }
public void Test_Post_CreateBlogPost() { // Arrange var res = false; var blogPost = new BlogPost() { Title = "Post-Title", Abstract = "Post Abstract-1", Description = "Post Description -1" }; // Act mockservice.Setup(blogRepo => blogRepo.Create(blogPost)); var result = _services.Create(blogPost); if (result != null) { res = true; } // Assert //writing tset boolean output in text file, that is present in project directory File.AppendAllText("../../../../output_revised.txt", "Test_Post_CreateBlogPost=" + res.ToString() + "\n"); }
public async Task <bool> Testfor_ValidatePostId() { //Arrange bool res = false; string postid = "5ef312a0f05009584c12a93f"; try { //Assigning values for new post var blogPost = new BlogPost() { PostId = "5ef312a0f05009584c12a93f", Abstract = "Abstract of post", Title = "Post Title", Description = "Post Description goes here" }; //Act mockservice.Setup(repo => repo.Create(blogPost)).ReturnsAsync(blogPost); var result = await _services.Create(blogPost); if (result.PostId == postid) { res = true; } else { res = false; } //Assert //writing tset boolean output in text file, that is present in project directory File.AppendAllText("../../../../output_boundary_revised.txt", "Testfor_ValidatePostId=" + res + "\n"); } catch (Exception ex) { File.AppendAllText("../../../../output_boundary_revised.txt", "Testfor_ValidatePostId=" + res + "\n"); throw (ex); } return(res); }
public async Task Test_Post_CreateBlogPostAsync() { // Arrange var res = false; // Act mockservice.Setup(blogRepo => blogRepo.Create(_blogPost)).ReturnsAsync(_blogPost); var result = await _services.Create(_blogPost); if (result == _blogPost) { res = true; } // Assert //writing tset boolean output in text file, that is present in project directory File.AppendAllText("../../../output_revised.txt", "Test_Post_CreateBlogPost=" + res.ToString() + "\n"); }
public async Task CreateNewPost_Null_Failure() { // Arrange // Arrange var res = false; var blogPost = new BlogPost() { Title = "Post-Title", Abstract = "Post Abstract-1", Description = "Post Description -1" }; blogPost = null; //Act mockservice.Setup(blogRepo => blogRepo.Create(blogPost)); var result = await _services.Create(blogPost); if (result == null) { res = true; } //writing tset boolean output in text file, that is present in project directory File.AppendAllText("../../../../output_exception_revised.txt", "CreateNewPost_Null_Failure=" + res + "\n"); }