Update FluentAssertions

This commit is contained in:
Stepan Goremykin 2023-03-18 23:05:46 +01:00 committed by Mark McDowall
parent fd5d279a9e
commit 951a9ade00
10 changed files with 37 additions and 33 deletions

View File

@ -49,7 +49,7 @@ namespace NzbDrone.Common.Test.DiskTests
.Setup(s => s.GetDirectoryInfos(It.IsAny<string>()))
.Returns(_folders);
Subject.LookupContents(root, false, false).Directories.Should().NotContain(Path.Combine(root, RECYCLING_BIN));
Subject.LookupContents(root, false, false).Directories.Should().NotContain(dir => dir.Path == Path.Combine(root, RECYCLING_BIN));
}
[Test]
@ -62,7 +62,7 @@ namespace NzbDrone.Common.Test.DiskTests
.Setup(s => s.GetDirectoryInfos(It.IsAny<string>()))
.Returns(_folders);
Subject.LookupContents(root, false, false).Directories.Should().NotContain(Path.Combine(root, SYSTEM_VOLUME_INFORMATION));
Subject.LookupContents(root, false, false).Directories.Should().NotContain(dir => dir.Path == Path.Combine(root, SYSTEM_VOLUME_INFORMATION));
}
[Test]

View File

@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@ -584,7 +583,7 @@ namespace NzbDrone.Common.Test.DiskTests
var count = Subject.MirrorFolder(source.FullName, destination.FullName);
count.Should().Equals(0);
count.Should().Be(0);
destination.GetFileSystemInfos().Should().BeEmpty();
}
@ -604,7 +603,7 @@ namespace NzbDrone.Common.Test.DiskTests
var count = Subject.MirrorFolder(source.FullName, destination.FullName);
count.Should().Equals(0);
count.Should().Be(0);
destination.GetFileSystemInfos().Should().HaveCount(1);
}
@ -621,7 +620,7 @@ namespace NzbDrone.Common.Test.DiskTests
var count = Subject.MirrorFolder(source.FullName, destination.FullName);
count.Should().Equals(3);
count.Should().Be(3);
VerifyCopyFolder(original.FullName, destination.FullName);
}
@ -638,7 +637,7 @@ namespace NzbDrone.Common.Test.DiskTests
var count = Subject.MirrorFolder(source.FullName, destination.FullName);
count.Should().Equals(3);
count.Should().Be(3);
File.Exists(Path.Combine(destination.FullName, _nfsFile)).Should().BeFalse();
}
@ -658,7 +657,7 @@ namespace NzbDrone.Common.Test.DiskTests
var count = Subject.MirrorFolder(source.FullName, destination.FullName);
count.Should().Equals(0);
count.Should().Be(0);
VerifyCopyFolder(original.FullName, destination.FullName);
}
@ -675,7 +674,7 @@ namespace NzbDrone.Common.Test.DiskTests
var count = Subject.MirrorFolder(source.FullName + Path.DirectorySeparatorChar, destination.FullName);
count.Should().Equals(3);
count.Should().Be(3);
VerifyCopyFolder(original.FullName, destination.FullName);
}

View File

@ -120,7 +120,7 @@ namespace NzbDrone.Common.Test.TPLTests
Subject.WaitAndPulse("me", "sub", TimeSpan.FromMilliseconds(100));
(GetRateLimitStore()["me"] - _epoch).Should().BeCloseTo(TimeSpan.FromMilliseconds(200));
(GetRateLimitStore()["me"] - _epoch).Should().BeCloseTo(TimeSpan.FromMilliseconds(200), TimeSpan.FromMilliseconds(20));
}
}
}

View File

@ -13,6 +13,7 @@ namespace NzbDrone.Core.Test.Datastore
[TestFixture]
public class BasicRepositoryFixture : DbTest<BasicRepository<ScheduledTask>, ScheduledTask>
{
private readonly TimeSpan _dateTimePrecision = TimeSpan.FromMilliseconds(20);
private List<ScheduledTask> _basicList;
[SetUp]
@ -20,7 +21,7 @@ namespace NzbDrone.Core.Test.Datastore
{
AssertionOptions.AssertEquivalencyUsing(options =>
{
options.Using<DateTime>(ctx => ctx.Subject.Should().BeCloseTo(ctx.Expectation.ToUniversalTime())).WhenTypeIs<DateTime>();
options.Using<DateTime>(ctx => ctx.Subject.Should().BeCloseTo(ctx.Expectation.ToUniversalTime(), _dateTimePrecision)).WhenTypeIs<DateTime>();
return options;
});

View File

@ -96,7 +96,10 @@ namespace NzbDrone.Core.Test.Datastore.Migration
var series = db.Query<Series69>("SELECT Tags FROM Series");
series.Should().HaveCount(1);
series.First().Tags.Should().BeEquivalentTo(tag.Id);
var actualTags = series.First().Tags;
var expectedTags = Enumerable.Repeat(tag.Id, actualTags.Count);
actualTags.Should().Equal(expectedTags);
}
}
}

View File

@ -28,8 +28,8 @@ namespace NzbDrone.Core.Test.Datastore.Migration
var items = profiles.First().Items;
items.Should().HaveCount(4);
items.Select(v => v.Quality).Should().BeEquivalentTo(1, 16, 18, 19);
items.Select(v => v.Allowed).Should().BeEquivalentTo(true, false, false, false);
items.Select(v => v.Quality).Should().Equal(1, 16, 18, 19);
items.Select(v => v.Allowed).Should().Equal(true, false, false, false);
}
}
}

View File

