Exemple #1
0
        public void ReturnTheProperValueInTheAuthorField()
        {
            String fieldValueDelegate(ContentItem c) => c.Author;

            string expected    = string.Empty.GetRandom();
            var    fileContent = new ContentItemFileBuilder()
                                 .UseRandomValues()
                                 .Author(expected)
                                 .Build();

            fileContent.ExecutePostPropertyTest(expected, fieldValueDelegate);
        }
Exemple #2
0
        public void ReturnTheProperValueInTheIdField()
        {
            Guid fieldValueDelegate(ContentItem c) => c.Id;

            var expected    = Guid.NewGuid();
            var fileContent = new ContentItemFileBuilder()
                              .UseRandomValues()
                              .Id(expected)
                              .Build();

            fileContent.ExecutePostPropertyTest(expected, fieldValueDelegate);
        }
Exemple #3
0
        public void ReturnAnEmptyStringInTheByLineFieldIfAuthorFieldIsEmpty()
        {
            String fieldValueDelegate(ContentItem c) => c.ByLine;

            String author      = string.Empty;
            String expected    = string.Empty;
            var    fileContent = new ContentItemFileBuilder()
                                 .UseRandomValues()
                                 .Author(expected)
                                 .Build();

            fileContent.ExecutePostPropertyTest(expected, fieldValueDelegate);
        }
Exemple #4
0
        public void ReturnTheProperValueInTheByLineField()
        {
            String fieldValueDelegate(ContentItem c) => c.ByLine;

            String author      = string.Empty.GetRandom();
            String expected    = $"by {author}";
            var    fileContent = new ContentItemFileBuilder()
                                 .UseRandomValues()
                                 .Author(author)
                                 .Build();

            fileContent.ExecutePostPropertyTest(expected, fieldValueDelegate);
        }
Exemple #5
0
        public void ReturnTheProperValueInTheLastModifiedDateFieldIfFullIso8601Format()
        {
            DateTime fieldValueDelegate(ContentItem c) => c.LastModificationDate.ToSecondPrecision();

            DateTime expected    = DateTime.Parse("1/1/1900").AddSeconds(Int32.MaxValue.GetRandom());
            var      fileContent = new ContentItemFileBuilder()
                                   .UseRandomValues()
                                   .LastModificationDate(expected)
                                   .LastModificationDateSerializationFormat("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffzzz")
                                   .Build();

            fileContent.ExecutePostPropertyTest(expected.ToSecondPrecision(), fieldValueDelegate);
        }
Exemple #6
0
        public void ReturnTheHtmlFormattedValueInTheContentField()
        {
            String fieldValueDelegate(ContentItem c) => c.Content.Trim();

            string content     = string.Empty.GetRandom();
            String expected    = $"<p>{content}</p>";
            var    fileContent = new ContentItemFileBuilder()
                                 .UseRandomValues()
                                 .Content(content)
                                 .Build();

            fileContent.ExecutePostPropertyTest(expected, fieldValueDelegate);
        }
Exemple #7
0
        public void ReturnTheCorrectValueInTheContentFieldEvenIfItContainsAHorizontalRule()
        {
            String fieldValueDelegate(ContentItem c) => c.Content.Trim();

            string field1   = string.Empty.GetRandom();
            string field2   = string.Empty.GetRandom();
            string content  = $"<h1>{field1}</h1>\n---\n<h2>{field2}</h2>";
            String expected = $"<h1>{field1}</h1>\n<hr />\n<h2>{field2}</h2>\n".Trim();

            var fileContent = new ContentItemFileBuilder()
                              .UseRandomValues()
                              .Content(content)
                              .Build();

            fileContent.ExecutePostPropertyTest(expected, fieldValueDelegate);
        }
Exemple #8
0
        public void ReturnTheCategoryFromASingleCategoryPost()
        {
            String fieldValueDelegate(ContentItem c) => c.CategoryIds.AsHash();

            List <String> categories = new List <String>()
            {
                String.Empty.GetRandom()
            };

            var fileContent = new ContentItemFileBuilder()
                              .UseRandomValues()
                              .Categories(categories)
                              .Build();

            var    sourceCategories = categories.AsCategoryEntities().ToArray();
            string expected         = sourceCategories.Select(c => c.Id).AsHash();

            fileContent.ExecutePostPropertyTest(expected, fieldValueDelegate, sourceCategories);
        }
Exemple #9
0
        public void ReturnTheCorrectNumberOfTags()
        {
            Int32 fieldValueDelegate(ContentItem c) => c.Tags?.Count() ?? 0;

            Int32         expected = 10.GetRandom(3);
            List <String> tags     = new List <string>();

            for (Int32 i = 0; i < expected; i++)
            {
                tags.Add(string.Empty.GetRandom());
            }

            var fileContent = new ContentItemFileBuilder()
                              .UseRandomValues()
                              .Tags(tags)
                              .Build();

            fileContent.ExecutePostPropertyTest(expected, fieldValueDelegate);
        }
Exemple #10
0
        public void ReturnTheTagFromAMultipleTagPost()
        {
            String fieldValueDelegate(ContentItem c) => c.Tags.AsHash();

            Int32         expectedCount = 10.GetRandom(3);
            List <String> tags          = new List <string>();

            for (Int32 i = 0; i < expectedCount; i++)
            {
                tags.Add(string.Empty.GetRandom());
            }

            var fileContent = new ContentItemFileBuilder()
                              .UseRandomValues()
                              .Tags(tags)
                              .Build();

            fileContent.ExecutePostPropertyTest(tags.AsHash(), fieldValueDelegate);
        }
Exemple #11
0
        public void ReturnTheCorrectNumberOfCategories()
        {
            Int32 fieldValueDelegate(ContentItem c) => c.CategoryIds?.Count() ?? 0;

            Int32 expectedCount = 10.GetRandom(3);
            var   categories    = new List <String>();

            for (Int32 i = 0; i < expectedCount; i++)
            {
                categories.Add(String.Empty.GetRandom());
            }

            var fileContent = new ContentItemFileBuilder()
                              .UseRandomValues()
                              .Categories(categories)
                              .Build();

            var sourceCategories = categories.AsCategoryEntities();

            fileContent.ExecutePostPropertyTest(expectedCount, fieldValueDelegate, sourceCategories);
        }
Exemple #12
0
        public void ReturnTheCategoriesFromAMultipleCategoryPost()
        {
            String fieldValueDelegate(ContentItem c) => c.CategoryIds.AsHash();

            Int32 expectedCount = 10.GetRandom(3);
            var   categories    = new List <String>();

            for (Int32 i = 0; i < expectedCount; i++)
            {
                categories.Add(String.Empty.GetRandom());
            }

            var fileContent = new ContentItemFileBuilder()
                              .UseRandomValues()
                              .Categories(categories)
                              .Build();

            var    sourceCategories = categories.AsCategoryEntities().ToArray();
            string expected         = sourceCategories.Select(c => c.Id).AsHash();

            fileContent.ExecutePostPropertyTest(expected, fieldValueDelegate, sourceCategories);
        }