public void ReturnAnEmptyStringInTheByLineFieldIfAuthorFieldIsMissing() { String fieldValueDelegate(ContentItem c) => c.ByLine; var fileContents = new ContentItemFileBuilder() .UseRandomValues() .RemoveAuthor() .Build(); fileContents.ExecutePagePropertyTest <String>(string.Empty, fieldValueDelegate); }
public void ReturnTheProperValueInTheDescriptionField() { String fieldValueDelegate(ContentItem c) => c.Description; string expected = string.Empty.GetRandom(); var fileContent = new ContentItemFileBuilder() .UseRandomValues() .Description(expected) .Build(); fileContent.ExecutePostPropertyTest(expected, fieldValueDelegate); }
public void ReturnFalseIfTheIsPublishedFieldIsMissing() { Boolean fieldValueDelegate(ContentItem c) => c.IsPublished; bool expected = false; var fileContents = new ContentItemFileBuilder() .UseRandomValues() .RemoveIsPublished() .Build(); fileContents.ExecutePagePropertyTest <Boolean>(expected, fieldValueDelegate); }
public void ReturnTrueIfThePageIsPublished() { Boolean fieldValueDelegate(ContentItem c) => c.IsPublished; bool expected = true; var fileContents = new ContentItemFileBuilder() .UseRandomValues() .IsPublished(expected) .Build(); fileContents.ExecutePagePropertyTest <Boolean>(expected, fieldValueDelegate); }
public void ReturnTheProperValueInTheIdField() { Guid fieldValueDelegate(ContentItem c) => c.Id; var expected = Guid.NewGuid(); var fileContents = new ContentItemFileBuilder() .UseRandomValues() .Id(expected) .Build(); fileContents.ExecutePagePropertyTest <Guid>(expected, fieldValueDelegate); }
public void ReturnAnEmptyStringInTheByDescriptionFieldIfDescriptionIsMissing() { String fieldValueDelegate(ContentItem c) => c.Description; String expected = string.Empty; var fileContent = new ContentItemFileBuilder() .UseRandomValues() .RemoveDescription() .Build(); fileContent.ExecutePagePropertyTest(expected, fieldValueDelegate); }
public void ReturnTheTagFromASingleTagPost() { String fieldValueDelegate(ContentItem c) => c.Tags.AsHash(); String[] expected = new[] { string.Empty.GetRandom() }; var fileContent = new ContentItemFileBuilder() .UseRandomValues() .Tags(expected) .Build(); fileContent.ExecutePostPropertyTest(expected.AsHash(), fieldValueDelegate); }
public void ReturnTheProperValueInTheLastModificationDateField() { DateTime fieldValueDelegate(ContentItem c) => c.LastModificationDate.ToSecondPrecision(); DateTime expected = DateTime.Parse("1/1/2000").AddSeconds(Int32.MaxValue); var fileContents = new ContentItemFileBuilder() .UseRandomValues() .LastModificationDate(expected) .Build(); fileContents.ExecutePagePropertyTest <DateTime>(expected.ToSecondPrecision(), fieldValueDelegate); }
public void ReturnTheProperValueInTheSlugField() { String fieldValueDelegate(ContentItem c) => c.Slug; String expected = string.Empty.GetRandom(); var fileContents = new ContentItemFileBuilder() .UseRandomValues() .Slug(expected) .Build(); fileContents.ExecutePagePropertyTest(expected, fieldValueDelegate); }
public void ReturnFalseIfThePageIsNotMarkedShowInList() { Boolean fieldValueDelegate(ContentItem c) => c.ShowInList; bool expected = false; var fileContents = new ContentItemFileBuilder() .UseRandomValues() .ShowInList(expected) .Build(); fileContents.ExecutePagePropertyTest <Boolean>(expected, fieldValueDelegate); }
public void ReturnAnEmptyStringInTheByLineFieldIfAuthorFieldIsMissing() { String fieldValueDelegate(ContentItem c) => c.ByLine; String expected = string.Empty; var fileContent = new ContentItemFileBuilder() .UseRandomValues() .RemoveAuthor() .Build(); fileContent.ExecutePostPropertyTest(expected, fieldValueDelegate); }
public void ReturnTheProperValueInThePublicationDateField() { DateTime fieldValueDelegate(ContentItem c) => c.PublicationDate.ToSecondPrecision(); DateTime expected = DateTime.Parse("1/1/1900").AddSeconds(Int32.MaxValue.GetRandom()); var fileContent = new ContentItemFileBuilder() .UseRandomValues() .PublicationDate(expected) .Build(); fileContent.ExecutePostPropertyTest(expected, fieldValueDelegate); }
public void ReturnFalseIfThePostIsNotPublished() { Boolean fieldValueDelegate(ContentItem c) => c.IsPublished; Boolean expected = false; var fileContent = new ContentItemFileBuilder() .UseRandomValues() .IsPublished(expected) .Build(); fileContent.ExecutePostPropertyTest(expected, fieldValueDelegate); }
public void ReturnTheHtmlFormattedValueInTheContentField() { String fieldValueDelegate(ContentItem c) => c.Content.Trim(); String content = string.Empty.GetRandom(500); String expected = $"<p>{content}</p>"; var fileContents = new ContentItemFileBuilder() .UseRandomValues() .Content(content) .Build(); fileContents.ExecutePagePropertyTest <String>(expected, fieldValueDelegate); }
public void ReturnTheProperValueInTheIdFieldIfDelimitedBySingleQuotes() { Guid fieldValueDelegate(ContentItem c) => c.Id; var expected = Guid.NewGuid(); var fileContent = new ContentItemFileBuilder() .UseRandomValues() .Id(expected) .IdDelimiter('\'') .Build(); fileContent.ExecutePostPropertyTest(expected, fieldValueDelegate); }
public void ReturnTheProperValueInTheByLineField() { String fieldValueDelegate(ContentItem c) => c.ByLine; String expectedAuthor = string.Empty.GetRandom(); String expected = $"by {expectedAuthor}"; var fileContents = new ContentItemFileBuilder() .UseRandomValues() .Author(expectedAuthor) .Build(); fileContents.ExecutePagePropertyTest <String>(expected, fieldValueDelegate); }
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); }
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); }
public static ContentItemFileBuilder UseRandomValues(this ContentItemFileBuilder builder) { return(builder .Tags(new[] { string.Empty.GetRandom() }) .Id(Guid.NewGuid()) .Author(string.Empty.GetRandom(10)) .Title(string.Empty.GetRandom(15)) .Description(string.Empty.GetRandom(25)) .IsPublished(true) .ShowInList(true) .PublicationDate(DateTime.Parse("1/1/2000").AddSeconds(Int32.MaxValue)) .LastModificationDate(DateTime.Parse("1/1/2000").AddSeconds(Int32.MaxValue)) .Slug(string.Empty.GetRandom(20)) .Categories(new[] { string.Empty.GetRandom() }) .MenuOrder(10.GetRandom()) .Content(string.Empty.GetRandom(200))); }
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); }
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); }
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); }
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); }
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); }