@ -33,9 +33,9 @@ namespace NzbDrone.Core.Test.Datastore.Migration
var items = profiles.First().Items;
items.Should().HaveCount(6);
items.Select(v => v.Quality).Should().BeEquivalentTo(1, null, null, null, null, null);
items.Select(v => v.Items.Count).Should().BeEquivalentTo(0, 2, 2, 2, 2, 2);
items.Select(v => v.Allowed).Should().BeEquivalentTo(true, false, false, false, false, false);
items.Select(v => v.Quality).Should().Equal(1, null, null, null, null, null);
items.Select(v => v.Items.Count).Should().Equal(0, 2, 2, 2, 2, 2);
items.Select(v => v.Allowed).Should().Equal(true, false, false, false, false, false);
}
[Test]
@ -56,9 +56,9 @@ namespace NzbDrone.Core.Test.Datastore.Migration
var items = profiles.First().Items;
items.Should().HaveCount(6);
items.Select(v => v.Quality).Should().BeEquivalentTo(1, null, null, null, null, null);
items.Select(v => v.Items.Count).Should().BeEquivalentTo(0, 2, 2, 2, 2, 2);
items.Select(v => v.Allowed).Should().BeEquivalentTo(true, false, false, false, false, false);
items.Select(v => v.Quality).Should().Equal(1, null, null, null, null, null);
items.Select(v => v.Items.Count).Should().Equal(0, 2, 2, 2, 2, 2);
items.Select(v => v.Allowed).Should().Equal(true, false, false, false, false, false);
}
[Test]
@ -79,9 +79,9 @@ namespace NzbDrone.Core.Test.Datastore.Migration
var items = profiles.First().Items;
items.Should().HaveCount(6);
items.Select(v => v.Quality).Should().BeEquivalentTo(1, null, null, null, null, null);
items.Select(v => v.Items.Count).Should().BeEquivalentTo(0, 2, 2, 2, 2, 2);
items.Select(v => v.Allowed).Should().BeEquivalentTo(true, false, false, false, false, false);
items.Select(v => v.Quality).Should().Equal(1, null, null, null, null, null);
items.Select(v => v.Items.Count).Should().Equal(0, 2, 2, 2, 2, 2);
items.Select(v => v.Allowed).Should().Equal(true, false, false, false, false, false);
}
[Test]

View File

@ -27,9 +27,9 @@ namespace NzbDrone.Core.Test.Datastore.Migration
var items = profiles.First().Items;
items.Should().HaveCount(4);
items.Select(v => v.Quality).Should().BeEquivalentTo(7, 20, 19, 21);
items.Select(v => v.Allowed).Should().BeEquivalentTo(true, false, true, false);
items.Select(v => v.Name).Should().BeEquivalentTo(null, null, null, (string)null);
items.Select(v => v.Quality).Should().Equal(7, 20, 19, 21);
items.Select(v => v.Allowed).Should().Equal(true, false, true, false);
items.Select(v => v.Name).Should().Equal(null, null, null, null);
}
[Test]
@ -50,9 +50,9 @@ namespace NzbDrone.Core.Test.Datastore.Migration
var items = profiles.First().Items;
items.Should().HaveCount(4);
items.Select(v => v.Quality).Should().BeEquivalentTo(null, 20, 19, 21);
items.Select(v => v.Allowed).Should().BeEquivalentTo(true, false, true, false);
items.Select(v => v.Name).Should().BeEquivalentTo("Why?!", null, null, null);
items.Select(v => v.Quality).Should().Equal(null, 20, 19, 21);
items.Select(v => v.Allowed).Should().Equal(true, false, true, false);
items.Select(v => v.Name).Should().Equal("Why?!", null, null, null);
}
}
}

View File

@ -34,6 +34,7 @@ namespace NzbDrone.Core.Test.ThingiProviderTests
public class ProviderStatusServiceFixture : CoreTest<MockProviderStatusService>
{
private readonly TimeSpan _disabledTillPrecision = TimeSpan.FromMilliseconds(500);
private DateTime _epoch;
[SetUp]
@ -90,7 +91,7 @@ namespace NzbDrone.Core.Test.ThingiProviderTests
var status = Subject.GetBlockedProviders().FirstOrDefault();
status.Should().NotBeNull();
status.DisabledTill.Should().HaveValue();
status.DisabledTill.Value.Should().BeCloseTo(_epoch + TimeSpan.FromMinutes(5), 500);
status.DisabledTill.Value.Should().BeCloseTo(_epoch + TimeSpan.FromMinutes(5), _disabledTillPrecision);
}
[Test]
@ -133,7 +134,7 @@ namespace NzbDrone.Core.Test.ThingiProviderTests
var status = Subject.GetBlockedProviders().FirstOrDefault();
status.Should().NotBeNull();
status.DisabledTill.Should().HaveValue();
status.DisabledTill.Value.Should().BeCloseTo(_epoch + TimeSpan.FromMinutes(15), 500);
status.DisabledTill.Value.Should().BeCloseTo(_epoch + TimeSpan.FromMinutes(15), _disabledTillPrecision);
}
[Test]
@ -160,7 +161,7 @@ namespace NzbDrone.Core.Test.ThingiProviderTests
status.Should().NotBeNull();
origStatus.EscalationLevel.Should().Be(3);
status.DisabledTill.Should().BeCloseTo(_epoch + TimeSpan.FromMinutes(5), 500);
status.DisabledTill.Should().BeCloseTo(_epoch + TimeSpan.FromMinutes(5), _disabledTillPrecision);
}
}
}

View File

@ -3,7 +3,7 @@
<TargetFrameworks>net6.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="FluentAssertions" Version="6.10.0" />
<PackageReference Include="FluentValidation" Version="8.6.2" />
<PackageReference Include="Moq" Version="4.18.4" />
<PackageReference Include="NLog" Version="4.7.14" />