Skip to content

Commit

Permalink
GH-74 :: add more Article unit tests - starter branch
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikag2 committed Oct 11, 2024
1 parent 72f0599 commit 966cca5
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ public ArticlePageServiceTests()
ArticlePagePublishDate = DateTime.Now
};

[Fact]
public async Task GetArticlePageViewModel_IfArticlePageNull_ReturnsEmptyModel()
{
var articlePageViewModel = await articlePageServiceMock.Object.GetArticlePageViewModel(null);
Assert.Equivalent(new ArticlePageViewModel(), articlePageViewModel);
}

[Fact]
public async Task GetArticlePageViewModel_ReturnsModel_WithArticleTitleSet()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Xunit;
using TrainingGuides.Web.Features.Articles.Widgets.ArticleList;
using TrainingGuides.Web.Features.Articles;

namespace TrainingGuides.Web.Tests.Features.Articles.Widgets.ArticleList;

public class ArticleListWidgetViewModelTests
{
private readonly ArticleListWidgetViewModel emptyWidgetViewModel;

public ArticleListWidgetViewModelTests()
{
emptyWidgetViewModel = new();
}

[Fact]
public void WhenInitialized_ArticlesIsEmptyList() => Assert.Empty(emptyWidgetViewModel.Articles);

[Fact]
public void WhenInitialized_CtaTextIsEmpty() => Assert.Equal(string.Empty, emptyWidgetViewModel.CtaText);

[Fact]
public void IsMisconfigured_When_ArticlesEmpty_ReturnsTrue() => Assert.True(emptyWidgetViewModel.IsMisconfigured);

[Fact]
public void IsMisconfigured_When_ArticlesContainItems_ReturnsFalse()
{
var widgetViewModel = new ArticleListWidgetViewModel();
widgetViewModel.Articles.Add(new ArticlePageViewModel());

Assert.False(widgetViewModel.IsMisconfigured);
}
}

0 comments on commit 966cca5

Please sign in to comment.