Version 2.1 #41
@ -4,8 +4,7 @@ open Expecto
|
|||||||
open MyWebLog
|
open MyWebLog
|
||||||
|
|
||||||
/// Unit tests for the WebLog type
|
/// Unit tests for the WebLog type
|
||||||
let webLogTests =
|
let webLogTests = testList "WebLog" [
|
||||||
testList "WebLog" [
|
|
||||||
testList "ExtraPath" [
|
testList "ExtraPath" [
|
||||||
test "succeeds for blank URL base" {
|
test "succeeds for blank URL base" {
|
||||||
Expect.equal WebLog.Empty.ExtraPath "" "Extra path should have been blank for blank URL base"
|
Expect.equal WebLog.Empty.ExtraPath "" "Extra path should have been blank for blank URL base"
|
||||||
@ -66,8 +65,7 @@ let webLogTests =
|
|||||||
]
|
]
|
||||||
|
|
||||||
/// Unit tests for the WebLogUser type
|
/// Unit tests for the WebLogUser type
|
||||||
let webLogUserTests =
|
let webLogUserTests = testList "WebLogUser" [
|
||||||
testList "WebLogUser" [
|
|
||||||
testList "DisplayName" [
|
testList "DisplayName" [
|
||||||
test "succeeds when a preferred name is present" {
|
test "succeeds when a preferred name is present" {
|
||||||
Expect.equal
|
Expect.equal
|
||||||
@ -86,5 +84,4 @@ let webLogUserTests =
|
|||||||
]
|
]
|
||||||
|
|
||||||
/// All tests for the Domain.DataTypes file
|
/// All tests for the Domain.DataTypes file
|
||||||
let all =
|
let all = testList "DataTypes" [ webLogTests; webLogUserTests ]
|
||||||
testList "DataTypes" [ webLogTests; webLogUserTests ]
|
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
open Expecto
|
open Expecto
|
||||||
|
|
||||||
let allTests =
|
let allTests = testList "MyWebLog" [
|
||||||
testList
|
testList "Domain" [ SupportTypesTests.all; DataTypesTests.all; ViewModelsTests.all ]
|
||||||
"MyWebLog"
|
]
|
||||||
[ testList "Domain" [ SupportTypesTests.all; DataTypesTests.all; ViewModelsTests.all ] ]
|
|
||||||
|
|
||||||
[<EntryPoint>]
|
[<EntryPoint>]
|
||||||
let main args = runTestsWithCLIArgs [] args allTests
|
let main args = runTestsWithCLIArgs [] args allTests
|
||||||
|
@ -6,8 +6,7 @@ open MyWebLog
|
|||||||
open NodaTime
|
open NodaTime
|
||||||
|
|
||||||
/// Tests for the NodaTime-wrapping module
|
/// Tests for the NodaTime-wrapping module
|
||||||
let nodaTests =
|
let nodaTests = testList "Noda" [
|
||||||
testList "Noda" [
|
|
||||||
test "epoch succeeds" {
|
test "epoch succeeds" {
|
||||||
Expect.equal
|
Expect.equal
|
||||||
(Noda.epoch.ToDateTimeUtc())
|
(Noda.epoch.ToDateTimeUtc())
|
||||||
@ -29,8 +28,7 @@ let nodaTests =
|
|||||||
]
|
]
|
||||||
|
|
||||||
/// Tests for the AccessLevel type
|
/// Tests for the AccessLevel type
|
||||||
let accessLevelTests =
|
let accessLevelTests = testList "AccessLevel" [
|
||||||
testList "AccessLevel" [
|
|
||||||
testList "Parse" [
|
testList "Parse" [
|
||||||
test "succeeds for \"Author\"" {
|
test "succeeds for \"Author\"" {
|
||||||
Expect.equal Author (AccessLevel.Parse "Author") "Author not parsed correctly"
|
Expect.equal Author (AccessLevel.Parse "Author") "Author not parsed correctly"
|
||||||
@ -116,8 +114,7 @@ let accessLevelTests =
|
|||||||
]
|
]
|
||||||
|
|
||||||
/// Tests for the CommentStatus type
|
/// Tests for the CommentStatus type
|
||||||
let commentStatusTests =
|
let commentStatusTests = testList "CommentStatus" [
|
||||||
testList "CommentStatus" [
|
|
||||||
testList "Parse" [
|
testList "Parse" [
|
||||||
test "succeeds for \"Approved\"" {
|
test "succeeds for \"Approved\"" {
|
||||||
Expect.equal Approved (CommentStatus.Parse "Approved") "Approved not parsed correctly"
|
Expect.equal Approved (CommentStatus.Parse "Approved") "Approved not parsed correctly"
|
||||||
@ -146,8 +143,8 @@ let commentStatusTests =
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
let explicitRatingTests =
|
/// Tests for the ExplicitRating type
|
||||||
testList "ExplicitRating" [
|
let explicitRatingTests = testList "ExplicitRating" [
|
||||||
testList "Parse" [
|
testList "Parse" [
|
||||||
test "succeeds for \"yes\"" {
|
test "succeeds for \"yes\"" {
|
||||||
Expect.equal Yes (ExplicitRating.Parse "yes") "\"yes\" not parsed correctly"
|
Expect.equal Yes (ExplicitRating.Parse "yes") "\"yes\" not parsed correctly"
|
||||||
@ -177,8 +174,7 @@ let explicitRatingTests =
|
|||||||
]
|
]
|
||||||
|
|
||||||
/// Tests for the Episode type
|
/// Tests for the Episode type
|
||||||
let episodeTests =
|
let episodeTests = testList "Episode" [
|
||||||
testList "Episode" [
|
|
||||||
testList "FormatDuration" [
|
testList "FormatDuration" [
|
||||||
test "succeeds when no duration is specified" {
|
test "succeeds when no duration is specified" {
|
||||||
Expect.isNone (Episode.Empty.FormatDuration()) "A missing duration should have returned None"
|
Expect.isNone (Episode.Empty.FormatDuration()) "A missing duration should have returned None"
|
||||||
@ -200,8 +196,7 @@ let episodeTests =
|
|||||||
]
|
]
|
||||||
|
|
||||||
/// Unit tests for the MarkupText type
|
/// Unit tests for the MarkupText type
|
||||||
let markupTextTests =
|
let markupTextTests = testList "MarkupText" [
|
||||||
testList "MarkupText" [
|
|
||||||
testList "Parse" [
|
testList "Parse" [
|
||||||
test "succeeds with HTML content" {
|
test "succeeds with HTML content" {
|
||||||
let txt = MarkupText.Parse "HTML: <p>howdy</p>"
|
let txt = MarkupText.Parse "HTML: <p>howdy</p>"
|
||||||
@ -239,9 +234,7 @@ let markupTextTests =
|
|||||||
testList "ToString" [
|
testList "ToString" [
|
||||||
test "succeeds for HTML" {
|
test "succeeds for HTML" {
|
||||||
Expect.equal
|
Expect.equal
|
||||||
(string (MarkupText.Parse "HTML: <h1>HTML</h1>"))
|
(string (MarkupText.Parse "HTML: <h1>HTML</h1>")) "HTML: <h1>HTML</h1>" "HTML string value incorrect"
|
||||||
"HTML: <h1>HTML</h1>"
|
|
||||||
"HTML string value incorrect"
|
|
||||||
}
|
}
|
||||||
test "succeeds for Markdown" {
|
test "succeeds for Markdown" {
|
||||||
Expect.equal
|
Expect.equal
|
||||||
@ -253,9 +246,7 @@ let markupTextTests =
|
|||||||
testList "AsHtml" [
|
testList "AsHtml" [
|
||||||
test "succeeds for HTML" {
|
test "succeeds for HTML" {
|
||||||
Expect.equal
|
Expect.equal
|
||||||
((MarkupText.Parse "HTML: <h1>The Heading</h1>").AsHtml())
|
((MarkupText.Parse "HTML: <h1>The Heading</h1>").AsHtml()) "<h1>The Heading</h1>" "HTML value incorrect"
|
||||||
"<h1>The Heading</h1>"
|
|
||||||
"HTML value incorrect"
|
|
||||||
}
|
}
|
||||||
test "succeeds for Markdown" {
|
test "succeeds for Markdown" {
|
||||||
Expect.equal
|
Expect.equal
|
||||||
@ -267,8 +258,7 @@ let markupTextTests =
|
|||||||
]
|
]
|
||||||
|
|
||||||
/// Unit tests for the PodcastMedium type
|
/// Unit tests for the PodcastMedium type
|
||||||
let podcastMediumTests =
|
let podcastMediumTests = testList "PodcastMedium" [
|
||||||
testList "PodcastMedium" [
|
|
||||||
testList "Parse" [
|
testList "Parse" [
|
||||||
test "succeeds for \"podcast\"" {
|
test "succeeds for \"podcast\"" {
|
||||||
Expect.equal (PodcastMedium.Parse "podcast") Podcast "\"podcast\" not parsed correctly"
|
Expect.equal (PodcastMedium.Parse "podcast") Podcast "\"podcast\" not parsed correctly"
|
||||||
@ -322,8 +312,7 @@ let podcastMediumTests =
|
|||||||
]
|
]
|
||||||
|
|
||||||
/// Unit tests for the PostStatus type
|
/// Unit tests for the PostStatus type
|
||||||
let postStatusTests =
|
let postStatusTests = testList "PostStatus" [
|
||||||
testList "PostStatus" [
|
|
||||||
testList "Parse" [
|
testList "Parse" [
|
||||||
test "succeeds for \"Draft\"" {
|
test "succeeds for \"Draft\"" {
|
||||||
Expect.equal (PostStatus.Parse "Draft") Draft "\"Draft\" not parsed correctly"
|
Expect.equal (PostStatus.Parse "Draft") Draft "\"Draft\" not parsed correctly"
|
||||||
@ -339,8 +328,7 @@ let postStatusTests =
|
|||||||
]
|
]
|
||||||
|
|
||||||
/// Unit tests for the CustomFeedSource type
|
/// Unit tests for the CustomFeedSource type
|
||||||
let customFeedSourceTests =
|
let customFeedSourceTests = testList "CustomFeedSource" [
|
||||||
testList "CustomFeedSource" [
|
|
||||||
testList "Parse" [
|
testList "Parse" [
|
||||||
test "succeeds for category feeds" {
|
test "succeeds for category feeds" {
|
||||||
Expect.equal
|
Expect.equal
|
||||||
@ -353,8 +341,7 @@ let customFeedSourceTests =
|
|||||||
}
|
}
|
||||||
test "fails for unknown type" {
|
test "fails for unknown type" {
|
||||||
Expect.throwsT<ArgumentException>
|
Expect.throwsT<ArgumentException>
|
||||||
(fun () -> ignore (CustomFeedSource.Parse "nasa:sat1"))
|
(fun () -> ignore (CustomFeedSource.Parse "nasa:sat1")) "Invalid value should have raised an exception"
|
||||||
"Invalid value should have raised an exception"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
testList "ToString" [
|
testList "ToString" [
|
||||||
@ -369,8 +356,7 @@ let customFeedSourceTests =
|
|||||||
]
|
]
|
||||||
|
|
||||||
/// Unit tests for the ThemeAssetId type
|
/// Unit tests for the ThemeAssetId type
|
||||||
let themeAssetIdTests =
|
let themeAssetIdTests = testList "ThemeAssetId" [
|
||||||
testList "ThemeAssetId" [
|
|
||||||
testList "Parse" [
|
testList "Parse" [
|
||||||
test "succeeds with expected values" {
|
test "succeeds with expected values" {
|
||||||
Expect.equal
|
Expect.equal
|
||||||
@ -380,8 +366,7 @@ let themeAssetIdTests =
|
|||||||
}
|
}
|
||||||
test "fails if no slash is present" {
|
test "fails if no slash is present" {
|
||||||
Expect.throwsT<ArgumentException>
|
Expect.throwsT<ArgumentException>
|
||||||
(fun () -> ignore (ThemeAssetId.Parse "my-theme-asset"))
|
(fun () -> ignore (ThemeAssetId.Parse "my-theme-asset")) "Invalid value should have raised an exception"
|
||||||
"Invalid value should have raised an exception"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
test "ToString succeeds" {
|
test "ToString succeeds" {
|
||||||
@ -391,8 +376,7 @@ let themeAssetIdTests =
|
|||||||
]
|
]
|
||||||
|
|
||||||
/// Unit tests for the UploadDestination type
|
/// Unit tests for the UploadDestination type
|
||||||
let uploadDestinationTests =
|
let uploadDestinationTests = testList "UploadDestination" [
|
||||||
testList "UploadDestination" [
|
|
||||||
testList "Parse" [
|
testList "Parse" [
|
||||||
test "succeeds for \"Database\"" {
|
test "succeeds for \"Database\"" {
|
||||||
Expect.equal (UploadDestination.Parse "Database") Database "\"Database\" not parsed correctly"
|
Expect.equal (UploadDestination.Parse "Database") Database "\"Database\" not parsed correctly"
|
||||||
@ -416,10 +400,8 @@ let uploadDestinationTests =
|
|||||||
]
|
]
|
||||||
|
|
||||||
/// All tests for the Domain.SupportTypes file
|
/// All tests for the Domain.SupportTypes file
|
||||||
let all =
|
let all = testList "SupportTypes" [
|
||||||
testList
|
nodaTests
|
||||||
"SupportTypes"
|
|
||||||
[ nodaTests
|
|
||||||
accessLevelTests
|
accessLevelTests
|
||||||
commentStatusTests
|
commentStatusTests
|
||||||
explicitRatingTests
|
explicitRatingTests
|
||||||
@ -429,4 +411,5 @@ let all =
|
|||||||
postStatusTests
|
postStatusTests
|
||||||
customFeedSourceTests
|
customFeedSourceTests
|
||||||
themeAssetIdTests
|
themeAssetIdTests
|
||||||
uploadDestinationTests ]
|
uploadDestinationTests
|
||||||
|
]
|
||||||
|
@ -7,8 +7,7 @@ open MyWebLog.ViewModels
|
|||||||
open NodaTime
|
open NodaTime
|
||||||
|
|
||||||
/// Unit tests for the addBaseToRelativeUrls helper function
|
/// Unit tests for the addBaseToRelativeUrls helper function
|
||||||
let addBaseToRelativeUrlsTests =
|
let addBaseToRelativeUrlsTests = testList "PublicHelpers.addBaseToRelativeUrls" [
|
||||||
testList "PublicHelpers.addBaseToRelativeUrls" [
|
|
||||||
test "succeeds when there is no extra URL path" {
|
test "succeeds when there is no extra URL path" {
|
||||||
let testText = """<a href="/somewhere-else.html">Howdy></a>"""
|
let testText = """<a href="/somewhere-else.html">Howdy></a>"""
|
||||||
let modified = addBaseToRelativeUrls "" testText
|
let modified = addBaseToRelativeUrls "" testText
|
||||||
@ -24,8 +23,7 @@ let addBaseToRelativeUrlsTests =
|
|||||||
]
|
]
|
||||||
|
|
||||||
/// Unit tests for the DisplayCustomFeed type
|
/// Unit tests for the DisplayCustomFeed type
|
||||||
let displayCustomFeedTests =
|
let displayCustomFeedTests = testList "DisplayCustomFeed.FromFeed" [
|
||||||
testList "DisplayCustomFeed.FromFeed" [
|
|
||||||
test "succeeds for a feed for an existing category" {
|
test "succeeds for a feed for an existing category" {
|
||||||
let cats =
|
let cats =
|
||||||
[| { DisplayCategory.Id = "abc"
|
[| { DisplayCategory.Id = "abc"
|
||||||
@ -72,8 +70,7 @@ let displayCustomFeedTests =
|
|||||||
]
|
]
|
||||||
|
|
||||||
/// Unit tests for the DisplayPage type
|
/// Unit tests for the DisplayPage type
|
||||||
let displayPageTests =
|
let displayPageTests = testList "DisplayPage" [
|
||||||
testList "DisplayPage" [
|
|
||||||
let page =
|
let page =
|
||||||
{ Page.Empty with
|
{ Page.Empty with
|
||||||
Id = PageId "my-page"
|
Id = PageId "my-page"
|
||||||
@ -97,9 +94,7 @@ let displayPageTests =
|
|||||||
((Noda.epoch + Duration.FromHours 1).ToDateTimeUtc())
|
((Noda.epoch + Duration.FromHours 1).ToDateTimeUtc())
|
||||||
"PublishedOn not filled properly"
|
"PublishedOn not filled properly"
|
||||||
Expect.equal
|
Expect.equal
|
||||||
model.UpdatedOn
|
model.UpdatedOn ((Noda.epoch + Duration.FromHours 2).ToDateTimeUtc()) "UpdatedOn not filled properly"
|
||||||
((Noda.epoch + Duration.FromHours 2).ToDateTimeUtc())
|
|
||||||
"UpdatedOn not filled properly"
|
|
||||||
Expect.isFalse model.IsInPageList "IsInPageList should not have been set"
|
Expect.isFalse model.IsInPageList "IsInPageList should not have been set"
|
||||||
Expect.isTrue model.IsDefault "IsDefault should have been set"
|
Expect.isTrue model.IsDefault "IsDefault should have been set"
|
||||||
Expect.equal model.Text "" "Text should have been blank"
|
Expect.equal model.Text "" "Text should have been blank"
|
||||||
@ -139,23 +134,20 @@ let displayPageTests =
|
|||||||
]
|
]
|
||||||
|
|
||||||
/// Unit tests for the DisplayRevision type
|
/// Unit tests for the DisplayRevision type
|
||||||
let displayRevisionTests =
|
let displayRevisionTests = test "DisplayRevision.FromRevision succeeds" {
|
||||||
test "DisplayRevision.FromRevision succeeds" {
|
|
||||||
let model =
|
let model =
|
||||||
DisplayRevision.FromRevision
|
DisplayRevision.FromRevision
|
||||||
{ WebLog.Empty with TimeZone = "Etc/GMT+1" }
|
{ WebLog.Empty with TimeZone = "Etc/GMT+1" }
|
||||||
{ Text = Html "howdy"; AsOf = Noda.epoch }
|
{ Text = Html "howdy"; AsOf = Noda.epoch }
|
||||||
Expect.equal model.AsOf (Noda.epoch.ToDateTimeUtc()) "AsOf not filled properly"
|
Expect.equal model.AsOf (Noda.epoch.ToDateTimeUtc()) "AsOf not filled properly"
|
||||||
Expect.equal
|
Expect.equal model.AsOfLocal ((Noda.epoch - Duration.FromHours 1).ToDateTimeUtc()) "AsOfLocal not filled properly"
|
||||||
model.AsOfLocal ((Noda.epoch - Duration.FromHours 1).ToDateTimeUtc()) "AsOfLocal not filled properly"
|
|
||||||
Expect.equal model.Format "HTML" "Format not filled properly"
|
Expect.equal model.Format "HTML" "Format not filled properly"
|
||||||
}
|
}
|
||||||
|
|
||||||
open System.IO
|
open System.IO
|
||||||
|
|
||||||
/// Unit tests for the DisplayTheme type
|
/// Unit tests for the DisplayTheme type
|
||||||
let displayThemeTests =
|
let displayThemeTests = testList "DisplayTheme.FromTheme" [
|
||||||
testList "DisplayTheme.FromTheme" [
|
|
||||||
let theme =
|
let theme =
|
||||||
{ Id = ThemeId "the-theme"
|
{ Id = ThemeId "the-theme"
|
||||||
Name = "Test Theme"
|
Name = "Test Theme"
|
||||||
@ -186,8 +178,7 @@ let displayThemeTests =
|
|||||||
]
|
]
|
||||||
|
|
||||||
/// Unit tests for the DisplayUpload type
|
/// Unit tests for the DisplayUpload type
|
||||||
let displayUploadTests =
|
let displayUploadTests = test "DisplayUpload.FromUpload succeeds" {
|
||||||
test "DisplayUpload.FromUpload succeeds" {
|
|
||||||
let upload =
|
let upload =
|
||||||
{ Upload.Empty with
|
{ Upload.Empty with
|
||||||
Id = UploadId "test-up"
|
Id = UploadId "test-up"
|
||||||
@ -204,8 +195,7 @@ let displayUploadTests =
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Unit tests for the DisplayUser type
|
/// Unit tests for the DisplayUser type
|
||||||
let displayUserTests =
|
let displayUserTests = testList "DisplayUser.FromUser" [
|
||||||
testList "DisplayUser.FromUser" [
|
|
||||||
let minimalUser =
|
let minimalUser =
|
||||||
{ WebLogUser.Empty with
|
{ WebLogUser.Empty with
|
||||||
Id = WebLogUserId "test-user"
|
Id = WebLogUserId "test-user"
|
||||||
@ -246,8 +236,7 @@ let displayUserTests =
|
|||||||
]
|
]
|
||||||
|
|
||||||
/// Unit tests for the EditCategoryModel type
|
/// Unit tests for the EditCategoryModel type
|
||||||
let editCategoryModelTests =
|
let editCategoryModelTests = testList "EditCategoryModel" [
|
||||||
testList "EditCategoryModel" [
|
|
||||||
testList "FromCategory" [
|
testList "FromCategory" [
|
||||||
let minimalCat = { Category.Empty with Id = CategoryId "test-cat"; Name = "test"; Slug = "test-slug" }
|
let minimalCat = { Category.Empty with Id = CategoryId "test-cat"; Name = "test"; Slug = "test-slug" }
|
||||||
test "succeeds with minimal information" {
|
test "succeeds with minimal information" {
|
||||||
@ -278,15 +267,203 @@ let editCategoryModelTests =
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
/// All tests for the Domain namespace
|
/// Unit tests for the EditCustomFeedModel type
|
||||||
let all =
|
let editCustomFeedModelTests = testList "EditCustomFeedModel" [
|
||||||
testList
|
let minimalPodcast =
|
||||||
"ViewModels"
|
{ PodcastOptions.Empty with
|
||||||
[ addBaseToRelativeUrlsTests
|
Title = "My Minimal Podcast"
|
||||||
|
Summary = "As little as possible"
|
||||||
|
DisplayedAuthor = "The Tester"
|
||||||
|
Email = "thetester@example.com"
|
||||||
|
ImageUrl = Permalink "upload/my-image.png"
|
||||||
|
AppleCategory = "News"
|
||||||
|
Explicit = Clean }
|
||||||
|
// A GUID with all zeroes, ending in "a"
|
||||||
|
let aGuid =
|
||||||
|
let guidBytes = Guid.Empty.ToByteArray()
|
||||||
|
guidBytes[15] <- byte 10
|
||||||
|
Guid guidBytes
|
||||||
|
let fullPodcast =
|
||||||
|
{ minimalPodcast with
|
||||||
|
Subtitle = Some "A Podcast about Little"
|
||||||
|
ItemsInFeed = 17
|
||||||
|
AppleSubcategory = Some "Analysis"
|
||||||
|
DefaultMediaType = Some "video/mpeg4"
|
||||||
|
MediaBaseUrl = Some "a/b/c"
|
||||||
|
PodcastGuid = Some aGuid
|
||||||
|
FundingUrl = Some "https://pay.me"
|
||||||
|
FundingText = Some "Gimme Money!"
|
||||||
|
Medium = Some Newsletter }
|
||||||
|
testList "FromFeed" [
|
||||||
|
test "succeeds with no podcast" {
|
||||||
|
let model =
|
||||||
|
EditCustomFeedModel.FromFeed
|
||||||
|
{ Id = CustomFeedId "test-feed"
|
||||||
|
Source = Category (CategoryId "no-podcast")
|
||||||
|
Path = Permalink "no-podcast.xml"
|
||||||
|
Podcast = None }
|
||||||
|
Expect.equal model.Id "test-feed" "Id not filled properly"
|
||||||
|
Expect.equal model.SourceType "category" "SourceType not filled properly"
|
||||||
|
Expect.equal model.SourceValue "no-podcast" "SourceValue not filled properly"
|
||||||
|
Expect.equal model.Path "no-podcast.xml" "Path not filled properly"
|
||||||
|
Expect.isFalse model.IsPodcast "IsPodcast should not have been set"
|
||||||
|
Expect.equal model.Title "" "Title should be the default value"
|
||||||
|
Expect.equal model.Subtitle "" "Subtitle should be the default value"
|
||||||
|
Expect.equal model.ItemsInFeed 25 "ItemsInFeed should be the default value"
|
||||||
|
Expect.equal model.Summary "" "Summary should be the default value"
|
||||||
|
Expect.equal model.DisplayedAuthor "" "DisplayedAuthor should be the default value"
|
||||||
|
Expect.equal model.Email "" "Email should be the default value"
|
||||||
|
Expect.equal model.ImageUrl "" "ImageUrl should be the default value"
|
||||||
|
Expect.equal model.AppleCategory "" "AppleCategory should be the default value"
|
||||||
|
Expect.equal model.AppleSubcategory "" "AppleSubcategory should be the default value"
|
||||||
|
Expect.equal model.Explicit "no" "Explicit should be the default value"
|
||||||
|
Expect.equal model.DefaultMediaType "audio/mpeg" "DefaultMediaType should be the default value"
|
||||||
|
Expect.equal model.MediaBaseUrl "" "MediaBaseUrl should be the default value"
|
||||||
|
Expect.equal model.FundingUrl "" "FundingUrl should be the default value"
|
||||||
|
Expect.equal model.FundingText "" "FundingText should be the default value"
|
||||||
|
Expect.equal model.PodcastGuid "" "PodcastGuid should be the default value"
|
||||||
|
Expect.equal model.Medium "" "Medium should be the default value"
|
||||||
|
}
|
||||||
|
test "succeeds with minimal podcast" {
|
||||||
|
let model =
|
||||||
|
EditCustomFeedModel.FromFeed
|
||||||
|
{ Id = CustomFeedId "minimal-feed"
|
||||||
|
Source = Tag "min-podcast"
|
||||||
|
Path = Permalink "min-podcast.xml"
|
||||||
|
Podcast = Some minimalPodcast }
|
||||||
|
Expect.equal model.Id "minimal-feed" "Id not filled properly"
|
||||||
|
Expect.equal model.SourceType "tag" "SourceType not filled properly"
|
||||||
|
Expect.equal model.SourceValue "min-podcast" "SourceValue not filled properly"
|
||||||
|
Expect.equal model.Path "min-podcast.xml" "Path not filled properly"
|
||||||
|
Expect.isTrue model.IsPodcast "IsPodcast should have been set"
|
||||||
|
Expect.equal model.Title "My Minimal Podcast" "Title not filled properly"
|
||||||
|
Expect.equal model.Subtitle "" "Subtitle not filled properly (should be blank)"
|
||||||
|
Expect.equal model.ItemsInFeed 0 "ItemsInFeed not filled properly"
|
||||||
|
Expect.equal model.Summary "As little as possible" "Summary not filled properly"
|
||||||
|
Expect.equal model.DisplayedAuthor "The Tester" "DisplayedAuthor not filled properly"
|
||||||
|
Expect.equal model.Email "thetester@example.com" "Email not filled properly"
|
||||||
|
Expect.equal model.ImageUrl "upload/my-image.png" "ImageUrl not filled properly"
|
||||||
|
Expect.equal model.AppleCategory "News" "AppleCategory not filled properly"
|
||||||
|
Expect.equal model.AppleSubcategory "" "AppleSubcategory not filled properly (should be blank)"
|
||||||
|
Expect.equal model.Explicit "clean" "Explicit not filled properly"
|
||||||
|
Expect.equal model.DefaultMediaType "" "DefaultMediaType not filled properly (should be blank)"
|
||||||
|
Expect.equal model.MediaBaseUrl "" "MediaBaseUrl not filled properly (should be blank)"
|
||||||
|
Expect.equal model.FundingUrl "" "FundingUrl not filled properly (should be blank)"
|
||||||
|
Expect.equal model.FundingText "" "FundingText not filled properly (should be blank)"
|
||||||
|
Expect.equal model.PodcastGuid "" "PodcastGuid not filled properly (should be blank)"
|
||||||
|
Expect.equal model.Medium "" "Medium not filled properly (should be blank)"
|
||||||
|
}
|
||||||
|
test "succeeds with full podcast" {
|
||||||
|
let model =
|
||||||
|
EditCustomFeedModel.FromFeed
|
||||||
|
{ Id = CustomFeedId "full-feed"
|
||||||
|
Source = Tag "whole-enchilada"
|
||||||
|
Path = Permalink "full-podcast.xml"
|
||||||
|
Podcast = Some fullPodcast }
|
||||||
|
Expect.equal model.Id "full-feed" "Id not filled properly"
|
||||||
|
Expect.equal model.SourceType "tag" "SourceType not filled properly"
|
||||||
|
Expect.equal model.SourceValue "whole-enchilada" "SourceValue not filled properly"
|
||||||
|
Expect.equal model.Path "full-podcast.xml" "Path not filled properly"
|
||||||
|
Expect.isTrue model.IsPodcast "IsPodcast should have been set"
|
||||||
|
Expect.equal model.Title "My Minimal Podcast" "Title not filled properly"
|
||||||
|
Expect.equal model.Subtitle "A Podcast about Little" "Subtitle not filled properly"
|
||||||
|
Expect.equal model.ItemsInFeed 17 "ItemsInFeed not filled properly"
|
||||||
|
Expect.equal model.Summary "As little as possible" "Summary not filled properly"
|
||||||
|
Expect.equal model.DisplayedAuthor "The Tester" "DisplayedAuthor not filled properly"
|
||||||
|
Expect.equal model.Email "thetester@example.com" "Email not filled properly"
|
||||||
|
Expect.equal model.ImageUrl "upload/my-image.png" "ImageUrl not filled properly"
|
||||||
|
Expect.equal model.AppleCategory "News" "AppleCategory not filled properly"
|
||||||
|
Expect.equal model.AppleSubcategory "Analysis" "AppleSubcategory not filled properly"
|
||||||
|
Expect.equal model.Explicit "clean" "Explicit not filled properly"
|
||||||
|
Expect.equal model.DefaultMediaType "video/mpeg4" "DefaultMediaType not filled properly"
|
||||||
|
Expect.equal model.MediaBaseUrl "a/b/c" "MediaBaseUrl not filled properly"
|
||||||
|
Expect.equal model.FundingUrl "https://pay.me" "FundingUrl not filled properly"
|
||||||
|
Expect.equal model.FundingText "Gimme Money!" "FundingText not filled properly"
|
||||||
|
Expect.equal model.PodcastGuid "00000000-0000-0000-0000-00000000000a" "PodcastGuid not filled properly"
|
||||||
|
Expect.equal model.Medium "newsletter" "Medium not filled properly"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
testList "UpdateFeed" [
|
||||||
|
test "succeeds with no podcast" {
|
||||||
|
let model =
|
||||||
|
{ EditCustomFeedModel.Empty with SourceType = "tag"; SourceValue = "no-audio"; Path = "no-podcast.xml" }
|
||||||
|
let feed =
|
||||||
|
model.UpdateFeed
|
||||||
|
{ CustomFeed.Empty with Id = CustomFeedId "no-podcast-feed"; Podcast = Some fullPodcast }
|
||||||
|
Expect.equal feed.Id (CustomFeedId "no-podcast-feed") "Id not filled properly"
|
||||||
|
Expect.equal feed.Source (Tag "no-audio") "Source not filled properly"
|
||||||
|
Expect.equal feed.Path (Permalink "no-podcast.xml") "Path not filled properly"
|
||||||
|
Expect.isNone feed.Podcast "Podcast not filled properly"
|
||||||
|
}
|
||||||
|
test "succeeds with minimal podcast" {
|
||||||
|
let model = EditCustomFeedModel.FromFeed { CustomFeed.Empty with Podcast = Some minimalPodcast }
|
||||||
|
let feed = model.UpdateFeed CustomFeed.Empty
|
||||||
|
Expect.equal feed.Source (Category (CategoryId "")) "Source not filled properly"
|
||||||
|
Expect.equal feed.Path (Permalink "") "Path not filled properly"
|
||||||
|
Expect.isSome feed.Podcast "Podcast should be present"
|
||||||
|
let podcast = feed.Podcast.Value
|
||||||
|
Expect.equal podcast.Title "My Minimal Podcast" "Podcast title not filled properly"
|
||||||
|
Expect.isNone podcast.Subtitle "Podcast subtitle not filled properly"
|
||||||
|
Expect.equal podcast.ItemsInFeed 0 "Podcast items in feed not filled properly"
|
||||||
|
Expect.equal podcast.Summary "As little as possible" "Podcast summary not filled properly"
|
||||||
|
Expect.equal podcast.DisplayedAuthor "The Tester" "Podcast author not filled properly"
|
||||||
|
Expect.equal podcast.Email "thetester@example.com" "Podcast email not filled properly"
|
||||||
|
Expect.equal podcast.Explicit Clean "Podcast explicit rating not filled properly"
|
||||||
|
Expect.equal podcast.AppleCategory "News" "Podcast Apple category not filled properly"
|
||||||
|
Expect.isNone podcast.AppleSubcategory "Podcast Apple subcategory not filled properly"
|
||||||
|
Expect.isNone podcast.DefaultMediaType "Podcast default media type not filled properly"
|
||||||
|
Expect.isNone podcast.MediaBaseUrl "Podcast media base URL not filled properly"
|
||||||
|
Expect.isNone podcast.PodcastGuid "Podcast GUID not filled properly"
|
||||||
|
Expect.isNone podcast.FundingUrl "Podcast funding URL not filled properly"
|
||||||
|
Expect.isNone podcast.FundingText "Podcast funding text not filled properly"
|
||||||
|
Expect.isNone podcast.Medium "Podcast medium not filled properly"
|
||||||
|
}
|
||||||
|
test "succeeds with full podcast" {
|
||||||
|
let model = EditCustomFeedModel.FromFeed { CustomFeed.Empty with Podcast = Some fullPodcast }
|
||||||
|
let feed = model.UpdateFeed CustomFeed.Empty
|
||||||
|
Expect.equal feed.Source (Category (CategoryId "")) "Source not filled properly"
|
||||||
|
Expect.equal feed.Path (Permalink "") "Path not filled properly"
|
||||||
|
Expect.isSome feed.Podcast "Podcast should be present"
|
||||||
|
let podcast = feed.Podcast.Value
|
||||||
|
Expect.equal podcast.Title "My Minimal Podcast" "Podcast title not filled properly"
|
||||||
|
Expect.equal podcast.Subtitle (Some "A Podcast about Little") "Podcast subtitle not filled properly"
|
||||||
|
Expect.equal podcast.ItemsInFeed 17 "Podcast items in feed not filled properly"
|
||||||
|
Expect.equal podcast.Summary "As little as possible" "Podcast summary not filled properly"
|
||||||
|
Expect.equal podcast.DisplayedAuthor "The Tester" "Podcast author not filled properly"
|
||||||
|
Expect.equal podcast.Email "thetester@example.com" "Podcast email not filled properly"
|
||||||
|
Expect.equal podcast.Explicit Clean "Podcast explicit rating not filled properly"
|
||||||
|
Expect.equal podcast.AppleCategory "News" "Podcast Apple category not filled properly"
|
||||||
|
Expect.equal podcast.AppleSubcategory (Some "Analysis") "Podcast Apple subcategory not filled properly"
|
||||||
|
Expect.equal podcast.DefaultMediaType (Some "video/mpeg4") "Podcast default media type not filled properly"
|
||||||
|
Expect.equal podcast.MediaBaseUrl (Some "a/b/c") "Podcast media base URL not filled properly"
|
||||||
|
Expect.equal podcast.PodcastGuid (Some aGuid) "Podcast GUID not filled properly"
|
||||||
|
Expect.equal podcast.FundingUrl (Some "https://pay.me") "Podcast funding URL not filled properly"
|
||||||
|
Expect.equal podcast.FundingText (Some "Gimme Money!") "Podcast funding text not filled properly"
|
||||||
|
Expect.equal podcast.Medium (Some Newsletter) "Podcast medium not filled properly"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
/// Unit tests for the EditMyInfoModel type
|
||||||
|
let editMyInfoModelTests = test "EditMyInfoModel.FromUser succeeds" {
|
||||||
|
let model = EditMyInfoModel.FromUser { WebLogUser.Empty with FirstName = "A"; LastName = "B"; PreferredName = "C" }
|
||||||
|
Expect.equal model.FirstName "A" "FirstName not filled properly"
|
||||||
|
Expect.equal model.LastName "B" "LastName not filled properly"
|
||||||
|
Expect.equal model.PreferredName "C" "PreferredName not filled properly"
|
||||||
|
Expect.equal model.NewPassword "" "NewPassword not filled properly"
|
||||||
|
Expect.equal model.NewPasswordConfirm "" "NewPasswordConfirm not filled properly"
|
||||||
|
}
|
||||||
|
|
||||||
|
/// All tests in the Domain.ViewModels file
|
||||||
|
let all = testList "ViewModels" [
|
||||||
|
addBaseToRelativeUrlsTests
|
||||||
displayCustomFeedTests
|
displayCustomFeedTests
|
||||||
displayPageTests
|
displayPageTests
|
||||||
displayRevisionTests
|
displayRevisionTests
|
||||||
displayThemeTests
|
displayThemeTests
|
||||||
displayUploadTests
|
displayUploadTests
|
||||||
displayUserTests
|
displayUserTests
|
||||||
editCategoryModelTests ]
|
editCategoryModelTests
|
||||||
|
editCustomFeedModelTests
|
||||||
|
editMyInfoModelTests
|
||||||
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user