Skip to content

Commit

Permalink
Optional: Update the tests to NUnit v4
Browse files Browse the repository at this point in the history
  • Loading branch information
andreise committed Feb 14, 2024
1 parent 6c76e7d commit 3d71a1d
Show file tree
Hide file tree
Showing 81 changed files with 540 additions and 540 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ partial class AbsentStaticTestsBase<T>
public void Comparison_Compare_OfAndDefault_ExpectTrue()
{
var actual = Absent.Compare(Absent.Of<T>(), default(Absent<T>));
Assert.Zero(actual);
Assert.That(actual, Is.Zero);
}

[Test]
public void Comparison_Compare_OfAndNew_ExpectTrue()
{
var actual = Absent.Compare(new Absent<T>(), default(Absent<T>));
Assert.Zero(actual);
Assert.That(actual, Is.Zero);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ partial class AbsentStaticTestsBase<T>
public void Equality_Equals_OfAndDefault_ExpectTrue()
{
var actual = Absent.Equals(Absent.Of<T>(), default(Absent<T>));
Assert.True(actual);
Assert.That(actual, Is.True);
}

[Test]
public void Equality_Equals_OfAndNew_ExpectTrue()
{
var actual = Absent.Equals(Absent.Of<T>(), new Absent<T>());
Assert.True(actual);
Assert.That(actual, Is.True);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ partial class AbsentStaticTestsBase<T>
[Test]
public void Factory_Of_ExpectEqualToDefault()
{
Assert.AreEqual(default(Absent<T>), Absent.Of<T>());
Assert.That(Absent.Of<T>(), Is.EqualTo(default(Absent<T>)));
}

[Test]
public void Factory_Of_ExpectEqualToNew()
{
Assert.AreEqual(new Absent<T>(), Absent.Of<T>());
Assert.That(Absent.Of<T>(), Is.EqualTo(new Absent<T>()));
}

[Test]
public void Factory_Of_ExpectEqualToValue()
{
Assert.AreEqual(Absent<T>.Value, Absent.Of<T>());
Assert.That(Absent.Of<T>(), Is.EqualTo(Absent<T>.Value));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,69 +9,69 @@ partial class AbsentTestsBase<T>
public void Comparison_Compare_NewAndDefault_ExpectZero()
{
var actual = Absent<T>.Compare(new Absent<T>(), default);
Assert.Zero(actual);
Assert.That(actual, Is.Zero);
}

[Test]
public void Comparison_Compare_ValueAndDefault_ExpectZero()
{
var actual = Absent<T>.Compare(Absent<T>.Value, default);
Assert.Zero(actual);
Assert.That(actual, Is.Zero);
}

[Test]
public void Comparison_LessThanOrEqualToOperator_NewAndDefault_ExpectTrue()
{
var actual = new Absent<T>() <= default(Absent<T>);
Assert.True(actual);
Assert.That(actual, Is.True);
}

[Test]
public void Comparison_LessThanOrEqualToOperator_ValueAndDefault_ExpectTrue()
{
var actual = Absent<T>.Value <= default(Absent<T>);
Assert.True(actual);
Assert.That(actual, Is.True);
}

[Test]
public void Comparison_GreaterThanOrEqualToOperator_NewAndDefault_ExpectTrue()
{
var actual = new Absent<T>() >= default(Absent<T>);
Assert.True(actual);
Assert.That(actual, Is.True);
}

[Test]
public void Comparison_GreaterThanOrEqualToOperator_ValueAndDefault_ExpectTrue()
{
var actual = Absent<T>.Value >= default(Absent<T>);
Assert.True(actual);
Assert.That(actual, Is.True);
}

[Test]
public void Comparison_LessThanOperator_NewAndDefault_ExpectFalse()
{
var actual = new Absent<T>() < default(Absent<T>);
Assert.False(actual);
Assert.That(actual, Is.False);
}

[Test]
public void Comparison_LessThanOperator_ValueAndDefault_ExpectFalse()
{
var actual = Absent<T>.Value < default(Absent<T>);
Assert.False(actual);
Assert.That(actual, Is.False);
}

[Test]
public void Comparison_GreaterThanOperator_NewAndDefault_ExpectFalse()
{
var actual = new Absent<T>() > default(Absent<T>);
Assert.False(actual);
Assert.That(actual, Is.False);
}

[Test]
public void Comparison_GreaterThanOperator_ValueAndDefault_ExpectFalse()
{
var actual = Absent<T>.Value > default(Absent<T>);
Assert.False(actual);
Assert.That(actual, Is.False);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,44 @@ partial class AbsentTestsBase<T>
public void Comparison_CompareTo_NewAndDefault_ExpectZero()
{
var actual = new Absent<T>().CompareTo(default);
Assert.Zero(actual);
Assert.That(actual, Is.Zero);
}

[Test]
public void Comparison_CompareTo_ValueAndDefault_ExpectZero()
{
var actual = Absent<T>.Value.CompareTo(default);
Assert.Zero(actual);
Assert.That(actual, Is.Zero);
}

[Test]
public void Comparison_CompareToObj_NewAndNull_ExpectOne()
{
var actual = new Absent<T>().CompareTo(null);
Assert.Positive(actual);
Assert.AreEqual(1, actual);
Assert.That(actual, Is.Positive);
Assert.That(actual, Is.EqualTo(1));
}

[Test]
public void Comparison_CompareToObj_ValueAndNull_ExpectOne()
{
var actual = Absent<T>.Value.CompareTo(null);
Assert.Positive(actual);
Assert.AreEqual(1, actual);
Assert.That(actual, Is.Positive);
Assert.That(actual, Is.EqualTo(1));
}

[Test]
public void Comparison_CompareToObj_NewAndDefault_ExpectZero()
{
var actual = new Absent<T>().CompareTo((object?)default(Absent<T>));
Assert.Zero(actual);
Assert.That(actual, Is.Zero);
}

[Test]
public void Comparison_CompareToObj_ValueAndDefault_ExpectZero()
{
var actual = Absent<T>.Value.CompareTo((object?)new Absent<T>());
Assert.Zero(actual);
Assert.That(actual, Is.Zero);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,41 @@ partial class AbsentTestsBase<T>
public void Equality_Static_Equals_NewAndDefault_ExpectTrue()
{
var actual = Absent<T>.Equals(new Absent<T>(), default);
Assert.True(actual);
Assert.That(actual, Is.True);
}

[Test]
public void Equality_Static_Equals_ValueAndDefault_ExpectTrue()
{
var actual = Absent<T>.Equals(Absent<T>.Value, default);
Assert.True(actual);
Assert.That(actual, Is.True);
}

[Test]
public void Equality_Static_EqualityOperator_NewAndDefault_ExpectTrue()
{
var actual = new Absent<T>() == default;
Assert.True(actual);
Assert.That(actual, Is.True);
}

[Test]
public void Equality_Static_EqualityOperator_ValueAndDefault_ExpectTrue()
{
var actual = Absent<T>.Value == default;
Assert.True(actual);
Assert.That(actual, Is.True);
}

[Test]
public void Equality_Static_InequalityOperator_NewAndDefault_ExpectFalse()
{
var actual = new Absent<T>() != default;
Assert.False(actual);
Assert.That(actual, Is.False);
}

[Test]
public void Equality_Static_InequalityOperator_ValueAndDefault_ExpectFalse()
{
var actual = Absent<T>.Value != default;
Assert.False(actual);
Assert.That(actual, Is.False);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ partial class AbsentTestsBase<T>
public void Equality_Equals_NewAndDefault_ExpectTrue()
{
var actual = new Absent<T>().Equals(default);
Assert.True(actual);
Assert.That(actual, Is.True);
}

[Test]
public void Equality_Equals_ValueAndDefault_ExpectTrue()
{
var actual = Absent<T>.Value.Equals(default);
Assert.True(actual);
Assert.That(actual, Is.True);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ partial class AbsentTestsBase<T>
[Test]
public void Factory_New_ExpectDefault()
{
Assert.AreEqual(default(Absent<T>), new Absent<T>());
Assert.That(new Absent<T>(), Is.EqualTo(default(Absent<T>)));
}

[Test]
public void Factory_Value_ExpectDefault()
{
Assert.AreEqual(default(Absent<T>), Absent<T>.Value);
Assert.That(Absent<T>.Value, Is.EqualTo(default(Absent<T>)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,43 @@ public void ToOptionalExplicit_FromDefault_ExpectAbsent()
{
var optional = default(Absent<T>).ToOptional();

Assert.IsTrue(optional.IsAbsent);
Assert.That(optional.IsAbsent, Is.True);
}
[Test]
public void ToOptionalImplicit_FromDefault_ExpectAbsent()
{
Optional<T> optional = default(Absent<T>);

Assert.IsTrue(optional.IsAbsent);
Assert.That(optional.IsAbsent, Is.True);
}

[Test]
public void ToOptionalExplicit_FromNew_ExpectAbsent()
{
var optional = new Absent<T>().ToOptional();

Assert.IsTrue(optional.IsAbsent);
Assert.That(optional.IsAbsent, Is.True);
}
[Test]
public void ToOptionalImplicit_FromNew_ExpectAbsent()
{
Optional<T> optional = new Absent<T>();

Assert.IsTrue(optional.IsAbsent);
Assert.That(optional.IsAbsent, Is.True);
}

[Test]
public void ToOptionalExplicit_FromValue_ExpectAbsent()
{
var optional = Absent<T>.Value.ToOptional();

Assert.IsTrue(optional.IsAbsent);
Assert.That(optional.IsAbsent, Is.True);
}
[Test]
public void ToOptionalImplicit_FromValue_ExpectAbsent()
{
Optional<T> optional = Absent<T>.Value;

Assert.IsTrue(optional.IsAbsent);
Assert.That(optional.IsAbsent, Is.True);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ public void ToString_ExpectAbsentFormat()

var expected = string.Format("Absent<{0}>:()", typeof(T).Name);

Assert.AreEqual(expected, actual);
Assert.That(actual, Is.EqualTo(expected));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public void FilterNotNull_Class_SourceValueIsNotNull_ExpectSource()
var source = Optional<RefType?>.Present(PlusFifteenIdRefType);

var actual = FilterNotNullOptionalExtensions.FilterNotNull(source);
Assert.AreEqual(source, actual);
Assert.That(actual, Is.EqualTo(source));
}

[Test]
Expand All @@ -22,8 +22,8 @@ public void FilterNotNull_Struct_SourceValueIsNotNull_ExpectSource()
var source = Optional<int?>.Present(PlusFifteen);

var actual = FilterNotNullOptionalExtensions.FilterNotNull(source);
Assert.True(actual.IsPresent);
Assert.AreEqual(source.OrThrow()!.Value, actual.OrThrow());
Assert.That(actual.IsPresent, Is.True);
Assert.That(actual.OrThrow(), Is.EqualTo(source.OrThrow()!.Value));
}

[Test]
Expand All @@ -34,7 +34,7 @@ public void FilterNotNull_SourceValueIsNull_ExpectAbsent()
var actual = FilterNotNullOptionalExtensions.FilterNotNull(source);
var expected = Optional<RefType?>.Absent;

Assert.AreEqual(expected, actual);
Assert.That(actual, Is.EqualTo(expected));
}

[Test]
Expand All @@ -46,7 +46,7 @@ public void FilterNotNull_SourceValueIsNotNullRefType_ExpectNotNullableRefTypePr
var actual = FilterNotNullOptionalExtensions.FilterNotNull(source);
var expected = Optional<RefType>.Present(sourceValue);

Assert.AreEqual(expected, actual);
Assert.That(actual, Is.EqualTo(expected));
}

[Test]
Expand All @@ -57,7 +57,7 @@ public void FilterNotNull_SourceValueIsNullRefType_ExpectNotNullableRefTypeAbsen
var actual = FilterNotNullOptionalExtensions.FilterNotNull(source);
var expected = Optional<RefType>.Absent;

Assert.AreEqual(expected, actual);
Assert.That(actual, Is.EqualTo(expected));
}

[Test]
Expand All @@ -69,7 +69,7 @@ public void FilterNotNull_SourceValueIsNotNullStructType_ExpectNotNullableStruct
var actual = FilterNotNullOptionalExtensions.FilterNotNull(source);
var expected = Optional<StructType>.Present(sourceValue);

Assert.AreEqual(expected, actual);
Assert.That(actual, Is.EqualTo(expected));
}

[Test]
Expand All @@ -80,6 +80,6 @@ public void FilterNotNull_SourceValueIsNullStructType_ExpectNotNullableStructTyp
var actual = FilterNotNullOptionalExtensions.FilterNotNull(source);
var expected = Optional<StructType>.Absent;

Assert.AreEqual(expected, actual);
Assert.That(actual, Is.EqualTo(expected));
}
}
Loading

0 comments on commit 3d71a1d

Please sign in to comment.