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
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.2.2" />
<PackageReference Include="MSTest.TestFramework" Version="3.2.2" />
<PackageReference Include="MSTest.TestAdapter" Version="3.3.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.3.1" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
4 changes: 2 additions & 2 deletions src/AD.FsCheck.MSTest.FsTests/VectorTest.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ with static member (+) (a, b) = { X = a.X + b.X; Y = a.Y + b.Y }
module Vector =
let plusIdentity = { X = 0; Y = 0}

[<Properties(MaxNbOfTest = 1000)>]
[<Properties(MaxTest = 1000)>]
type VectorTest () =

[<Property>]
Expand All @@ -39,7 +39,7 @@ type VectorSerializationTest () =
return vector
}

[<Property(MaxNbOfTest = 10)>]
[<Property(MaxTest = 10)>]
member _.```Serialize and deserialize`` expected : Task = task {
let! data = expected |> serialize
let! actual = data |> deserialize
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<IsPackable>false</IsPackable>
Expand All @@ -11,8 +11,8 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.2.2" />
<PackageReference Include="MSTest.TestFramework" Version="3.2.2" />
<PackageReference Include="MSTest.TestAdapter" Version="3.3.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.3.1" />
</ItemGroup>

<ItemGroup>
Expand Down
15 changes: 4 additions & 11 deletions src/AD.FsCheck.MSTest.Tests.Arbitraries/Arbitraries.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
namespace AD.FsCheck.MSTest.Tests.Arbitraries;

[TestClass]
public sealed class Arbitraries
public static class Arbitraries
{
public static Arbitrary<From100To200> From100To200Arbitrary() => Arb.From(
public static Arbitrary<From100To200> From100To200(Arbitrary<int> intArb) => Arb.From(
Gen.Choose(100, 200).Select(value => new From100To200(value)),
from100To200 => Arb.Shrink(from100To200.Value).Where(value => value >= 100 && value <= 200).Select(value => new From100To200(value)));

[AssemblyInitialize]
public static void Initialize(TestContext _)
{
Arb.Register<Arbitraries>();
}
}
from100To200 => intArb.Shrinker(from100To200.Value).Where(value => value >= 100 && value <= 200).Select(value => new From100To200(value)));
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[TestClass]
public sealed class From100To200Tests
{
[Property]
[Property(Arbitrary = [typeof(Arbitraries)])]
public void IsInRange(From100To200 x)
{
Assert.IsTrue(x.Value >= 100);
Expand Down
1 change: 1 addition & 0 deletions src/AD.FsCheck.MSTest.Tests.Arbitraries/_usings.cs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
global using FsCheck;
global using FsCheck.Fluent;
4 changes: 2 additions & 2 deletions src/AD.FsCheck.MSTest.Tests/AD.FsCheck.MSTest.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.2.2" />
<PackageReference Include="MSTest.TestFramework" Version="3.2.2" />
<PackageReference Include="MSTest.TestAdapter" Version="3.3.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.3.1" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@

#pragma warning disable IDE0060 // Remove unused parameter

[Properties(MaxNbOfTest = ClassMaxNbOfTest)]
public sealed class ClassAndMethodMaxNbOfTest : CommandLineTest
[Properties(MaxTest = ClassMaxTest)]
public sealed class ClassAndMethodMaxTest : CommandLineTest
{
const int ClassMaxNbOfTest = 20;
const int MethodMaxNbOfTest = 30;
const int ClassMaxTest = 20;
const int MethodMaxTest = 30;

public ClassAndMethodMaxNbOfTest() : base(nameof(ClassAndMethodMaxNbOfTest))
public ClassAndMethodMaxTest() : base(nameof(ClassAndMethodMaxTest))
{ }

[CommandLineProperty]
public void Class_is_inherited(int a)
{ }

[TestMethod]
public async Task Class_is_inherited_test() => AreEqual(ClassMaxNbOfTest, await AssertSuccess(nameof(Class_is_inherited)));
public async Task Class_is_inherited_test() => AreEqual(ClassMaxTest, await AssertSuccess(nameof(Class_is_inherited)));

[CommandLineProperty(MaxNbOfTest = MethodMaxNbOfTest)]
[CommandLineProperty(MaxTest = MethodMaxTest)]
public void Method_overrides_class(int a)
{ }

[TestMethod]
public async Task Method_overrides_class_test() => AreEqual(MethodMaxNbOfTest, await AssertSuccess(nameof(Method_overrides_class)));
public async Task Method_overrides_class_test() => AreEqual(MethodMaxTest, await AssertSuccess(nameof(Method_overrides_class)));
}

#pragma warning restore IDE0060 // Remove unused parameter
21 changes: 0 additions & 21 deletions src/AD.FsCheck.MSTest.Tests/ClassMaxNbOfTest.cs

This file was deleted.

21 changes: 21 additions & 0 deletions src/AD.FsCheck.MSTest.Tests/ClassMaxTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace AD.FsCheck.MSTest.Tests;

#pragma warning disable IDE0060 // Remove unused parameter

[Properties(MaxTest = MaxTest)]
public sealed class ClassMaxTest : CommandLineTest
{
const int MaxTest = 20;

public ClassMaxTest() : base(nameof(ClassMaxTest))
{ }

[CommandLineProperty]
public void Method(int a)
{ }

[TestMethod]
public async Task Method_test() => AreEqual(MaxTest, await AssertSuccess(nameof(Method)));
}

#pragma warning restore IDE0060 // Remove unused parameter
2 changes: 1 addition & 1 deletion src/AD.FsCheck.MSTest.Tests/DurationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public sealed class DurationTest : CommandLineTest
public DurationTest() : base(nameof(DurationTest))
{ }

[Property(MaxNbOfTest = NbOfTest)]
[Property(MaxTest = NbOfTest)]
public async Task Duration(int _) => await Task.Delay(Yield);

[TestMethod]
Expand Down
2 changes: 1 addition & 1 deletion src/AD.FsCheck.MSTest.Tests/InvokeErrorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void CannotGenerate(NotGeneratable _)
public async Task CannotGenerate_test()
{
var msg = await Run(nameof(CannotGenerate), Fetch.StdErr);
AreEqual($"The type {typeof(NotGeneratable).FullName} is not handled automatically by FsCheck. Consider using another type or writing and registering a generator for it.",
AreEqual($"The type {typeof(NotGeneratable).FullName} is not handled automatically by FsCheck. Consider using another type or writing a generator for it.",
msg);
}
}
21 changes: 0 additions & 21 deletions src/AD.FsCheck.MSTest.Tests/MethodMaxNbOfTest.cs

This file was deleted.

21 changes: 21 additions & 0 deletions src/AD.FsCheck.MSTest.Tests/MethodMaxTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace AD.FsCheck.MSTest.Tests;

#pragma warning disable IDE0060 // Remove unused parameter

[TestClass]
public sealed class MethodMaxTest : CommandLineTest
{
const int MaxTest = 30;

public MethodMaxTest() : base(nameof(MethodMaxTest))
{ }

[CommandLineProperty(MaxTest = MaxTest)]
public void Method(int a)
{ }

[TestMethod]
public async Task Method_test() => AreEqual(MaxTest, await AssertSuccess(nameof(Method)));
}

#pragma warning restore IDE0060 // Remove unused parameter
14 changes: 7 additions & 7 deletions src/AD.FsCheck.MSTest.Tests/ParametersTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void One_parameter(int a)
#region Two

[CommandLineProperty]
public void Two_parameters(int a, int b)
public void Two_parameters(int a, string b)
{ }

[TestMethod]
Expand All @@ -48,7 +48,7 @@ public void Two_parameters(int a, int b)
#region Three

[CommandLineProperty]
public void Three_parameters(int a, int b, int c)
public void Three_parameters(int a, string b, Guid c)
{ }

[TestMethod]
Expand All @@ -59,7 +59,7 @@ public void Three_parameters(int a, int b, int c)
#region Four

[CommandLineProperty]
public void Four_parameters(int a, int b, int c, int d)
public void Four_parameters(int a, string b, Guid c, double d)
{ }

[TestMethod]
Expand All @@ -70,7 +70,7 @@ public void Four_parameters(int a, int b, int c, int d)
#region Five

[CommandLineProperty]
public void Five_parameters(int a, int b, int c, int d, int e)
public void Five_parameters(int a, string b, Guid c, double d, decimal e)
{ }

[TestMethod]
Expand All @@ -81,7 +81,7 @@ public void Five_parameters(int a, int b, int c, int d, int e)
#region Six

[CommandLineProperty]
public void Six_parameters(int a, int b, int c, int d, int e, int f)
public void Six_parameters(int a, string b, Guid c, double d, decimal e, byte f)
{ }

[TestMethod]
Expand All @@ -92,7 +92,7 @@ public void Six_parameters(int a, int b, int c, int d, int e, int f)
#region Seven

[CommandLineProperty]
public void Seven_parameters(int a, int b, int c, int d, int e, int f, int g)
public void Seven_parameters(int a, string b, Guid c, double d, decimal e, byte f, DateTime g)
{ }

[TestMethod]
Expand All @@ -103,7 +103,7 @@ public void Seven_parameters(int a, int b, int c, int d, int e, int f, int g)
#region Eight

[CommandLineProperty]
public void Eight_parameters(int a, int b, int c, int d, int e, int f, int g, int h)
public void Eight_parameters(int a, string b, Guid c, double d, decimal e, byte f, DateTime g, char h)
{ }

[TestMethod]
Expand Down
4 changes: 2 additions & 2 deletions src/AD.FsCheck.MSTest.Tests/PropertiesReplayTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace AD.FsCheck.MSTest.Tests;

[Properties(Replay = "1561428431,297099475")]
[Properties(Replay = "10333802694858096737,13365262137747244545")]
public sealed class PropertiesReplayTest : CommandLineTest
{
public PropertiesReplayTest() : base(nameof(PropertiesReplayTest))
Expand All @@ -13,6 +13,6 @@ public PropertiesReplayTest() : base(nameof(PropertiesReplayTest))
public async Task Prop_test()
{
var msg = await Run(nameof(Prop), Fetch.StdErr);
IsTrue(msg.StartsWith("Falsifiable, after 28 tests (1 shrink) (StdGen (1561428431,297099475))"));
IsTrue(msg.StartsWith("Falsifiable, after 20 tests (2 shrinks) (10333802694858096737,13365262137747244545)"));
}
}
8 changes: 4 additions & 4 deletions src/AD.FsCheck.MSTest.Tests/PropertyReplayTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ public sealed class PropertyReplayTest : CommandLineTest
public PropertyReplayTest() : base(nameof(PropertyReplayTest))
{ }

[CommandLineProperty(Replay = "1561428431,297099475")]
[CommandLineProperty(Replay = "1358818329932720880,1613334182980143787")]
public void Prop1(int a) => IsTrue(a < 17);

[TestMethod]
public async Task Prop1_test() => await Run(nameof(Prop1));

[CommandLineProperty(Replay = " 1561428431 , 297099475 ")]
[CommandLineProperty(Replay = " 1358818329932720880 , 1613334182980143787 ")]
public void Prop2(int a) => IsTrue(a < 17);

[TestMethod]
public async Task Prop2_test() => await Run(nameof(Prop2));

[CommandLineProperty(Replay = "(1561428431,297099475)")]
[CommandLineProperty(Replay = "(1358818329932720880,1613334182980143787)")]
public void Prop3(int a) => IsTrue(a < 17);

[TestMethod]
Expand All @@ -27,6 +27,6 @@ public PropertyReplayTest() : base(nameof(PropertyReplayTest))
async Task Run(string testName)
{
var msg = await Run(testName, Fetch.StdErr);
IsTrue(msg.StartsWith("Falsifiable, after 28 tests (1 shrink) (StdGen (1561428431,297099475))"));
IsTrue(msg.StartsWith("Falsifiable, after 25 tests (3 shrinks) (1358818329932720880,1613334182980143787)"));
}
}
4 changes: 2 additions & 2 deletions src/AD.FsCheck.MSTest.Tests/ReplayPrecedenceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ public sealed class ReplayPrecedenceTest : CommandLineTest
public ReplayPrecedenceTest() : base(nameof(ReplayPrecedenceTest))
{ }

[CommandLineProperty(Replay = "1561428431,297099475")]
[CommandLineProperty(Replay = "5195330141687306492,9724345478383734501")]
public void Prop(int a) => IsTrue(a < 17);

[TestMethod]
public async Task Prop_test()
{
var msg = await Run(nameof(Prop), Fetch.StdErr);
IsTrue(msg.StartsWith("Falsifiable, after 28 tests (1 shrink) (StdGen (1561428431,297099475))"));
IsTrue(msg.StartsWith("Falsifiable, after 21 tests (2 shrinks) (5195330141687306492,9724345478383734501)"));
}
}
4 changes: 2 additions & 2 deletions src/AD.FsCheck.MSTest.Tests/VectorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public record Vector(int X, int Y)
public static Vector PlusIdentity { get; } = new(0, 0);
}

[Properties(MaxNbOfTest = 1000)]
[Properties(MaxTest = 1000)]
public sealed class VectorTest
{
[Property]
Expand All @@ -23,7 +23,7 @@ public sealed class VectorTest
[TestClass]
public sealed class VectorSerializationTest
{
[Property(MaxNbOfTest = 10)]
[Property(MaxTest = 10)]
public async Task Serialize_and_deserialize(Vector expected)
{
var actual = await Deserialize(await Serialize(expected));
Expand Down
Loading