Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
<PackageVersion Include="FastEndpoints.ApiExplorer" Version="2.2.0" />
<PackageVersion Include="FastEndpoints.Swagger" Version="5.19.2" />
<PackageVersion Include="FastEndpoints.Swagger.Swashbuckle" Version="2.2.0" />
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
<PackageVersion Include="Flurl" Version="4.0.0" />
<PackageVersion Include="Flurl.Http" Version="4.0.2" />
<PackageVersion Include="GoogleReCaptcha.V3" Version="1.3.1" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using System;
using DevBetterWeb.Core.Entities;
using DevBetterWeb.Core.Enums;
using FluentAssertions;
using FluentAssertions.Execution;
using Shouldly;
using Xunit;

namespace DevBetterWeb.UnitTests.Core.Entities.MemberTests;
Expand All @@ -21,13 +20,10 @@ public void AddsBillingActivityGivenRequiredParameters()

var billingActivity = member.BillingActivities[0];

using (new AssertionScope())
{
billingActivity.Details.SubscriptionPlanName.Should().Be(subscriptionPlanName);
billingActivity.Details.ActionVerbPastTense.Should().Be(actionVerb);
billingActivity.Details.BillingPeriod.Should().Be(billingPeriod);
billingActivity.Details.MemberName.Should().Be(member.UserFullName());
}
billingActivity.Details.SubscriptionPlanName.ShouldBe(subscriptionPlanName);
billingActivity.Details.ActionVerbPastTense.ShouldBe(actionVerb);
billingActivity.Details.BillingPeriod.ShouldBe(billingPeriod);
billingActivity.Details.MemberName.ShouldBe(member.UserFullName());
}

[Fact]
Expand All @@ -44,10 +40,7 @@ public void AddsBillingActivityGivenMessageAndAmount()

var billingActivity = member.BillingActivities[0];

using (new AssertionScope())
{
billingActivity.Details.BillingPeriod.Should().Be(billingPeriod);
billingActivity.Details.Amount.Should().Be(amount);
}
billingActivity.Details.BillingPeriod.ShouldBe(billingPeriod);
billingActivity.Details.Amount.ShouldBe(amount);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Linq;
using DevBetterWeb.Core.Entities;
using FluentAssertions;
using FluentAssertions.Execution;
using Shouldly;
using Xunit;

namespace DevBetterWeb.UnitTests.Core.Entities.MemberTests;
Expand All @@ -22,11 +21,8 @@ public void ShouldAddFavoriteArchiveVideoGivenArchiveVideo()

member.AddFavoriteArchiveVideo(archiveVideo);

using (new AssertionScope())
{
member.FavoriteArchiveVideos.Single().ArchiveVideoId.Should().Be(_validArchiveVideoId);
member.FavoriteArchiveVideos.Single().MemberId.Should().Be(member.Id);
}
member.FavoriteArchiveVideos.Single().ArchiveVideoId.ShouldBe(_validArchiveVideoId);
member.FavoriteArchiveVideos.Single().MemberId.ShouldBe(member.Id);
}

[Fact]
Expand All @@ -42,6 +38,6 @@ public void ShouldDoNothingGivenDuplicateArchiveVideo()
member.AddFavoriteArchiveVideo(archiveVideo);
member.AddFavoriteArchiveVideo(archiveVideo);

member.FavoriteArchiveVideos.Count().Should().Be(1);
member.FavoriteArchiveVideos.Count().ShouldBe(1);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Linq;
using DevBetterWeb.Core.Entities;
using FluentAssertions;
using Shouldly;
using Xunit;

namespace DevBetterWeb.UnitTests.Core.Entities.MemberTests;
Expand All @@ -26,7 +26,7 @@ public void ShouldDoNothingGivenFavoriteArchiveVideoNotInFavoriteArchiveVideos()
};
member.RemoveFavoriteArchiveVideo(nonexistingArchiveVideo);

member.FavoriteArchiveVideos.Count().Should().Be(expectedCount);
member.FavoriteArchiveVideos.Count().ShouldBe(expectedCount);
}

[Fact]
Expand All @@ -39,8 +39,8 @@ public void ShouldRemoveFavoriteArchiveVideoGivenExistingFavoriteArchiveVideo()
};
member.AddFavoriteArchiveVideo(archiveVideo);

member.RemoveFavoriteArchiveVideo(archiveVideo);
member.RemoveFavoriteArchiveVideo(archiveVideo);

