created test project
This commit is contained in:
parent
7e372791ee
commit
e6117d6b06
35
Wave.Tests/Utilities/ArticleUtilitiesTest.cs
Normal file
35
Wave.Tests/Utilities/ArticleUtilitiesTest.cs
Normal file
|
@ -0,0 +1,35 @@
|
|||
using NUnit.Framework.Constraints;
|
||||
using Wave.Data;
|
||||
using Wave.Utilities;
|
||||
|
||||
namespace Wave.Tests.Utilities;
|
||||
|
||||
[TestFixture]
|
||||
[TestOf(typeof(ArticleUtilities))]
|
||||
public class ArticleUtilitiesTest {
|
||||
|
||||
[Test]
|
||||
public void GenerateArticleLink() {
|
||||
var testArticle = new Article {
|
||||
Id = Guid.Parse("e7a94905-d83a-4146-8061-de2ef7869a82"),
|
||||
Title = "Test Article",
|
||||
Body = "This is the body of the test Article",
|
||||
Author = new ApplicationUser {
|
||||
UserName = "test@example.com",
|
||||
FullName = "Test User"
|
||||
},
|
||||
PublishDate = DateTimeOffset.MaxValue,
|
||||
Slug = "test-article"
|
||||
};
|
||||
|
||||
string linkWithoutPublishDate = ArticleUtilities.GenerateArticleLink(testArticle, null);
|
||||
Assert.That(linkWithoutPublishDate, Is.EqualTo("/article/e7a94905-d83a-4146-8061-de2ef7869a82"));
|
||||
|
||||
testArticle.PublishDate = new DateTimeOffset(new DateOnly(2024, 4, 24), TimeOnly.MinValue, TimeSpan.Zero);
|
||||
string linkWithPublishDate = ArticleUtilities.GenerateArticleLink(testArticle, null);
|
||||
Assert.That(linkWithPublishDate, Is.EqualTo("/2024/04/24/test-article"));
|
||||
|
||||
string testHttps = ArticleUtilities.GenerateArticleLink(testArticle, new Uri("http://example.com", UriKind.Absolute));
|
||||
Assert.That(testHttps, new StartsWithConstraint("https://"));
|
||||
}
|
||||
}
|
32
Wave.Tests/Wave.Tests.csproj
Normal file
32
Wave.Tests/Wave.Tests.csproj
Normal file
|
@ -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>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||
<PackageReference Include="NUnit" Version="3.14.0" />
|
||||
<PackageReference Include="NUnit.Analyzers" Version="3.9.0" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Wave\Wave.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="NUnit.Framework" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Utilities\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
6
Wave.sln
6
Wave.sln
|
@ -7,6 +7,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Wave", "Wave\Wave.csproj",
|
|||
EndProject
|
||||
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{FE5DA24A-8490-4DCE-BDFB-49C9CF656F8A}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wave.Tests", "Wave.Tests\Wave.Tests.csproj", "{54BFBF0E-5918-4830-BCDD-135BAD702529}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@ -21,6 +23,10 @@ Global
|
|||
{FE5DA24A-8490-4DCE-BDFB-49C9CF656F8A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FE5DA24A-8490-4DCE-BDFB-49C9CF656F8A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FE5DA24A-8490-4DCE-BDFB-49C9CF656F8A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{54BFBF0E-5918-4830-BCDD-135BAD702529}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{54BFBF0E-5918-4830-BCDD-135BAD702529}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{54BFBF0E-5918-4830-BCDD-135BAD702529}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{54BFBF0E-5918-4830-BCDD-135BAD702529}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
Loading…
Reference in a new issue