public void CanZip() { var actual = FactoryGirl.Build <Person>(); Validate.Begin() .ComparesTo <Person>(actual.ToJson().Zip().Unzip().FromJson <Person>(), actual, AssertionExtensions.Matches); }
public void Equal() { var angelina = FactoryGirl.Build <Person>(); var angelinaClone = FactoryGirl.Build <Person>(); angelina.ReflectionEquals(angelinaClone).Should().BeTrue(); }
private static void Not(Action <Person, Person> initializer) { var first = FactoryGirl.Build <Person>(); var notEqual = FactoryGirl.Build <Person>(); initializer(first, FactoryGirl.Build <Person>()); first.ReflectionEquals(notEqual).Should().BeFalse(); }
public async Task SavePost() { var blogPost = FactoryGirl.Build <BlogPost>(); validator.Setup(x => x.ValidateBlogPost(blogPost)); repository.Setup(x => x.Save(blogPost)) .ReturnsAsync(blogPost); await service.PostBlog(blogPost); }
public async Task GetAllPosts() { var blogPosts = new[] { FactoryGirl.Build <BlogPost>(), FactoryGirl.Build <BlogPost>() }; repository.Setup(x => x.GetAllPosts()).ReturnsAsync(blogPosts); var posts = await service.GetAllPosts(); Validate.Begin() .IsNotNull(posts, "posts").Check() .HasExactly(posts, 2, "has 2 poss") .Check(); }
public void BlogPost() { var post = FactoryGirl.Build <BlogPost>(); var json = post.ToJson(); var fromJson = json.FromJson <BlogPost>(); Validate.Begin() .IsNotNull(fromJson, "fromJson").Check() .IsEqual(post.Author, fromJson.Author, nameof(Api.Models.BlogPost.Author)) .IsEqual(post.Article, fromJson.Article, nameof(Api.Models.BlogPost.Article)) .IsEqual(post.PostedDate, fromJson.PostedDate, nameof(Api.Models.BlogPost.PostedDate)) .Check(); }
public async Task GetAllPosts() { var results = new[] { FactoryGirl.Build <BlogPost>(), FactoryGirl.Build <BlogPost>() }; blogService.Setup(x => x.GetAllPosts()) .ReturnsAsync(results); var response = await handler.GetAllBlogPosts(new APIGatewayProxyRequest()); Validate.Begin() .IsNotNull(response, "response").Check(); var items = response.Body.FromJson <IEnumerable <BlogPost> >(); Validate.Begin() .HasExactly(items, 2, "has 2 BlogPosts") .Check(); }
public async Task PostBLogPost() { var blogPost = FactoryGirl.Build <BlogPost>(); blogService.Setup(x => x.PostBlog(It.Is <BlogPost>(x => x.Matches(blogPost)))) .ReturnsAsync(blogPost); var request = new APIGatewayProxyRequest { Body = blogPost.ToJson() }; var response = await handler.PostBlog(request); Validate.Begin() .IsNotNull(response, "response").Check() .IsNotEmpty(response.Body, nameof(response.Body)).Check() .IsNotNull(response.Body.FromJson <BlogPost>(), "blogPost") .Check(); }
public void BadPostedDate() { Invalid(FactoryGirl.Build <BlogPost>(x => x.PostedDate = string.Empty)); Invalid(FactoryGirl.Build <BlogPost>(x => x.PostedDate = null)); }
public void NoArticle() { Invalid(FactoryGirl.Build <BlogPost>(x => x.Article = string.Empty)); Invalid(FactoryGirl.Build <BlogPost>(x => x.Article = null)); }
public void NoAuthor() { Invalid(FactoryGirl.Build <BlogPost>(x => x.Author = string.Empty)); Invalid(FactoryGirl.Build <BlogPost>(x => x.Author = null)); }
public void ValidBlogPost() { validator.ValidateBlogPost(FactoryGirl.Build <BlogPost>()); }