Exemple #1
0
        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();
        }
Exemple #3
0
 public void Run()
 {
     FactoryGirl.Define(() => new BlogPost
     {
         Author     = "Albert Einstein",
         Article    = "E = mc2",
         PostedDate = new DateTime(1905, 11, 21).ToString("yyyy-MM-dd")
     });
 }
        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();
        }
Exemple #5
0
        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 void Run()
 {
     FactoryGirl.Define(() => new Person
     {
         FirstName            = "Angelina",
         LastName             = "Jolie",
         Age                  = 25,
         SocialSecurityNumber = 12345
     });
 }
Exemple #7
0
        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();
        }
Exemple #8
0
        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();
        }
Exemple #9
0
        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();
        }
Exemple #10
0
        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();
        }
Exemple #11
0
 public void Dispose()
 {
     FactoryGirl.Clear();
 }
Exemple #12
0
 public void Run()
 {
     FactoryGirl.Clear();
 }
 public void AfterContextCleanup()
 {
     FactoryGirl.ClearFactoryDefinitions();
 }
 public void ValidBlogPost()
 {
     validator.ValidateBlogPost(FactoryGirl.Build <BlogPost>());
 }
Exemple #15
0
 public static string UniqueName(this object item, string prefix = "Name")
 {
     return($"{prefix} {FactoryGirl.UniqueId()}");
 }
Exemple #16
0
 public static int NextId(this object item)
 {
     return(FactoryGirl.UniqueId());
 }
 public void NoAuthor()
 {
     Invalid(FactoryGirl.Build <BlogPost>(x => x.Author = string.Empty));
     Invalid(FactoryGirl.Build <BlogPost>(x => x.Author = null));
 }
 public void NoArticle()
 {
     Invalid(FactoryGirl.Build <BlogPost>(x => x.Article = string.Empty));
     Invalid(FactoryGirl.Build <BlogPost>(x => x.Article = null));
 }
 public void BadPostedDate()
 {
     Invalid(FactoryGirl.Build <BlogPost>(x => x.PostedDate = string.Empty));
     Invalid(FactoryGirl.Build <BlogPost>(x => x.PostedDate = null));
 }