member.FavoriteArchiveVideos.Should().BeEmpty();
member.FavoriteArchiveVideos.ShouldBeEmpty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using DevBetterWeb.Core.Events;
using DevBetterWeb.Core.ValueObjects;
using DevBetterWeb.UnitTests.Core.Entities;
using FluentAssertions;
using Shouldly;
using Xunit;

namespace DevBetterWeb.UnitTests.Core.Events;
Expand All @@ -28,24 +28,24 @@ public void ShouldSetValues()
{
var sut = new BillingActivityCreatedEvent(_billingActivity, _member);

sut.DateOccurred.Should().NotBe(default);
sut.Member.Should().Be(_member);
sut.BillingActivity.Should().Be(_billingActivity);
sut.DateOccurred.ShouldNotBe(default);
sut.Member.ShouldBe(_member);
sut.BillingActivity.ShouldBe(_billingActivity);
}

[Fact]
public void ShouldThrowExceptionWhenBillingActivityIsNull()
{
var action = () => new BillingActivityCreatedEvent(null!, _member);

action.Should().Throw<ArgumentNullException>();
action.ShouldThrow<ArgumentNullException>();
}

[Fact]
public void ShouldThrowExceptionWhenMemberIsNull()
{
var action = () => new BillingActivityCreatedEvent(_billingActivity, null!);

action.Should().Throw<ArgumentNullException>();
action.ShouldThrow<ArgumentNullException>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using DevBetterWeb.Core.Entities;
using DevBetterWeb.Core.Events;
using DevBetterWeb.UnitTests.Core.Entities;
using FluentAssertions;
using Shouldly;
using Xunit;

namespace DevBetterWeb.UnitTests.Core.Events;
Expand All @@ -17,23 +17,23 @@ public void ShouldSetValues()
{
var sut = new SubscriptionAddedEvent(_member, _memberSubscription);

sut.Member.Should().Be(_member);
sut.MemberSubscription.Should().Be(_memberSubscription);
sut.Member.ShouldBe(_member);
sut.MemberSubscription.ShouldBe(_memberSubscription);
}

[Fact]
public void ShouldThrowExceptionWhenMemberIsNull()
{
var action = () => new SubscriptionAddedEvent(null!, _memberSubscription);

action.Should().Throw<ArgumentNullException>();
action.ShouldThrow<ArgumentNullException>();
}

[Fact]
public void ShouldThrowExceptionWhenMemberSubscriptionIsNull()
{
var action = () => new SubscriptionAddedEvent(_member, null!);

action.Should().Throw<ArgumentNullException>();
action.ShouldThrow<ArgumentNullException>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using DevBetterWeb.Core.Entities;
using DevBetterWeb.Core.Events;
using DevBetterWeb.UnitTests.Core.Entities;
using FluentAssertions;
using Shouldly;
using Xunit;

namespace DevBetterWeb.UnitTests.Core.Events;
Expand All @@ -17,23 +17,23 @@ public void ShouldSetValues()
{
var sut = new SubscriptionUpdatedEvent(_member, _memberSubscription);

sut.Member.Should().Be(_member);
sut.MemberSubscription.Should().Be(_memberSubscription);
sut.Member.ShouldBe(_member);
sut.MemberSubscription.ShouldBe(_memberSubscription);
}

[Fact]
public void ShouldThrowExceptionWhenMemberIsNull()
{
var action = () => new SubscriptionUpdatedEvent(null!, _memberSubscription);

action.Should().Throw<ArgumentNullException>();
action.ShouldThrow<ArgumentNullException>();
}

[Fact]
public void ShouldThrowExceptionWhenMemberSubscriptionIsNull()
{
var action = () => new SubscriptionUpdatedEvent(_member, null!);

action.Should().Throw<ArgumentNullException>();
action.ShouldThrow<ArgumentNullException>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Linq;
using DevBetterWeb.Core.Entities;
using DevBetterWeb.Core.Specs;
using FluentAssertions;
using Shouldly;
using Xunit;

namespace DevBetterWeb.UnitTests.Core.Specs;
Expand Down Expand Up @@ -44,7 +44,7 @@ public void ReturnsUnfilteredListGivenNullSearchExpression()

var result = sut.Evaluate(_archiveVideos);

result.Should().HaveCount(_archiveVideos.Count());
result.Count().ShouldBe(_archiveVideos.Count());
}

[Theory]
Expand All @@ -61,7 +61,7 @@ public void ReturnsFilteredListGivenSearchExpression(string search, int expected

var result = sut.Evaluate(_archiveVideos);

result.Should().HaveCount(expectedCount);
result.Count().ShouldBe(expectedCount);
}

[Theory]
Expand All @@ -80,7 +80,7 @@ public void ReturnsFilteredListGivenSkipExpression(int skip, int expectedCount)

var result = sut.Evaluate(_archiveVideos);

result.Should().HaveCount(expectedCount);
result.Count().ShouldBe(expectedCount);
}

[Theory]
Expand All @@ -99,6 +99,6 @@ public void ReturnsFilteredListGivenSizeExpression(int size, int expectedCount)

var result = sut.Evaluate(_archiveVideos);

result.Should().HaveCount(expectedCount);
result.Count().ShouldBe(expectedCount);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using DevBetterWeb.Core.ValueObjects;
using FluentAssertions;
using FluentAssertions.Execution;
using Shouldly;
using Xunit;

namespace DevBetterWeb.UnitTests.Core.ValueObjects;
Expand All @@ -15,10 +14,7 @@ public void SetValuesGivenMemberIdAndArchiveVideoId()
{
var memberFavoriteArchiveVideo = new MemberFavoriteArchiveVideo(_validMemberId, _validArchiveVideoId);

using (new AssertionScope())
{
memberFavoriteArchiveVideo.ArchiveVideoId.Should().Be(_validArchiveVideoId);
memberFavoriteArchiveVideo.MemberId.Should().Be(_validMemberId);
}
memberFavoriteArchiveVideo.ArchiveVideoId.ShouldBe(_validArchiveVideoId);
memberFavoriteArchiveVideo.MemberId.ShouldBe(_validMemberId);
}
}
2 changes: 1 addition & 1 deletion tests/DevBetterWeb.UnitTests/DevBetterWeb.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentAssertions" />
<PackageReference Include="Microsoft.Extensions.Identity.Core" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="NSubstitute" />
<PackageReference Include="Shouldly" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
using DevBetterWeb.Infrastructure.Services;
using Microsoft.Extensions.Logging;
using NSubstitute;
using Shouldly;
using Xunit;
using FluentAssertions;

