-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-74 :: TrainingGuides.Web.Tests folder structure
- Loading branch information
1 parent
9120a4f
commit c237395
Showing
8 changed files
with
1,439 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using Xunit; | ||
using CMS.Websites; | ||
using Moq; | ||
using TrainingGuides.Web.Features.Articles.Services; | ||
using TrainingGuides.Web.Features.Articles; | ||
using Microsoft.AspNetCore.Html; | ||
|
||
namespace TrainingGuides.Web.Tests; | ||
|
||
public class ArticlePageServiceTests | ||
{ | ||
private readonly Mock<ArticlePageService> articlePageServiceMock; | ||
private readonly Mock<IWebPageUrlRetriever> webPageUrlRetrieverMock; | ||
|
||
private const string TEST_URL = "test"; | ||
|
||
public ArticlePageServiceTests() | ||
{ | ||
webPageUrlRetrieverMock = new Mock<IWebPageUrlRetriever>(); | ||
webPageUrlRetrieverMock.Setup(x => x.Retrieve(It.IsAny<ArticlePage>(), It.IsAny<CancellationToken>())) | ||
.ReturnsAsync(new WebPageUrl(TEST_URL)); | ||
|
||
articlePageServiceMock = new Mock<ArticlePageService>(webPageUrlRetrieverMock.Object); | ||
} | ||
|
||
[Fact] | ||
public async Task GetArticlePageViewModel_ShouldReturnArticleWithUrl() | ||
{ | ||
ArticlePageViewModel referenceViewModel = new() | ||
{ | ||
Title = string.Empty, | ||
Summary = HtmlString.Empty, | ||
Text = HtmlString.Empty, | ||
Url = TEST_URL | ||
}; | ||
|
||
var articlePage = new ArticlePage() | ||
{ | ||
ArticlePageArticleContent = [new GeneralArticle() | ||
{ | ||
ArticleSchemaTitle = "Title", | ||
ArticleSchemaSummary = "Summary", | ||
ArticleSchemaText = "Text", | ||
ArticleSchemaTeaser = [] | ||
}], | ||
ArticlePagePublishDate = DateTime.Now | ||
}; | ||
var viewModelWithUrl = await articlePageServiceMock.Object.GetArticlePageViewModel(articlePage); | ||
|
||
Assert.Equal(referenceViewModel.Url, viewModelWithUrl.Url); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
test/TrainingGuides.Web.Tests/ArticlePageViewModelTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Microsoft.AspNetCore.Html; | ||
using TrainingGuides.Web.Features.Articles; | ||
using TrainingGuides.Web.Features.Shared.Models; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace TrainingGuides.Web.Tests; | ||
|
||
public class ArticlePageViewModelTests | ||
{ | ||
private readonly ArticlePageViewModel viewModel = new(); | ||
|
||
[Fact] | ||
public void ViewModel_Initialized_TitleIsEmpty() | ||
{ | ||
ArticlePageViewModel referenceViewModel = new() | ||
{ | ||
Title = string.Empty, | ||
Summary = HtmlString.Empty, | ||
Text = HtmlString.Empty, | ||
TeaserImage = new AssetViewModel(), | ||
Url = string.Empty | ||
}; | ||
Assert.Equal(referenceViewModel.Title, viewModel.Title); | ||
} | ||
|
||
[Fact] | ||
public void ViewModel_Initialized_TeaserIsNull() | ||
{ | ||
Assert.Null(viewModel.TeaserImage); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
test/TrainingGuides.Web.Tests/TrainingGuides.Web.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\TrainingGuides.Web\TrainingGuides.Web.csproj" /> | ||
<ProjectReference Include="..\TrainingGuides.Entities\TrainingGuides.Entities.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="coverlet.collector"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" /> | ||
<PackageReference Include="Moq" /> | ||
<PackageReference Include="xunit" /> | ||
<PackageReference Include="xunit.abstractions" /> | ||
<PackageReference Include="xunit.runner.visualstudio"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.