namespace DevBetterWeb.UnitTests.Infrastructure.Services;

Expand Down Expand Up @@ -34,7 +34,7 @@ public void Parse_ValidJson_WorksAsExpected()

var actualResult = this._jsonParserService.Parse(validJson);

expectedResult.Should().BeEquivalentTo(actualResult, opt => opt.ComparingByMembers<JsonElement>());
actualResult.RootElement.GetProperty("Name").GetString().ShouldBeEquivalentTo(expectedResult.RootElement.GetProperty("Name").GetString());
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using System.Collections.Generic;
using FluentAssertions;
using Flurl.Http.Testing;
using NSubstitute;
using Xunit;
using DevBetterWeb.Web.Interfaces;
using DevBetterWeb.Web.Services;
using NimblePros.Vimeo.Models;
using System.Threading.Tasks;
using Shouldly;

namespace DevBetterWeb.UnitTests.Web.Services;

Expand All @@ -24,7 +24,7 @@ public async Task GetTranscript_Returns_Empty_String_When_No_TextTracks()

var result = await videoDetailsService.GetTranscriptAsync(textTracks, "https://it-does-not-matter-for-this-test.com");

result.Should().BeEmpty();
result.ShouldBeEmpty();
}

[Fact]
Expand All @@ -38,6 +38,6 @@ public async Task GetTranscript_Returns_Empty_String_When_TextTrackLink_Is_Inval

var result = await videoDetailsService.GetTranscriptAsync(textTracks, "https://it-does-not-matter-for-this-test.com");

result.Should().BeEmpty();
result.ShouldBeEmpty();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Xunit;
using FluentAssertions;
using DevBetterWeb.Web.Services;
using Shouldly;

namespace DevBetterWeb.UnitTests.Web.Services;

Expand Down Expand Up @@ -37,6 +37,6 @@ get people invited.

var actual = new WebVTTParsingService().Parse(vtt, "https://devbetter.com/Videos/Details/1234");

actual.Should().Be(expected);
actual.ShouldBe(expected);
}
}
Loading