diff --git a/src/Testing.Commons.NUnit.Tests.old/ArrangingTestTester.cs b/src/Testing.Commons.NUnit.Tests.old/ArrangingTestTester.cs deleted file mode 100644 index 9569ff4..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/ArrangingTestTester.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System; -using NSubstitute; -using NUnit.Framework; -using Testing.Commons.NUnit.Tests.Subjects; - -namespace Testing.Commons.NUnit.Tests -{ - public class ArrangingTestTester : ArrangingTest - { - private static int COUNTER; - - protected override string initSubject() - { - COUNTER++; - return "subject"; - } - - [Test] - public void Subject_IsInitialized() - { - Assert.That(Subject, Is.EqualTo("subject")); - } - - [Test] - public void ArrangingMethod_InvokedBeforeThisTest() { } - - [Test] - public void ArrangingMethod_AndBeforeThisTest() { } - - [OneTimeTearDown] - public void AfterAllTestAreRun() - { - Assert.That(COUNTER, Is.EqualTo(3), "run for every test in the fixture"); - } - } - - public class UsefulWhenDealingWithSubjectsWithMockableDependencies : ArrangingTest - { - // dependencies go into fields for test to access them - private IDependencyOne _one; - private IDependencyTwo _two; - - protected override ISubjectWithDependencies initSubject() - { - // dependencies are initialized inside the arrange method - _one = Substitute.For(); - _two = Substitute.For(); - - return new SubjectWithDependencies(_one, _two); - } - - [Test] - public void DoSomethingWithOne_InvokesDependencyOne() - { - // Act - Subject.DoSomethingWithOne(); - - // Assert - _one.Received().DoSomething(); - } - - [Test] - public void DoSomethingWithOne_InvokesDependencyTwo() - { - // Act - Subject.DoSomethingWithTwo(); - - // Assert - _two.Received().DoSomethingElse(); - } - - [Test] - public void DoSomethingWithBoth_InvokesDependencyTwo() - { - // Act - Subject.DosomethingWithBoth(); - - // Assert - _one.Received().DoSomething(); - _two.Received().DoSomethingElse(); - } - - [Test] - public void IndividualTests_CanOverrideDependencyBehavior() - { - // init the subject in a custom method - initSubjectWith((IDependencyTwo)null); - - // no expectation on a strict mock makes the mock throw - - Assert.That(() => Subject.DoSomethingWithTwo(), Throws.InstanceOf()); - } - - private void initSubjectWith(IDependencyTwo dependencyTwo) - { - Subject = new SubjectWithDependencies(_one, dependencyTwo); - } - } -} diff --git a/src/Testing.Commons.NUnit.Tests.old/Constraints/BinarySerializationConstraintTester.net.cs b/src/Testing.Commons.NUnit.Tests.old/Constraints/BinarySerializationConstraintTester.net.cs deleted file mode 100644 index 684b773..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Constraints/BinarySerializationConstraintTester.net.cs +++ /dev/null @@ -1,96 +0,0 @@ -using NUnit.Framework; -using NUnit.Framework.Internal; -using Testing.Commons.NUnit.Constraints; -using Testing.Commons.NUnit.Constraints.Support; -using Testing.Commons.NUnit.Tests.Constraints.Subjects; -using Testing.Commons.Serialization; - -namespace Testing.Commons.NUnit.Tests.Constraints -{ - [TestFixture] - public class BinarySerializationConstraintTester : ConstraintTesterBase - { - #region ApplyTo - - [Test] - public void ApplyTo_MatchingSerializable_True() - { - var serializable = new Serializable { D = 3m, S = "s" }; - var subject = new SerializationConstraint(new BinaryRoundtripSerializer(), - Is.Not.SameAs(serializable) - .And.Property("S").EqualTo("s") - .And.Property("D").EqualTo(3m)); - - Assert.That(matches(subject, serializable), Is.True); - } - - [Test] - public void ApplyTo_NonSerializable_False() - { - var nonSerializable = new NonSerializable("s"); - var subject = new SerializationConstraint(new BinaryRoundtripSerializer(), Is.Not.Null); - - Assert.That(matches(subject, nonSerializable), Is.False); - } - - [Test] - public void ApplyTo_NonMatchingSerializable_False() - { - var serializable = new Serializable { D = 3m, S = "s" }; - var subject = new SerializationConstraint(new BinaryRoundtripSerializer(), - Is.Not.SameAs(serializable) - .And.Property("S").EqualTo("sS") - .And.Property("D").EqualTo(3m)); - - Assert.That(matches(subject, serializable), Is.False); - } - - #endregion - - #region WriteMessageTo - - [Test] - public void WriteMessageTo_NonSerializable_ExpectedContainsConstraintExpectations_ActualContainsExpectationsErrorPlusObject() - { - var nonSerializable = new NonSerializable("s"); - var subject = new SerializationConstraint(new BinaryRoundtripSerializer(), Is.Not.Null); - - Assert.That(getMessage(subject, nonSerializable), Does - .StartWith(TextMessageWriter.Pfx_Expected + "Deserialized object not null").And - .Contains(TextMessageWriter.Pfx_Actual + "Could not serialize/deserialize object")); - } - - [Test] - public void WriteMessageTo_NonMatchingSerializable_ActualContainsOffendingValueAndActualObject() - { - var serializable = new Serializable { D = 3m, S = "s" }; - var subject = new SerializationConstraint(new BinaryRoundtripSerializer(), - Is.Not.SameAs(serializable) - .And.Property("S").EqualTo("sS") - .And.Property("D").EqualTo(3m)); - - Assert.That(getMessage(subject, serializable), Does.Contain(TextMessageWriter.Pfx_Actual + "\"s\"").And - .Contains(" -> <" + typeof(Serializable).FullName + ">")); - } - - #endregion - - [Test] - public void CanBeNewedUp() - { - Assert.That(new Serializable { D = 3m, S = "s" }, - new SerializationConstraint(new BinaryRoundtripSerializer(), - Has.Property("S").EqualTo("s") - .And.Property("D").EqualTo(3m))); - } - - [Test] - public void CanBeCreatedWithExtension() - { - Assert.That(new Serializable { D = 3m, S = "s" }, - Must.Be.BinarySerializable( - Has.Property("S").EqualTo("s") - .And.Property("D").EqualTo(3m))); - } - } -} \ No newline at end of file diff --git a/src/Testing.Commons.NUnit.Tests.old/Constraints/ConjuctionContraintTester.cs b/src/Testing.Commons.NUnit.Tests.old/Constraints/ConjuctionContraintTester.cs deleted file mode 100644 index 6ea9b7e..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Constraints/ConjuctionContraintTester.cs +++ /dev/null @@ -1,151 +0,0 @@ -using NUnit.Framework; -using NUnit.Framework.Constraints; -using NUnit.Framework.Internal; -using Testing.Commons.NUnit.Constraints; -using Testing.Commons.NUnit.Constraints.Support; -using Testing.Commons.NUnit.Tests.Subjects; - -namespace Testing.Commons.NUnit.Tests.Constraints -{ - [TestFixture] - public class ConjuctionContraintTester : ConstraintTesterBase - { - #region ApplyTo - - [Test] - public void ApplyTo_PassingConstraint_Success() - { - var subject = new ConjunctionConstraint( - Is.GreaterThan(1), - Is.GreaterThan(5)); - - Assert.That(matches(subject, 6), Is.True); - - Assert.That(getMessage(subject, 6), Is.Empty); - } - - [Test] - public void ApplyTo_FailingConstraint_Failure() - { - var subject = new ConjunctionConstraint( - Is.GreaterThan(1), - Is.GreaterThan(5)); - - Assert.That(matches(subject, 4), Is.False); - } - - [Test] - public void ApplyTo_NoConstraints_Success() - { - var subject = new ConjunctionConstraint(); - - Assert.That(matches(subject, new object()), Is.True); - } - - [Test] - public void ApplyTo_EmptyConstraints_Success() - { - var subject = new ConjunctionConstraint(new Constraint[0]); - - Assert.That(matches(subject, new object()), Is.True); - } - - [Test] - public void ApplyTo_AllNullContraints_Success() - { - var subject = new ConjunctionConstraint(null, null); - - Assert.That(matches(subject, new object()), Is.True); - } - - [Test] - public void ApplyTo_SingleFailingConstraints_Failure() - { - var subject = new ConjunctionConstraint( - Is.GreaterThan(5)); - - Assert.That(matches(subject, 4), Is.False); - } - - [Test] - public void ApplyTo_SinglePassingConstraints_Success() - { - var subject = new ConjunctionConstraint( - Is.GreaterThan(5)); - - Assert.That(matches(subject, 6), Is.True); - } - - #endregion - - #region WriteMessageTo - - [Test] - public void WriteMessageTo_FailingConstraint_ContainsConjuctionOfConstraints() - { - var subject = new ConjunctionConstraint( - Is.GreaterThan(1), - Is.GreaterThan(5)); - - Assert.That(getMessage(subject, 4), Does.StartWith( - TextMessageWriter.Pfx_Expected + "greater than 1 and greater than 5")); - } - - [Test] - public void WriteMessageTo_SingleFailingConstraint_ContainsConstraints() - { - var subject = new ConjunctionConstraint( - Is.GreaterThan(5)); - - Assert.That(getMessage(subject, 4), Does.StartWith(TextMessageWriter.Pfx_Expected + "greater than 5")); - } - - [Test] - public void WriteMessageTo_FailingConstraint_ContainsSpecificOffender() - { - var subject = new ConjunctionConstraint( - Is.GreaterThan(1), - Is.GreaterThan(5)); - - Assert.That(getMessage(subject, 4), Does.Contain("Specifically: greater than 5")); - } - - [Test] - public void WriteMessageTo_SingleFailingConstraint_ContainsTheOffender() - { - var subject = new ConjunctionConstraint( - Is.GreaterThan(5)); - - Assert.That(getMessage(subject, 4), Does.Contain("Specifically: greater than 5")); - } - - [Test] - public void WriteMessageTo_FailingConstraint_ActualContainsActual() - { - var subject = new ConjunctionConstraint( - Is.GreaterThan(1), - Is.GreaterThan(5)); - - Assert.That(getMessage(subject, 4), - Does.Contain(TextMessageWriter.Pfx_Actual + "4") - ); - } - - [Test] - public void WriteMessageTo_FailingConstraintThatEvaluatesAMember_ActualConstainsActualAndMember() - { - var customer = new FlatCustomer { Name = "name", PhoneNumber = "123456" }; - var nameConstraint = Must.Have.Property(nameof(FlatCustomer.Name), Is.EqualTo("name")); - var subject = Must.Satisfy.Conjunction( - Must.Have.Property(nameof(FlatCustomer.Name), Does.Contain("me")), - Must.Have.Property(nameof(FlatCustomer.PhoneNumber), Does.Contain("-")), - Is.Not.Null); - - Assert.That(customer, nameConstraint); - Assert.That(getMessage(subject, customer), Does.Contain(typeof(FlatCustomer).Name).And - .Contains("123456")); - } - - #endregion - } -} \ No newline at end of file diff --git a/src/Testing.Commons.NUnit.Tests.old/Constraints/ConstrainedEnumerableTester.cs b/src/Testing.Commons.NUnit.Tests.old/Constraints/ConstrainedEnumerableTester.cs deleted file mode 100644 index 1f1653d..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Constraints/ConstrainedEnumerableTester.cs +++ /dev/null @@ -1,136 +0,0 @@ -using NSubstitute; -using NUnit.Framework; -using NUnit.Framework.Constraints; -using NUnit.Framework.Internal; -using Testing.Commons.NUnit.Constraints; -using Testing.Commons.NUnit.Constraints.Support; - -namespace Testing.Commons.NUnit.Tests.Constraints -{ - [TestFixture] - public class ConstrainedEnumerableTester : ConstraintTesterBase - { - #region ApplyTo - - [Test] - public void ApplyTo_SubjectHasLessItemsThanConstraintsProvided_Failure() - { - var subject = new ConstrainedEnumerable(Is.EqualTo(1), Is.EqualTo(2)); - - Assert.That(matches(subject, new[] { 1 }), Is.False); - } - - [Test] - public void ApplyTo_SubjectHasMoreItemsThanConstraintsProvided_Failure() - { - var subject = new ConstrainedEnumerable(Is.EqualTo(1)); - - Assert.That(matches(subject, new[] { 1, 2 }), Is.False); - } - - [Test] - public void Apply_FirstItemDoesNotMatchConstraint_False() - { - var subject = new ConstrainedEnumerable(Is.GreaterThan(0), Is.EqualTo(2)); - - Assert.That(matches(subject, new[] { -1, 2 }), Is.False); - } - - [Test] - public void ApplyTo_FirstItemDoesNotMatchConstraint_SubsequentConstraintsNotEvaluated() - { - Constraint failing = Substitute.For(), - notEvaluated = Substitute.For(); - - var subject = new ConstrainedEnumerable(failing, notEvaluated); - failing.ApplyTo(-1).Returns(new ConstraintResult(null, null, false)); - - subject.ApplyTo(new[] { -1, 2 }); - - notEvaluated.DidNotReceive().ApplyTo(Arg.Any()); - } - - [Test] - public void ApplyTo_SecondItemDoesNotMatchConstraint_False() - { - var subject = new ConstrainedEnumerable(Is.EqualTo(1), Is.EqualTo(2), Is.EqualTo(3)); - - Assert.That(matches(subject, new[] { 1, -2, 3 }), Is.False); - } - - [Test] - public void apply_SecondItemDoesNotMatchConstraint_SubsequentConstraintsNotEvaluated() - { - Constraint - passing = Substitute.For(), - failing = Substitute.For(), - notEvaluated = Substitute.For(); - - var subject = new ConstrainedEnumerable(failing, notEvaluated); - passing.ApplyTo(1).Returns(new ConstraintResult(null, null, false)); - failing.ApplyTo(-2).Returns(new ConstraintResult(null, null, false)); - - subject.ApplyTo(new[] { 1, -2, 3 }); - - notEvaluated.DidNotReceive().ApplyTo(Arg.Any()); - } - - #endregion - - #region WriteMessageTo - - [Test] - public void WriteMessageTo_SubjectHasLessItemsThanConstraintsProvided_ExpectedIsLengthOfSubjectAndActualIsNumberOfConstraints() - { - var subject = new ConstrainedEnumerable(Is.EqualTo(1), Is.EqualTo(2)); - - Assert.That(getMessage(subject, new[] { 1 }), - Does.Contain(TextMessageWriter.Pfx_Expected + 1).And - .Contains(TextMessageWriter.Pfx_Actual + 2)); - } - - [Test] - public void WriteMessageTo_SubjectHasMoreItemsThanConstraintsProvided_ExpectedIsLengthOfSubjectAndActualIsNumberOfConstraints() - { - var subject = new ConstrainedEnumerable(Is.EqualTo(1)); - - Assert.That(getMessage(subject, new[] { 1, 2 }), - Does.Contain(TextMessageWriter.Pfx_Expected + 2).And - .Contains(TextMessageWriter.Pfx_Actual + 1)); - } - - [Test] - public void WriteMessageTo_FirstItemDoesNotMatchConstraint_DescriptionContainsIndexOfFailingItem_ExpectedIsOfFailingConstraint_ActualIsValueOfOffendingItem() - { - var subject = new ConstrainedEnumerable(Is.GreaterThan(0), Is.EqualTo(2)); - - Assert.That(getMessage(subject, new[] { -1, 2 }), Does.Contain("# 0").And - .Contain(TextMessageWriter.Pfx_Expected + "greater than 0").And - .Contains(TextMessageWriter.Pfx_Actual + "-1")); - } - - [Test] - public void WriteMessageTo_SecondItemDoesNotMatchConstraint_DescriptionContainsIndexOfFailingItem_ExpectedIsOfFailingConstraint_ActualIsValueOfOffendingItem() - { - var subject = new ConstrainedEnumerable(Is.EqualTo('1'), Is.GreaterThan('3')); - - Assert.That(getMessage(subject, new[] { '1', '2' }), Does.Contain("# 1").And - .Contain(TextMessageWriter.Pfx_Expected + "greater than '3'").And - .Contains(TextMessageWriter.Pfx_Actual + "'2'")); - } - - #endregion - - [Test] - public void CanBeNewedUp() - { - Assert.That(new[] { 1, 2 }, new ConstrainedEnumerable(Is.EqualTo(1), Is.LessThan(3))); - } - - [Test] - public void CanBeCreatedWithExtension() - { - Assert.That(new[] { 1, 2 }, Must.Be.Constrained(Is.EqualTo(1), Is.LessThan(3))); - } - } -} \ No newline at end of file diff --git a/src/Testing.Commons.NUnit.Tests.old/Constraints/DataContractDeserializationConstraintTester.cs b/src/Testing.Commons.NUnit.Tests.old/Constraints/DataContractDeserializationConstraintTester.cs deleted file mode 100644 index 2e904b6..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Constraints/DataContractDeserializationConstraintTester.cs +++ /dev/null @@ -1,99 +0,0 @@ -using NUnit.Framework; -using NUnit.Framework.Internal; -using Testing.Commons.NUnit.Constraints; -using Testing.Commons.NUnit.Constraints.Support; -using Testing.Commons.NUnit.Tests.Constraints.Subjects; -using Testing.Commons.Serialization; - -namespace Testing.Commons.NUnit.Tests.Constraints -{ - [TestFixture] - public class DataContractDeserializationConstraintTester : ConstraintTesterBase - { - #region ApplyTo - - [Test] - public void ApplyTo_MatchingDeserialized_True() - { - var matching = Serializable.DataContractString("s", 3m); - var subject = new DeserializationConstraint( - new DataContractDeserializer(), - Has.Property("S").EqualTo("s") - .And.Property("D").EqualTo(3m)); - - Assert.That(matches(subject, matching), Is.True); - } - - [Test] - public void ApplyTo_NonSerialized_False() - { - var nonSerializable = ""; - var subject = new DeserializationConstraint( - new DataContractDeserializer(), Is.Not.Null); - - Assert.That(matches(subject, nonSerializable), Is.False); - } - - [Test] - public void ApplyTo_NonMatching_False() - { - var nonMatching = Serializable.DataContractString("s", 3m); - var subject = new DeserializationConstraint( - new DataContractDeserializer(), - Has.Property("S").EqualTo("sS") - .And.Property("D").EqualTo(3m)); - - Assert.That(matches(subject, nonMatching), Is.False); - } - - #endregion - - #region WriteMessageTo - - [Test] - public void WriteMessageTo_NonSerialized_ExpectedContainsConstraintExpectations_ActualContainsExpectationsErrorPlusObject() - { - var nonSerializable = ""; - var subject = new DeserializationConstraint( - new DataContractDeserializer(), Is.Not.Null); - - Assert.That(getMessage(subject, nonSerializable), Does - .StartWith(TextMessageWriter.Pfx_Expected + "Deserialized object not null").And - .Contains(TextMessageWriter.Pfx_Actual + "Could not deserialize object")); - } - - [Test] - public void WriteMessageTo_NonMatching_ActualContainsOffendingValueAmdActualObject() - { - var nonMatching = Serializable.DataContractString("s", 3m); - var subject = new DeserializationConstraint( - new DataContractDeserializer(), - Has.Property("S").EqualTo("sS") - .And.Property("D").EqualTo(3m)); - - Assert.That(getMessage(subject, nonMatching), Does.Contain(TextMessageWriter.Pfx_Actual + "\"s\"").And - .Contains(" -> <" + typeof(Serializable).FullName + ">")); - } - - #endregion - - [Test] - public void CanBeNewedUp() - { - Assert.That(Serializable.DataContractString("s", 3m), - new DeserializationConstraint( - new DataContractDeserializer(), - Has.Property("S").EqualTo("s") - .And.Property("D").EqualTo(3m))); - } - - [Test] - public void CanBeCreatedWithExtension() - { - Assert.That(Serializable.DataContractString("s", 3m), - Must.Be.DataContractDeserializable( - Has.Property("S").EqualTo("s") - .And.Property("D").EqualTo(3m))); - } - } -} \ No newline at end of file diff --git a/src/Testing.Commons.NUnit.Tests.old/Constraints/DataContractJsonDeserializationConstraintTester.net.cs b/src/Testing.Commons.NUnit.Tests.old/Constraints/DataContractJsonDeserializationConstraintTester.net.cs deleted file mode 100644 index 96522d4..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Constraints/DataContractJsonDeserializationConstraintTester.net.cs +++ /dev/null @@ -1,99 +0,0 @@ -using NUnit.Framework; -using NUnit.Framework.Internal; -using Testing.Commons.NUnit.Constraints; -using Testing.Commons.NUnit.Constraints.Support; -using Testing.Commons.NUnit.Tests.Constraints.Subjects; -using Testing.Commons.Serialization; - -namespace Testing.Commons.NUnit.Tests.Constraints -{ - [TestFixture] - public class DataContractJsonDeserializationConstraintTester : ConstraintTesterBase - { - #region ApplyTo - - [Test] - public void ApplyTo_MatchingDeserialized_True() - { - var matching = Serializable.DataContractJsonString("s", 3m); - var subject = new DeserializationConstraint( - new DataContractJsonDeserializer(), - Has.Property("S").EqualTo("s") - .And.Property("D").EqualTo(3m)); - - Assert.That(matches(subject, matching), Is.True); - } - - [Test] - public void ApplyTo_NonSerialized_False() - { - var nonSerializable = ""; - var subject = new DeserializationConstraint( - new DataContractJsonDeserializer(), Is.Not.Null); - - Assert.That(matches(subject, nonSerializable), Is.False); - } - - [Test] - public void ApplyTo_NonMatching_False() - { - var nonMatching = Serializable.DataContractJsonString("s", 3m); - var subject = new DeserializationConstraint( - new DataContractJsonDeserializer(), - Has.Property("S").EqualTo("sS") - .And.Property("D").EqualTo(3m)); - - Assert.That(matches(subject, nonMatching), Is.False); - } - - #endregion - - #region WriteMessageTo - - [Test] - public void WriteMessageTo_NonSerialized_ExpectedContainsConstraintExpectations_ActualContainsExpectationsErrorPlusObject() - { - var nonSerializable = ""; - var subject = new DeserializationConstraint( - new DataContractJsonDeserializer(), Is.Not.Null); - - Assert.That(getMessage(subject, nonSerializable), Does - .StartWith(TextMessageWriter.Pfx_Expected + "Deserialized object not null").And - .Contains(TextMessageWriter.Pfx_Actual + "Could not deserialize object")); - } - - [Test] - public void WriteMessageTo_NonMatching_ActualContainsOffendingValueAndActualObject() - { - var nonMatching = Serializable.DataContractJsonString("s", 3m); - var subject = new DeserializationConstraint( - new DataContractJsonDeserializer(), - Has.Property("S").EqualTo("sS") - .And.Property("D").EqualTo(3m)); - - Assert.That(getMessage(subject, nonMatching), Does.Contain(TextMessageWriter.Pfx_Actual + "\"s\"").And - .Contain(" -> <" + typeof(Serializable).FullName + ">")); - } - - #endregion - - [Test] - public void CanBeNewedUp() - { - Assert.That(Serializable.DataContractJsonString("s", 3m), - new DeserializationConstraint( - new DataContractJsonDeserializer(), - Has.Property("S").EqualTo("s") - .And.Property("D").EqualTo(3m))); - } - - [Test] - public void CanBeCreatedWithExtension() - { - Assert.That(Serializable.DataContractJsonString("s", 3m), - Must.Be.DataContractJsonDeserializable( - Has.Property("S").EqualTo("s") - .And.Property("D").EqualTo(3m))); - } - } -} \ No newline at end of file diff --git a/src/Testing.Commons.NUnit.Tests.old/Constraints/DataContractJsonSerializationConstraintTester.net.cs b/src/Testing.Commons.NUnit.Tests.old/Constraints/DataContractJsonSerializationConstraintTester.net.cs deleted file mode 100644 index 38003d4..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Constraints/DataContractJsonSerializationConstraintTester.net.cs +++ /dev/null @@ -1,96 +0,0 @@ -using NUnit.Framework; -using NUnit.Framework.Internal; -using Testing.Commons.NUnit.Constraints; -using Testing.Commons.NUnit.Constraints.Support; -using Testing.Commons.NUnit.Tests.Constraints.Subjects; -using Testing.Commons.Serialization; - -namespace Testing.Commons.NUnit.Tests.Constraints -{ - [TestFixture] - public class DataContractJsonSerializationConstraintTester : ConstraintTesterBase - { - #region ApplyTo - - [Test] - public void ApplyTo_MatchingSerializable_True() - { - var serializable = new Serializable { D = 3m, S = "s" }; - var subject = new SerializationConstraint(new DataContractJsonRoundtripSerializer(), - Is.Not.SameAs(serializable) - .And.Property("S").EqualTo("s") - .And.Property("D").EqualTo(3m)); - - Assert.That(matches(subject, serializable), Is.True); - } - - [Test] - public void ApplyTo_NonSerializable_False() - { - var nonSerializable = new NonSerializable("s"); - var subject = new SerializationConstraint(new DataContractJsonRoundtripSerializer(), Is.Not.Null); - - Assert.That(matches(subject, nonSerializable), Is.False); - } - - [Test] - public void ApplyTo_NonMatchingSerializable_False() - { - var serializable = new Serializable { D = 3m, S = "s" }; - var subject = new SerializationConstraint(new DataContractJsonRoundtripSerializer(), - Is.Not.SameAs(serializable) - .And.Property("S").EqualTo("sS") - .And.Property("D").EqualTo(3m)); - - Assert.That(matches(subject, serializable), Is.False); - } - - #endregion - - #region WriteMessageTo - - [Test] - public void WriteMessageTo_NonSerializable_ExpectedContainsConstraintExpectations_ActualContainsExpectationsErrorPlusObject() - { - var nonSerializable = new NonSerializable("s"); - var subject = new SerializationConstraint(new DataContractJsonRoundtripSerializer(), Is.Not.Null); - - Assert.That(getMessage(subject, nonSerializable), Does - .StartWith(TextMessageWriter.Pfx_Expected + "Deserialized object not null").And - .Contains(TextMessageWriter.Pfx_Actual + "Could not serialize/deserialize object")); - } - - [Test] - public void WriteMessageTo_NonMatchingSerializable_ActualContainsOffendingValueAndActualObject() - { - var serializable = new Serializable { D = 3m, S = "s" }; - var subject = new SerializationConstraint(new DataContractJsonRoundtripSerializer(), - Is.Not.SameAs(serializable) - .And.Property("S").EqualTo("sS") - .And.Property("D").EqualTo(3m)); - - Assert.That(getMessage(subject, serializable), Does.Contain(TextMessageWriter.Pfx_Actual + "\"s\"").And - .Contains(" -> <" + typeof(Serializable).FullName + ">")); - } - - #endregion - - [Test] - public void CanBeNewedUp() - { - Assert.That(new Serializable { D = 3m, S = "s" }, - new SerializationConstraint(new DataContractJsonRoundtripSerializer(), - Has.Property("S").EqualTo("s") - .And.Property("D").EqualTo(3m))); - } - - [Test] - public void CanBeCreatedWithExtension() - { - Assert.That(new Serializable { D = 3m, S = "s" }, - Must.Be.DataContractJsonSerializable( - Has.Property("S").EqualTo("s") - .And.Property("D").EqualTo(3m))); - } - } -} \ No newline at end of file diff --git a/src/Testing.Commons.NUnit.Tests.old/Constraints/DataContractSerializationConstraintTester.cs b/src/Testing.Commons.NUnit.Tests.old/Constraints/DataContractSerializationConstraintTester.cs deleted file mode 100644 index bc5624a..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Constraints/DataContractSerializationConstraintTester.cs +++ /dev/null @@ -1,96 +0,0 @@ -using NUnit.Framework; -using NUnit.Framework.Internal; -using Testing.Commons.NUnit.Constraints; -using Testing.Commons.NUnit.Constraints.Support; -using Testing.Commons.NUnit.Tests.Constraints.Subjects; -using Testing.Commons.Serialization; - -namespace Testing.Commons.NUnit.Tests.Constraints -{ - [TestFixture] - public class DataContractSerializationConstraintTester : ConstraintTesterBase - { - #region ApplyTo - - [Test] - public void ApplyTo_MatchingSerializable_True() - { - var serializable = new Serializable { D = 3m, S = "s" }; - var subject = new SerializationConstraint(new DataContractRoundtripSerializer(), - Is.Not.SameAs(serializable) - .And.Property("S").EqualTo("s") - .And.Property("D").EqualTo(3m)); - - Assert.That(matches(subject,serializable), Is.True); - } - - [Test] - public void ApplyTo_NonSerializable_False() - { - var nonSerializable = new NonSerializable("s"); - var subject = new SerializationConstraint(new DataContractRoundtripSerializer(), Is.Not.Null); - - Assert.That(matches(subject,nonSerializable), Is.False); - } - - [Test] - public void ApplyTo_NonMatchingSerializable_False() - { - var serializable = new Serializable { D = 3m, S = "s" }; - var subject = new SerializationConstraint(new DataContractRoundtripSerializer(), - Is.Not.SameAs(serializable) - .And.Property("S").EqualTo("sS") - .And.Property("D").EqualTo(3m)); - - Assert.That(matches(subject,serializable), Is.False); - } - - #endregion - - #region WriteMessageTo - - [Test] - public void WriteMessageTo_NonSerializable_ExpectedContainsConstraintExpectations_ActualContainsExpectationsErrorPlusObject() - { - var nonSerializable = new NonSerializable("s"); - var subject = new SerializationConstraint(new DataContractRoundtripSerializer(), Is.Not.Null); - - Assert.That(getMessage(subject, nonSerializable), Does - .StartWith(TextMessageWriter.Pfx_Expected + "Deserialized object not null").And - .Contains(TextMessageWriter.Pfx_Actual + "Could not serialize/deserialize object")); - } - - [Test] - public void WriteMessageTo_NonMatchingSerializable_ActualContainsOffendingValueAndActualObject() - { - var serializable = new Serializable { D = 3m, S = "s" }; - var subject = new SerializationConstraint(new DataContractRoundtripSerializer(), - Is.Not.SameAs(serializable) - .And.Property("S").EqualTo("sS") - .And.Property("D").EqualTo(3m)); - - Assert.That(getMessage(subject, serializable), Does.Contain(TextMessageWriter.Pfx_Actual + "\"s\"").And - .Contains(" -> <" + typeof(Serializable).FullName + ">")); - } - - #endregion - - [Test] - public void CanBeNewedUp() - { - Assert.That(new Serializable { D = 3m, S = "s" }, - new SerializationConstraint(new DataContractRoundtripSerializer(), - Has.Property("S").EqualTo("s") - .And.Property("D").EqualTo(3m))); - } - - [Test] - public void CanBeCreatedWithExtension() - { - Assert.That(new Serializable { D = 3m, S = "s" }, - Must.Be.DataContractSerializable( - Has.Property("S").EqualTo("s") - .And.Property("D").EqualTo(3m))); - } - } -} \ No newline at end of file diff --git a/src/Testing.Commons.NUnit.Tests.old/Constraints/DateConstraintsTester.cs b/src/Testing.Commons.NUnit.Tests.old/Constraints/DateConstraintsTester.cs deleted file mode 100644 index e2b602b..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Constraints/DateConstraintsTester.cs +++ /dev/null @@ -1,110 +0,0 @@ -using System; -using NUnit.Framework; -using Testing.Commons.NUnit.Constraints; -using Testing.Commons.Time; - -namespace Testing.Commons.NUnit.Tests.Constraints -{ - [TestFixture] - public class DateConstraintsTester - { - private DateTime Today { get; set; } - private DateTime Yesterday { get; set; } - private DateTime Tomorrow { get; set; } - - [OneTimeSetUp] - public void Setup() - { - Today = DateTime.Today; - Tomorrow = Today.AddDays(1); - Yesterday = Today.AddDays(-1); - } - - #region Exploratory - - [Test] - public void Date_Comparisons() - { - Assert.That(Tomorrow, Must.Be.After(Today)); - - Assert.That(Yesterday, Must.Be.Before(Today)); - - Assert.That(Today, Must.Be.OnOrAfter(Today)); - Assert.That(Tomorrow, Must.Be.OnOrAfter(Today)); - - Assert.That(Today, Must.Be.OnOrBefore(Today)); - Assert.That(Yesterday, Must.Be.OnOrBefore(Today)); - } - - [Test] - public void Time_Comparisons() - { - DateTime nearbyPastTime = Today.Add(-Closeness.Default); - DateTime nearbyFutureTime = Today.Add(Closeness.Default); - - Assert.That(Today, Must.Be.CloseTo(nearbyPastTime)); - Assert.That(Today, Must.Be.CloseTo(nearbyFutureTime)); - - nearbyPastTime = Today.Add(-35.Milliseconds()); - nearbyFutureTime = Today.Add(35.Milliseconds()); - - Assert.That(Today, Must.Be.CloseTo(nearbyPastTime, ms: 35)); - Assert.That(Today, Must.Be.CloseTo(nearbyPastTime, within: 35.Milliseconds())); - Assert.That(Today, Must.Be.CloseTo(nearbyFutureTime, ms: 35)); - Assert.That(Today, Must.Be.CloseTo(nearbyFutureTime, within: 35.Milliseconds())); - } - - [Test] - public void Negative_Date_Comparisons() - { - Assert.That(Yesterday, Must.Not.Be.After(Today)); - Assert.That(Tomorrow, Must.Not.Be.Before(Today)); - Assert.That(Yesterday, Must.Not.Be.OnOrAfter(Today)); - Assert.That(Tomorrow, Must.Not.Be.OnOrBefore(Today)); - } - - [Test] - public void Negative_Time_Comparisons() - { - DateTime nearbyPastTime = Today.Add(-Closeness.Default - 1.Milliseconds()); - DateTime nearbyFutureTime = Today.Add(Closeness.Default + 1.Milliseconds()); - - Assert.That(Today, Must.Not.Be.CloseTo(nearbyPastTime)); - Assert.That(Today, Must.Not.Be.CloseTo(nearbyFutureTime)); - - nearbyPastTime = Today.Add(-35.Milliseconds()); - nearbyFutureTime = Today.Add(35.Milliseconds()); - - Assert.That(Today, Must.Not.Be.CloseTo(nearbyPastTime, ms: 30)); - Assert.That(Today, Must.Not.Be.CloseTo(nearbyPastTime, within: 30.Milliseconds())); - Assert.That(Today, Must.Not.Be.CloseTo(nearbyFutureTime, ms: 30)); - Assert.That(Today, Must.Not.Be.CloseTo(nearbyFutureTime, within: 30.Milliseconds())); - } - - [Test] - public void Date_Components() - { - Assert.That(11.March(1977), Must.Have.Year(1977)); - Assert.That(11.March(1977), Must.Have.Month(3)); - Assert.That(11.March(1977), Must.Have.Day(11)); - Assert.That(11.March(1977), Must.Have.Hour(0)); - Assert.That(11.March(1977), Must.Have.Minute(0)); - Assert.That(11.March(1977), Must.Have.Second(0)); - Assert.That(11.March(1977), Must.Have.Millisecond(0)); - } - - [Test] - public void Negative_Date_Components() - { - Assert.That(11.March(1977), Must.Not.Have.Year(1978)); - Assert.That(11.March(1977), Must.Not.Have.Month(1)); - Assert.That(11.March(1977), Must.Not.Have.Day(10)); - Assert.That(11.March(1977), Must.Not.Have.Hour(1)); - Assert.That(11.March(1977), Must.Not.Have.Minute(1)); - Assert.That(11.March(1977), Must.Not.Have.Second(1)); - Assert.That(11.March(1977), Must.Not.Have.Millisecond(1)); - } - - #endregion - } -} \ No newline at end of file diff --git a/src/Testing.Commons.NUnit.Tests.old/Constraints/DelegatingConstraintTester.cs b/src/Testing.Commons.NUnit.Tests.old/Constraints/DelegatingConstraintTester.cs deleted file mode 100644 index 2f91a0a..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Constraints/DelegatingConstraintTester.cs +++ /dev/null @@ -1,94 +0,0 @@ -using System; -using NUnit.Framework; -using NUnit.Framework.Constraints; -using NUnit.Framework.Internal; -using Testing.Commons.NUnit.Constraints; -using Testing.Commons.NUnit.Constraints.Support; -using Testing.Commons.NUnit.Tests.Constraints.Support; - -namespace Testing.Commons.NUnit.Tests.Constraints -{ - [TestFixture] - public class DelegatingConstraintTester : ConstraintTesterBase - { - class LongerThanFourCharactersWithStartingCapital : DelegatingConstraint - { - public LongerThanFourCharactersWithStartingCapital() - { - // we have to resolve the constraint as we are using the fluent builder - Delegate = ((IResolveConstraint)Has.Length.GreaterThan(4)).Resolve(); - } - - protected override ConstraintResult matches(object current) - { - string actual = (string) current; - // check length first - var result = Delegate.ApplyTo(actual); - if (result.IsSuccess) - { - // if long enough, check uppercase of first character - Delegate = new UppercaseConstraint(); - result = Delegate.ApplyTo(actual[0]); - } - return result; - } - } - - #region ApplyTo - - [Test] - public void ApplyTo_MatchesConditions_True() - { - var matching = "Daniel"; - Assert.That(matches(new LongerThanFourCharactersWithStartingCapital(), matching), Is.True); - } - - [Test] - public void ApplyTo_DoesNotMatchFirstCondition_False() - { - var notLongerThanFour = "Dani"; - Assert.That(matches(new LongerThanFourCharactersWithStartingCapital(), notLongerThanFour), Is.False); - } - - [Test] - public void ApplyTo_DoesNotMatchSecondCondition_False() - { - var lowercaseInitial = "daniel"; - Assert.That(matches(new LongerThanFourCharactersWithStartingCapital(), lowercaseInitial), Is.False); - } - - [Test] - public void ApplyTo_WrongType_Exception() - { - decimal notAnException = 3m; - Assert.That(() => matches(new LongerThanFourCharactersWithStartingCapital(), notAnException), - Throws.InstanceOf()); - } - - #endregion - - #region WriteMessageTo - - [Test] - public void WriteMessageTo_FailingFirstCondition_MessageFromFirstDelegateConstraint() - { - var subject = new LongerThanFourCharactersWithStartingCapital(); - var notLongerThanFour = "Dani"; - Assert.That(getMessage(subject, notLongerThanFour), - Does.StartWith(TextMessageWriter.Pfx_Expected + "property Length greater than 4").And - .Contains(TextMessageWriter.Pfx_Actual + "4")); - } - - [Test] - public void WriteMessageTo_FailingSecondCondition_MessageFromSecondDelegateConstraint() - { - var subject = new LongerThanFourCharactersWithStartingCapital(); - var lowercaseInitial = "daniel"; - Assert.That(getMessage(subject, lowercaseInitial), - Does.StartWith(TextMessageWriter.Pfx_Expected + "An uppercase character").And - .Contains(TextMessageWriter.Pfx_Actual + "'d'")); - } - - #endregion - } -} \ No newline at end of file diff --git a/src/Testing.Commons.NUnit.Tests.old/Constraints/DeserializationConstraintTester.cs b/src/Testing.Commons.NUnit.Tests.old/Constraints/DeserializationConstraintTester.cs deleted file mode 100644 index 3fa0c90..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Constraints/DeserializationConstraintTester.cs +++ /dev/null @@ -1,64 +0,0 @@ -using NSubstitute; -using NUnit.Framework; -using NUnit.Framework.Constraints; -using Testing.Commons.NUnit.Constraints; -using Testing.Commons.NUnit.Constraints.Support; -using Testing.Commons.NUnit.Tests.Constraints.Subjects; -using Testing.Commons.Serialization; - -namespace Testing.Commons.NUnit.Tests.Constraints -{ - [TestFixture] - public class DeserializationConstraintTester : ConstraintTesterBase - { - #region ApplyTo - - [Test] - public void ApplyTo_AppliesConstraintToDeserialized() - { - string serializationRepresentation = "representation"; - var deserialized = new Serializable { D = 3m, S = "s" }; - - var deserializer = Substitute.For(); - var constraint = Substitute.For(); - deserializer.Deserialize(serializationRepresentation).Returns(deserialized); - - var subject = new DeserializationConstraint(deserializer, constraint); - subject.ApplyTo(serializationRepresentation); - - constraint.Received().ApplyTo(deserialized); - } - - #endregion - - [Test] - public void CanBeNewedUp() - { - string serializationRepresentation = "representation"; - var deserialized = new Serializable { D = 3m, S = "s" }; - - var deserializer = Substitute.For(); - deserializer.Deserialize(serializationRepresentation).Returns(deserialized); - - Assert.That(serializationRepresentation, - new DeserializationConstraint(deserializer, - Has.Property("S").EqualTo("s") - .And.Property("D").EqualTo(3m))); - } - - [Test] - public void CanBeCreatedWithExtension() - { - string serializationRepresentation = "representation"; - var deserialized = new Serializable { D = 3m, S = "s" }; - - var deserializer = Substitute.For(); - deserializer.Deserialize(serializationRepresentation).Returns(deserialized); - - Assert.That(serializationRepresentation, - Must.Be.Deserializable(deserializer, - Has.Property("S").EqualTo("s") - .And.Property("D").EqualTo(3m))); - } - } -} \ No newline at end of file diff --git a/src/Testing.Commons.NUnit.Tests.old/Constraints/EnumerableCountConstraintTester.cs b/src/Testing.Commons.NUnit.Tests.old/Constraints/EnumerableCountConstraintTester.cs deleted file mode 100644 index 1b302d3..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Constraints/EnumerableCountConstraintTester.cs +++ /dev/null @@ -1,138 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using NUnit.Framework; -using NUnit.Framework.Internal; -using Testing.Commons.NUnit.Constraints; -using Testing.Commons.NUnit.Constraints.Support; - -namespace Testing.Commons.NUnit.Tests.Constraints -{ - [TestFixture] - public class EnumerableCountConstraintTester : ConstraintTesterBase - { - #region Exploratory - - [Test] - public void Array_MustUseLength() - { - Assert.That(new[] { 1, 2, 3 }, Has.Length.EqualTo(3)); - } - - [Test] - public void List_MustUseCount() - { - Assert.That(new List { 1, 2, 3 }, Has.Count.EqualTo(3)); - } - - [Test] - public void Enumerable_FromArray_MustUseLength() - { - IEnumerable e = new[] { 1, 2, 3 }; - Assert.That(e, Has.Length.EqualTo(3)); - } - - [Test] - public void Enumerable_FromList_MustUseCount() - { - IEnumerable e = new List { 1, 2, 3 }; - Assert.That(e, Has.Count.EqualTo(3)); - } - - [Test] - public void Enumereble_FromLinq_CannotUseLengthOrCount() - { - IEnumerable e = new[] { 1, 2, 3 }.Where(i => i <= 2); - - TestDelegate assertion = () => Assert.That(e, Has.Length.EqualTo(2)); - Assert.That(assertion, Throws.ArgumentException.With.Message.Contain("Length")); - - assertion = () => Assert.That(e, Has.Count.EqualTo(2)); - Assert.That(assertion, Throws.ArgumentException.With.Message.Contain("Count")); - } - - #endregion - - #region ApplyTo - - [Test] - public void ApplyTo_NotAnEnumerable_False() - { - var subject = new EnumerableCountConstraint(null); - Assert.That(matches(subject, 3), Is.False); - } - - [Test] - public void ApplyTo_NullEnumerable_False() - { - var subject = new EnumerableCountConstraint(null); - Assert.That(matches(subject, (IEnumerable)null), Is.False); - } - - [Test] - public void ApplyTo_EnumerableWithNotMatchingCount_False() - { - IEnumerable e = new[] { 1, 2, 3 }.Where(i => i <= 2); - var subject = new EnumerableCountConstraint(Is.GreaterThan(4)); - Assert.That(matches(subject, e), Is.False); - } - - [Test] - public void ApplyTo_EnumerableWithMatchingCount_True() - { - IEnumerable e = new[] { 1, 2, 3 }.Where(i => i <= 2); - var subject = new EnumerableCountConstraint(Is.EqualTo(2)); - Assert.That(matches(subject, e), Is.True); - } - - #endregion - - #region WriteMessageTo - - [Test] - public void WriteMessageTo_NotAnEnumerable_ExpectedEnumerable_ActualContainsTypeAndValue() - { - var subject = new EnumerableCountConstraint(null); - Assert.That(getMessage(subject, ConsoleColor.Black), Does - .StartWith(TextMessageWriter.Pfx_Expected + "instance of ").And - .Contains(TextMessageWriter.Pfx_Actual + "instance of ").And - .Contains("Black")); - } - - [Test] - public void WriteMessageTo_NullEnumerable_ExpectedContainsIEnumerable_ActualConstainsNull() - { - var subject = new EnumerableCountConstraint(null); - Assert.That(getMessage(subject, (IEnumerable)null), Does. - StartWith(TextMessageWriter.Pfx_Expected + "instance of ").And - .Contains(TextMessageWriter.Pfx_Actual + "null")); - } - - [Test] - public void WriteMessageTo_EnumerableWithNotMatchingCount_ExpectedContainsCount_ActualContainsCollectionValues() - { - IEnumerable e = new[] { '1', '2', '3' }.Where(i => i <= '2'); - var subject = new EnumerableCountConstraint(Is.GreaterThan(4)); - Assert.That(getMessage(subject, e), Does - .StartWith(TextMessageWriter.Pfx_Expected + "number of elements greater than 4").And - .Contains(TextMessageWriter.Pfx_Actual + "2 -> < '1', '2' >")); - } - - #endregion - - [Test] - public void CanBeNewedUp() - { - IEnumerable e = new[] { 1, 2, 3 }.Where(i => i <= 2); - Assert.That(e, new EnumerableCountConstraint(Is.LessThan(3))); - } - - [Test] - public void CanBeCreatedWithExtension() - { - IEnumerable e = new[] { 1, 2, 3 }.Where(i => i <= 2); - Assert.That(e, Must.Have.Count(Is.LessThan(3))); - } - } -} \ No newline at end of file diff --git a/src/Testing.Commons.NUnit.Tests.old/Constraints/JsonDeserializationConstraintTester.net.cs b/src/Testing.Commons.NUnit.Tests.old/Constraints/JsonDeserializationConstraintTester.net.cs deleted file mode 100644 index 35f8d02..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Constraints/JsonDeserializationConstraintTester.net.cs +++ /dev/null @@ -1,99 +0,0 @@ -using NUnit.Framework; -using NUnit.Framework.Internal; -using Testing.Commons.NUnit.Constraints; -using Testing.Commons.NUnit.Constraints.Support; -using Testing.Commons.NUnit.Tests.Constraints.Subjects; -using Testing.Commons.Serialization; - -namespace Testing.Commons.NUnit.Tests.Constraints -{ - [TestFixture] - public class JsonDeserializationConstraintTester : ConstraintTesterBase - { - #region Matches - - [Test] - public void ApplyTo_MatchingDeserialized_True() - { - var matching = Serializable.JsonString("s", 3m); - var subject = new DeserializationConstraint( - new JsonDeserializer(), - Has.Property("S").EqualTo("s") - .And.Property("D").EqualTo(3m)); - - Assert.That(matches(subject, matching), Is.True); - } - - [Test] - public void ApplyTo_NonSerialized_False() - { - var nonSerializable = ""; - var subject = new DeserializationConstraint( - new JsonDeserializer(), Is.Not.Null); - - Assert.That(matches(subject, nonSerializable), Is.False); - } - - [Test] - public void ApplyTo_NonMatching_False() - { - var nonMatching = Serializable.JsonString("s", 3m); - var subject = new DeserializationConstraint( - new JsonDeserializer(), - Has.Property("S").EqualTo("sS") - .And.Property("D").EqualTo(3m)); - - Assert.That(matches(subject, nonMatching), Is.False); - } - - #endregion - - #region WriteMessageTo - - [Test] - public void WriteMessageTo_NonSerialized_ExpectedContainsConstraintExpectations_ActualContainsExpectationsErrorPlusObject() - { - var nonSerializable = ""; - var subject = new DeserializationConstraint( - new JsonDeserializer(), Is.Not.Null); - - Assert.That(getMessage(subject, nonSerializable), Does - .StartWith(TextMessageWriter.Pfx_Expected + "Deserialized object not null").And - .Contains(TextMessageWriter.Pfx_Actual + "Could not deserialize object")); - } - - [Test] - public void WriteMessageTo_NonMatching_ActualContainsOffendingValueAndActualObject() - { - var nonMatching = Serializable.JsonString("s", 3m); - var subject = new DeserializationConstraint( - new JsonDeserializer(), - Has.Property("S").EqualTo("sS") - .And.Property("D").EqualTo(3m)); - - Assert.That(getMessage(subject, nonMatching), Does.Contain(TextMessageWriter.Pfx_Actual + "\"s\"").And - .Contains(" -> <" + typeof(Serializable).FullName + ">")); - } - - #endregion - - [Test] - public void CanBeNewedUp() - { - Assert.That(Serializable.JsonString("s", 3m), - new DeserializationConstraint( - new JsonDeserializer(), - Has.Property("S").EqualTo("s") - .And.Property("D").EqualTo(3m))); - } - - [Test] - public void CanBeCreatedWithExtension() - { - Assert.That(Serializable.JsonString("s", 3m), - Must.Be.JsonDeserializable( - Has.Property("S").EqualTo("s") - .And.Property("D").EqualTo(3m))); - } - } -} \ No newline at end of file diff --git a/src/Testing.Commons.NUnit.Tests.old/Constraints/JsonEqualConstraintTester.cs b/src/Testing.Commons.NUnit.Tests.old/Constraints/JsonEqualConstraintTester.cs deleted file mode 100644 index ceab7ff..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Constraints/JsonEqualConstraintTester.cs +++ /dev/null @@ -1,94 +0,0 @@ -using NUnit.Framework; -using NUnit.Framework.Constraints; -using Testing.Commons.NUnit.Constraints; -using Testing.Commons.NUnit.Constraints.Support; -using Testing.Commons.Serialization; - -namespace Testing.Commons.NUnit.Tests.Constraints -{ - [TestFixture] - public class JsonEqualConstraintTester : ConstraintTesterBase - { - #region ApplyTo - - [Test] - public void ApplyTo_SameProperJson_True() - { - string properJson = "{\"prop\"=\"value\"}"; - var subject = new JsonEqualConstraint("{'prop'='value'}"); - - Assert.That(matches(subject, properJson), Is.True); - } - - [Test] - public void Matches_SameJsonified_False() - { - string jsonified = "{'prop'='value'}"; - var subject = new JsonEqualConstraint("{'prop'='value'}"); - - Assert.That(matches(subject, jsonified), Is.False); - } - - [Test] - public void Matches_NotSame_False() - { - string notSame = "{\"abc\"=123}"; - var subject = new JsonEqualConstraint("{'prop'='value'}"); - - Assert.That(matches(subject, notSame), Is.False); - } - - #endregion - - #region WriteMessageTo - - [Test] - public void WriteMessageTo_DifferentJson_DelegateToEquals() - { - string expected = "{'prop'='value'}", - actual = "{\"abcd\"=\"12345\"}"; - var subject = new JsonEqualConstraint(expected); - var equals = new EqualConstraint(expected.Jsonify()); - - Assert.That(getMessage(subject, actual), - Is.EqualTo(getMessage(equals, actual))); - } - - #endregion - - [Test] - public void CanBeNewedUp() - { - var actual = "{\"prop\"=\"value\"}"; - Assert.That(actual, new JsonEqualConstraint("{'prop'='value'}")); - } - - [Test] - public void CanBeCreatedWithExtension() - { - var actual = "{\"prop\"=\"value\"}"; - Assert.That(actual, Must.Be.Json("{'prop'='value'}")); - } - - [Test] - public void EqualsCanBeUsed_WithAComparer() - { - var actual = "{\"prop\"=\"value\"}"; - Assert.That(actual, Is.EqualTo("{'prop'='value'}").Using(JsonString.Comparer)); - } - - [Test] - public void CanBeUsed_WithUsing() - { - var actual = "{\"prop\"=\"value\"}"; - Assert.That(actual, Is.EqualTo("{'prop'='value'}").Using(JsonString.Comparer)); - } - - [Test] - public void CanBeUsed_WithExtension() - { - var actual = "{\"prop\"=\"value\"}"; - Assert.That(actual, Is.EqualTo("{'prop'='value'}").AsJson()); - } - } -} \ No newline at end of file diff --git a/src/Testing.Commons.NUnit.Tests.old/Constraints/JsonSerializationConstraintTester.net.cs b/src/Testing.Commons.NUnit.Tests.old/Constraints/JsonSerializationConstraintTester.net.cs deleted file mode 100644 index 0d41a44..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Constraints/JsonSerializationConstraintTester.net.cs +++ /dev/null @@ -1,96 +0,0 @@ -using NUnit.Framework; -using NUnit.Framework.Internal; -using Testing.Commons.NUnit.Constraints; -using Testing.Commons.NUnit.Constraints.Support; -using Testing.Commons.NUnit.Tests.Constraints.Subjects; -using Testing.Commons.Serialization; - -namespace Testing.Commons.NUnit.Tests.Constraints -{ - [TestFixture] - public class JsonSerializationConstraintTester : ConstraintTesterBase - { - #region ApplyTo - - [Test] - public void ApplyTo_MatchingSerializable_True() - { - var serializable = new Serializable { D = 3m, S = "s" }; - var subject = new SerializationConstraint(new JsonRoundtripSerializer(), - Is.Not.SameAs(serializable) - .And.Property("S").EqualTo("s") - .And.Property("D").EqualTo(3m)); - - Assert.That(matches(subject,serializable), Is.True); - } - - [Test] - public void ApplyTo_NonSerializable_False() - { - var nonSerializable = new NonSerializable("s"); - var subject = new SerializationConstraint(new JsonRoundtripSerializer(), Is.Not.Null); - - Assert.That(matches(subject,nonSerializable), Is.False); - } - - [Test] - public void ApplyTo_NonMatchingSerializable_False() - { - var serializable = new Serializable { D = 3m, S = "s" }; - var subject = new SerializationConstraint(new JsonRoundtripSerializer(), - Is.Not.SameAs(serializable) - .And.Property("S").EqualTo("sS") - .And.Property("D").EqualTo(3m)); - - Assert.That(matches(subject,serializable), Is.False); - } - - #endregion - - #region WriteMessageTo - - [Test] - public void WriteMessageTo_NonSerializable_ExpectedContainsConstraintExpectations_ActualContainsExpectationsErrorPlusObject() - { - var nonSerializable = new NonSerializable("s"); - var subject = new SerializationConstraint(new JsonRoundtripSerializer(), Is.Not.Null); - - Assert.That(getMessage(subject, nonSerializable), Does - .StartWith(TextMessageWriter.Pfx_Expected + "Deserialized object not null").And - .Contains(TextMessageWriter.Pfx_Actual + "Could not serialize/deserialize object")); - } - - [Test] - public void WriteMessageTo_NonMatchingSerializable_ActualContainsOffendingValueAndActualObject() - { - var serializable = new Serializable { D = 3m, S = "s" }; - var subject = new SerializationConstraint(new JsonRoundtripSerializer(), - Is.Not.SameAs(serializable) - .And.Property("S").EqualTo("sS") - .And.Property("D").EqualTo(3m)); - - Assert.That(getMessage(subject, serializable), Does.Contain(TextMessageWriter.Pfx_Actual + "\"s\"").And - .Contains(" -> <" + typeof(Serializable).FullName + ">")); - } - - #endregion - - [Test] - public void CanBeNewedUp() - { - Assert.That(new Serializable { D = 3m, S = "s" }, - new SerializationConstraint(new JsonRoundtripSerializer(), - Has.Property("S").EqualTo("s") - .And.Property("D").EqualTo(3m))); - } - - [Test] - public void CanBeCreatedWithExtension() - { - Assert.That(new Serializable { D = 3m, S = "s" }, - Must.Be.JsonSerializable( - Has.Property("S").EqualTo("s") - .And.Property("D").EqualTo(3m))); - } - } -} \ No newline at end of file diff --git a/src/Testing.Commons.NUnit.Tests.old/Constraints/MatchingConstraintTester.cs b/src/Testing.Commons.NUnit.Tests.old/Constraints/MatchingConstraintTester.cs deleted file mode 100644 index 7a97640..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Constraints/MatchingConstraintTester.cs +++ /dev/null @@ -1,598 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using NUnit.Framework; -using NUnit.Framework.Constraints; -using NUnit.Framework.Internal; -using Testing.Commons.NUnit.Constraints; -using Testing.Commons.NUnit.Constraints.Support; -using Testing.Commons.NUnit.Tests.Subjects; - -namespace Testing.Commons.NUnit.Tests.Constraints -{ - [TestFixture] - public class MatchingConstraintTester : ConstraintTesterBase - { - #region problem exploration - - [Test] - public void MultipleAssertions_AmongstOtherThings_DoNotCommunicateIntentVeryWell() - { - CustomerWithCollection actual = someComplicatedOperation(); - - //only interested on name and the zip code of the addresses - Assert.That(actual.Name, Is.EqualTo("someName")); - var addresses = actual.Addresses.ToArray(); - Assert.That(addresses[0].Zipcode, Is.EqualTo("zip_1")); - Assert.That(addresses[1].Zipcode, Is.EqualTo("zip_2")); - } - - [Test] - public void BetterAssertions_MakeThingsSlightlyBetter() - { - CustomerWithCollection actual = someComplicatedOperation(); - - //only interested on name and the zip code of the addresses - Assert.That(actual.Name, Is.EqualTo("someName")); - Assert.That(actual.Addresses, Has.Some.Matches
(a => a.Zipcode == "zip_1")); - Assert.That(actual.Addresses, Has.Some.Matches(addressWithZipCode("zip_2"))); - - // fails but and give nice feedback about was expected but nothing about the actual object, but the type name - Assert.That(() => Assert.That(actual.Addresses, Has.Some.Matches(addressWithZipCode("wrong"))), - Throws.InstanceOf()); - } - - private IConstraint addressWithZipCode(string zipCode) - { - return ((IResolveConstraint)Has.Property("Zipcode").EqualTo(zipCode)).Resolve(); - } - - [Test] - public void UsingCustomEqualityComparer_Works_ButFeedbackWhenFailingIsPoor() - { - CustomerWithCollection actual = someComplicatedOperation(); - CustomerWithCollection expected = new CustomerWithCollection - { - Name = "someName", - Addresses = new[] - { - new Address{Zipcode = "zip_1"}, - new Address{Zipcode = "wrong"} - } - }; - - // when fails only the class name is reported, nothing else - string typeName = $"<{typeof(CustomerWithCollection).FullName}>"; - Assert.That(() => Assert.That(actual, Is.EqualTo(expected).Using(new CustomComparer())), - Throws.InstanceOf().With.Message.Contains( - TextMessageWriter.Pfx_Expected + typeName + Environment.NewLine + - TextMessageWriter.Pfx_Actual + typeName - )); - } - - class CustomComparer : IEqualityComparer - { - public bool Equals(CustomerWithCollection x, CustomerWithCollection y) - { - // for brevity, let's consider arguments as not null - bool areEqual = x.Name == y.Name; - if (areEqual) - { - // to make things easier, let's use indexes - Address[] inX = x.Addresses.ToArray(), inY = y.Addresses.ToArray(); - areEqual = inX.Length == inY.Length; - { - for (int i = 0; i < inX.Length && areEqual; i++) - { - areEqual = inX[i].Zipcode == inY[i].Zipcode; - } - } - } - return areEqual; - } - - public int GetHashCode(CustomerWithCollection obj) - { - //makes equality method to be always executed - return 0; - } - } - - private CustomerWithCollection someComplicatedOperation() - { - return new CustomerWithCollection - { - Name = "someName", - PhoneNumber = "someNumber", - Addresses = new[] - { - new Address - { - AddressLineOne = "1_1", AddressLineTwo = "1_2", City = "city_1", State = "state_1", Zipcode = "zip_1" - }, - new Address - { - AddressLineOne = "2_1", AddressLineTwo = "2_2", City = "city_2", State = "state_2", Zipcode = "zip_2" - } - } - }; - } - - #endregion - - #region Matches - - [Test] - public void ApplyTo_ExpectedWithSameShapeAndSameValues_True() - { - var subject = new MatchingConstraint(new { A = "a" }); - Assert.That(matches(subject, new { A = "a" }), Is.True); - } - - [TestCase("a"), TestCase("B")] - public void ApplyTo_ExpectedWithSameShapeAndDifferentValues_FalseRegardlessOfCasing(string differentValue) - { - var subject = new MatchingConstraint(new { A = differentValue }); - - Assert.That(matches(subject, new { A = "b" }), Is.False); - } - - [Test] - public void ApplyTo_ExpectedIsSubsetOfActual_True() - { - var subject = new MatchingConstraint(new { A = "a" }); - Assert.That(matches(subject, new { A = "a", B = 1 }), Is.True); - } - - [Test] - public void ApplyTo_ExpectedIsSupersetOfActual_False() - { - var subject = new MatchingConstraint(new { A = "a", B = 1 }); - Assert.That(matches(subject, new { A = "a" }), Is.False); - } - - [Test] - public void ApplyTo_PrettyDeepWithSameValues_True() - { - var actual = new - { - A = "a", - B = new - { - C = 1, - D = new { E = TimeSpan.Zero } - } - }; - - var expected = new - { - A = "a", - B = new - { - C = 1, - D = new { E = TimeSpan.Zero } - } - }; - - var subject = new MatchingConstraint(expected); - Assert.That(matches(subject, actual), Is.True); - } - - [Test] - public void ApplyTo_DifferentDeepValue_False() - { - var actual = new - { - A = "a", - B = new - { - C = 1, - D = new { E = TimeSpan.Zero } - } - }; - - var expected = new - { - A = "a", - B = new - { - C = 1, - D = new { E = TimeSpan.MaxValue } - } - }; - - var subject = new MatchingConstraint(expected); - Assert.That(matches(subject, actual), Is.False); - } - - [Test] - public void ApplyTo_WithCollectionMemberWithSameShapeAndValues_True() - { - var complex = new CustomerWithCollection - { - Name = "name", - PhoneNumber = "number", - Addresses = new[] - { - new Address { AddressLineOne = "1_1", AddressLineTwo = "1_2", City = "city_1", State = "state_1", Zipcode = "zip_1"}, - new Address { AddressLineOne = "2_1", AddressLineTwo = "2_2", City = "city_2", State = "state_2", Zipcode = "zip_2"} - } - }; - - var expected = new - { - Name = "name", - Addresses = new object[] - { - new { State = "state_1"}, - new { Zipcode = "zip_2"} - } - }; - - var subject = new MatchingConstraint(expected); - Assert.That(matches(subject, complex), Is.True); - } - - [Test] - public void ApplyTo_WithCollectionMemberWithDifferentShape_False() - { - var complex = new CustomerWithCollection - { - Name = "name", - PhoneNumber = "number", - Addresses = new[] - { - new Address { AddressLineOne = "1_1", AddressLineTwo = "1_2", City = "city_1", State = "state_1", Zipcode = "zip_1"}, - new Address { AddressLineOne = "2_1", AddressLineTwo = "2_2", City = "city_2", State = "state_2", Zipcode = "zip_2"} - } - }; - - var expected = new - { - Name = "name", - Addresses = new object[] - { - new { State = "state_1"}, - new { NotThere = 0} - } - }; - - var subject = new MatchingConstraint(expected); - Assert.That(matches(subject, complex), Is.False); - } - - [Test] - public void ApplyTo_WithCollectionMemberWithSameShapeAndDifferentValues_False() - { - var complex = new CustomerWithCollection - { - Name = "name", - PhoneNumber = "number", - Addresses = new[] - { - new Address { AddressLineOne = "1_1", AddressLineTwo = "1_2", City = "city_1", State = "state_1", Zipcode = "zip_1"}, - new Address { AddressLineOne = "2_1", AddressLineTwo = "2_2", City = "city_2", State = "state_2", Zipcode = "zip_2"} - } - }; - - var expected = new - { - Name = "name", - Addresses = new object[] - { - new { State = "state_1"}, - new { Zipcode = "notSameValue"} - } - }; - - var subject = new MatchingConstraint(expected); - Assert.That(matches(subject, complex), Is.False); - } - - [Test] - public void ApplyTo_WithCollectionMemberAgainstAnonymousWithoutCollection_True() - { - var withAddresses = new CustomerWithCollection - { - Name = "name", - PhoneNumber = "number", - Addresses = new[] - { - new Address { AddressLineOne = "1_1", AddressLineTwo = "1_2", City = "city_1", State = "state_1", Zipcode = "zip_1"}, - new Address { AddressLineOne = "2_1", AddressLineTwo = "2_2", City = "city_2", State = "state_2", Zipcode = "zip_2"} - } - }; - - var withoutAddresses = new - { - Name = "name", - PhoneNumber = "number", - }; - - var subject = new MatchingConstraint(withoutAddresses); - - Assert.That(matches(subject, withAddresses), Is.True); - } - - [Test] - public void ApplyTo_WithCollectionMemberAgainstSameTypeWithoutCollection_False() - { - var withAddresses = new CustomerWithCollection - { - Name = "name", - PhoneNumber = "number", - Addresses = new[] - { - new Address { AddressLineOne = "1_1", AddressLineTwo = "1_2", City = "city_1", State = "state_1", Zipcode = "zip_1"}, - new Address { AddressLineOne = "2_1", AddressLineTwo = "2_2", City = "city_2", State = "state_2", Zipcode = "zip_2"} - } - }; - - var withoutAddresses = new CustomerWithCollection - { - Name = "name", - PhoneNumber = "number", - }; - - var subject = new MatchingConstraint(withoutAddresses); - - Assert.That(matches(subject, withAddresses), Is.False); - } - - #endregion - - #region WriteMessageTo - - [Test] - public void WriteMessageTo_ExpectedWithSameShapeAndDifferentValues_ContainsMemberDiscrepancy() - { - var subject = new MatchingConstraint(new { A = "differentValue" }); - - string message = getMessage(subject, new { A = "b" }); - Assert.That(message, - offendingMember("A") & - expectedValue("differentValue") & - actualValue("b")); - } - - [Test] - public void WriteMessageTo_ExpectedIsSupersetOfActual_ContainsMemberDiscrepancy() - { - var subject = new MatchingConstraint(new { A = "a", B = 1 }); - - Assert.That(getMessage(subject, new { A = "a" }), - offendingMember("B") & - expectedValue(1) & - missingActualMember() - ); - } - - [Test] - public void WriteMessageTo_DifferentDeepValue_ContainsMemberDiscrepancy() - { - var actual = new - { - A = "a", - B = new - { - C = 1, - D = new { E = TimeSpan.Zero } - } - }; - - var expected = new - { - A = "a", - B = new - { - C = 1, - D = new { E = TimeSpan.MaxValue } - } - }; - - var subject = new MatchingConstraint(expected); - Assert.That(getMessage(subject, actual), - offendingMember("E") & - actualValue(TimeSpan.Zero) & - expectedValue(TimeSpan.MaxValue)); - } - - [Test] - public void WriteMessageTo_WithCollectionMemberWithDifferentShape_ContainsIndexedDiscrepancy() - { - var complex = new CustomerWithCollection - { - Name = "name", - PhoneNumber = "number", - Addresses = new[] - { - new Address { AddressLineOne = "1_1", AddressLineTwo = "1_2", City = "city_1", State = "state_1", Zipcode = "zip_1"}, - new Address { AddressLineOne = "2_1", AddressLineTwo = "2_2", City = "city_2", State = "state_2", Zipcode = "zip_2"} - } - }; - - var expected = new - { - Name = "name", - Addresses = new object[] - { - new { State = "state_1"}, - new { NotThere = 0} - } - }; - - var subject = new MatchingConstraint(expected); - Assert.That(getMessage(subject, complex), - memberContainer("CustomerWithCollection.Addresses") & - indexOfOffendingCollectionItem(1) & - offendingMember("NotThere") & - expectedValue(0) & - missingActualMember() - ); - } - - [Test] - public void WriteMessageTo_WithCollectionMemberWithSameShapeAndDifferentValues_ContainsIndexedDiscrepancy() - { - var complex = new CustomerWithCollection - { - Name = "name", - PhoneNumber = "number", - Addresses = new[] - { - new Address { AddressLineOne = "1_1", AddressLineTwo = "1_2", City = "city_1", State = "state_1", Zipcode = "zip_1"}, - new Address { AddressLineOne = "2_1", AddressLineTwo = "2_2", City = "city_2", State = "state_2", Zipcode = "zip_2"} - } - }; - - var expected = new - { - Name = "name", - Addresses = new object[] - { - new { State = "state_1"}, - new { Zipcode = "notSameValue"} - } - }; - - var subject = new MatchingConstraint(expected); - Assert.That(getMessage(subject, complex), - memberContainer("CustomerWithCollection.Addresses") & - indexOfOffendingCollectionItem(1) & - offendingMember("Zipcode") & - expectedValue("notSameValue") & - actualValue("zip_2") - ); - } - - [Test] - public void WriteMessageTo_WithCollectionMemberAgainstSameTypeWithoutCollection_ContainsMemberDiscrepancy() - { - var withAddresses = new CustomerWithCollection - { - Name = "name", - PhoneNumber = "number", - Addresses = new[] - { - new Address { AddressLineOne = "1_1", AddressLineTwo = "1_2", City = "city_1", State = "state_1", Zipcode = "zip_1"}, - new Address { AddressLineOne = "2_1", AddressLineTwo = "2_2", City = "city_2", State = "state_2", Zipcode = "zip_2"} - } - }; - - var withoutAddresses = new CustomerWithCollection - { - Name = "name", - PhoneNumber = "number", - }; - - var subject = new MatchingConstraint(withoutAddresses); - Assert.That(getMessage(subject, withAddresses), - memberContainer("Addresses") & - expectedValue(null) & - actualValue(Does.Contain("<"))); - } - - [Test] - public void WriteMessageTo_WithCollectionMemberWithLessMembers_ContainsIndexedDiscrepancy() - { - var withAddresses = new CustomerWithCollection - { - Name = "name", - PhoneNumber = "number", - Addresses = new[] - { - new Address { AddressLineOne = "1_1", AddressLineTwo = "1_2", City = "city_1", State = "state_1", Zipcode = "zip_1"}, - new Address { AddressLineOne = "2_1", AddressLineTwo = "2_2", City = "city_2", State = "state_2", Zipcode = "zip_2"} - } - }; - - var lessAddresses = new - { - Name = "name", - PhoneNumber = "number", - Addresses = new object[] { new { AddressLineOne = "1_1" } } - }; - - var subject = new MatchingConstraint(lessAddresses); - Assert.That(getMessage(subject, withAddresses), - memberContainer("Addresses") & - indexOfOffendingCollectionItem(1) & - missingExpectedMember() & - actualValue(Does.Contain("Address"))); - } - - private Constraint offendingMember(string memberName) - { - return Does.Contain("." + memberName); - } - - private Constraint expectedValue(string value) - { - return Does.Contain(TextMessageWriter.Pfx_Expected + valueOf(value)); - } - - private string valueOf(string str) - { - return str == null ? "null" : $"\"{str}\""; - } - - private Constraint actualValue(string value) - { - return Does.Contain(TextMessageWriter.Pfx_Actual + valueOf(value)); - } - - private Constraint expectedValue(object value) - { - return Does.Contain(TextMessageWriter.Pfx_Expected + valueOf(value)); - } - - private string valueOf(object i) - { - return i == null ? "null" : $"{i}"; - } - - private Constraint missingActualMember() - { - return Does.Contain(TextMessageWriter.Pfx_Actual + "member was missing"); - } - - private Constraint actualValue(object value) - { - return Does.Contain(TextMessageWriter.Pfx_Actual + valueOf(value)); - } - - private Constraint memberContainer(string containerName) - { - return Does.Contain(containerName); - } - - private Constraint indexOfOffendingCollectionItem(int i) - { - return Does.Contain($"[{i}]"); - } - - private Constraint actualValue(Constraint constraint) - { - return Does.Contain(TextMessageWriter.Pfx_Actual) & constraint; - } - - private Constraint missingExpectedMember() - { - return Does.Contain(TextMessageWriter.Pfx_Expected + "nothing"); - } - - #endregion - - [Test] - public void CanBeNewedUp() - { - Assert.That(new { A = "a", B = "b" }, new MatchingConstraint(new { A = "a" })); - } - - [Test] - public void CanBeCreatedWithExtension() - { - Assert.That(new { A = "a", B = "b" }, Must.Match.Expected(new { A = "a" })); - } - } -} \ No newline at end of file diff --git a/src/Testing.Commons.NUnit.Tests.old/Constraints/NoPropertyChangedConstraintTester.cs b/src/Testing.Commons.NUnit.Tests.old/Constraints/NoPropertyChangedConstraintTester.cs deleted file mode 100644 index cca3c6d..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Constraints/NoPropertyChangedConstraintTester.cs +++ /dev/null @@ -1,80 +0,0 @@ -using System.ComponentModel; -using NSubstitute; -using NUnit.Framework; -using NUnit.Framework.Internal; -using Testing.Commons.NUnit.Constraints; -using Testing.Commons.NUnit.Constraints.Support; -using Testing.Commons.NUnit.Tests.Subjects; - -namespace Testing.Commons.NUnit.Tests.Constraints -{ - [TestFixture] - public class NoPropertyChangedConstraintTester : ConstraintTesterBase - { - #region ApplyTo - - [Test] - public void ApplyTo_SetterDoesNotRaiseEvent_True() - { - IRaisingSubject raising = Substitute.For(); - var subject = new NoPropertyChangedConstraint(raising); - - Assert.That(matches(subject, () => raising.I = 3), Is.True); - } - - [Test] - public void ApplyTo_SetterRaisesEvent_False() - { - IRaisingSubject raising = Substitute.For(); - - raising - .When(r => r.I = Arg.Any()) - .Do(ci => raising.PropertyChanged += Raise.Event(raising, new PropertyChangedEventArgs("anything"))); - - var subject = new NoPropertyChangedConstraint(raising); - Assert.That(matches(subject, () => raising.I = 3), Is.False); - } - - #endregion - - #region WriteDescriptionTo - - [Test] - public void WriteDescriptionTo_RaisesEvent_ExpectationWithEvent_ActualWithEventNotRaised() - { - IRaisingSubject raising = Substitute.For(); - raising - .When(r => r.I = Arg.Any()) - .Do(ci => raising.PropertyChanged += Raise.Event(raising, new PropertyChangedEventArgs("anything"))); - - var subject = new NoPropertyChangedConstraint(raising); - - Assert.That(getMessage(subject, () => raising.I = 3), - Does.StartWith(TextMessageWriter.Pfx_Expected + "event 'PropertyChanged' not raised").And - .Contain(TextMessageWriter.Pfx_Actual + "event 'PropertyChanged' raised")); - } - - #endregion - - [Test] - public void CanBeNewedUp() - { - var raising = Substitute.For(); - raising - .When(r => r.I = Arg.Any()) - .Do(_ => { }); - - Assert.That(() => raising.I = 3, new NoPropertyChangedConstraint(raising)); - } - - [Test] - public void CanBeCreatedWithExtension() - { - var raising = Substitute.For(); - raising.When(r => r.I = Arg.Any()) - .Do(_ => { }); - - Assert.That(() => raising.I = 3, Must.Not.Raise.PropertyChanged(raising)); - } - } -} \ No newline at end of file diff --git a/src/Testing.Commons.NUnit.Tests.old/Constraints/NoPropertyChangingConstraintTester.cs b/src/Testing.Commons.NUnit.Tests.old/Constraints/NoPropertyChangingConstraintTester.cs deleted file mode 100644 index e42b3db..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Constraints/NoPropertyChangingConstraintTester.cs +++ /dev/null @@ -1,80 +0,0 @@ -using System.ComponentModel; -using NSubstitute; -using NUnit.Framework; -using NUnit.Framework.Internal; -using Testing.Commons.NUnit.Constraints; -using Testing.Commons.NUnit.Constraints.Support; -using Testing.Commons.NUnit.Tests.Subjects; - -namespace Testing.Commons.NUnit.Tests.Constraints -{ - [TestFixture] - public class NoPropertyChangingConstraintTester : ConstraintTesterBase - { - #region ApplyTo - - [Test] - public void ApplyTo_SetterDoesNotRaiseEvent_True() - { - IRaisingSubject raising = Substitute.For(); - var subject = new NoPropertyChangingConstraint(raising); - - Assert.That(matches(subject, () => raising.I = 3), Is.True); - } - - [Test] - public void ApplyTo_SetterRaisesEvent_False() - { - IRaisingSubject raising = Substitute.For(); - - raising - .When(r => r.I = Arg.Any()) - .Do(ci => raising.PropertyChanging += Raise.Event(raising, new PropertyChangingEventArgs("anything"))); - - var subject = new NoPropertyChangingConstraint(raising); - Assert.That(matches(subject, () => raising.I = 3), Is.False); - } - - #endregion - - #region WriteDescriptionTo - - [Test] - public void WriteDescriptionTo_RaisesEvent_ExpectationWithEvent_ActualWithEventNotRaising() - { - IRaisingSubject raising = Substitute.For(); - raising - .When(r => r.I = Arg.Any()) - .Do(ci => raising.PropertyChanging += Raise.Event(raising, new PropertyChangingEventArgs("anything"))); - - var subject = new NoPropertyChangingConstraint(raising); - - Assert.That(getMessage(subject, () => raising.I = 3), - Does.StartWith(TextMessageWriter.Pfx_Expected + "event 'PropertyChanging' not raised").And - .Contain(TextMessageWriter.Pfx_Actual + "event 'PropertyChanging' raised")); - } - - #endregion - - [Test] - public void CanBeNewedUp() - { - var raising = Substitute.For(); - raising - .When(r => r.I = Arg.Any()) - .Do(_ => { }); - - Assert.That(() => raising.I = 3, new NoPropertyChangingConstraint(raising)); - } - - [Test] - public void CanBeCreatedWithExtension() - { - var raising = Substitute.For(); - raising.When(r => r.I = Arg.Any()) - .Do(_ => { }); - - Assert.That(() => raising.I = 3, Must.Not.Raise.PropertyChanging(raising)); - } - } -} \ No newline at end of file diff --git a/src/Testing.Commons.NUnit.Tests.old/Constraints/PropertyChangedConstraintTester.cs b/src/Testing.Commons.NUnit.Tests.old/Constraints/PropertyChangedConstraintTester.cs deleted file mode 100644 index 875b82b..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Constraints/PropertyChangedConstraintTester.cs +++ /dev/null @@ -1,113 +0,0 @@ -using System.ComponentModel; -using NSubstitute; -using NUnit.Framework; -using NUnit.Framework.Internal; -using Testing.Commons.NUnit.Constraints; -using Testing.Commons.NUnit.Constraints.Support; -using Testing.Commons.NUnit.Tests.Subjects; - -namespace Testing.Commons.NUnit.Tests.Constraints -{ - [TestFixture] - public class PropertyChangedConstraintTester : ConstraintTesterBase - { - #region ApplyTo - - [Test] - public void ApplyTo_SetterDoesNotRaiseEvent_False() - { - IRaisingSubject raising = Substitute.For(); - var subject = new PropertyChangedConstraint(raising, r => r.I); - - Assert.That(matches(subject, () => raising.I = 3), Is.False); - } - - [Test] - public void ApplyTo_WrongPropertyName_False() - { - IRaisingSubject raising = Substitute.For(); - - raising - .When(r => r.I = Arg.Any()) - .Do(ci => raising.PropertyChanged += Raise.Event(raising, new PropertyChangedEventArgs("Wrong"))); - - var subject = new PropertyChangedConstraint(raising, r => r.I); - Assert.That(matches(subject, () => raising.I = 3), Is.False); - } - - [Test] - public void ApplyTo_RightPropertyName_True() - { - IRaisingSubject raising = Substitute.For(); - raising - .When(r => r.I = Arg.Any()) - .Do(ci => raising.PropertyChanged += Raise.Event(raising, new PropertyChangedEventArgs("I"))); - - var subject = new PropertyChangedConstraint(raising, r => r.I); - Assert.That(matches(subject, () => raising.I = 3), Is.True); - } - - #endregion - - #region WriteDescriptionTo - - [Test] - public void WriteDescriptionTo_SetterDoesNotRaiseEvent_ExpectationWithEvent_PropertyName_ActualWithEventNotRaised() - { - IRaisingSubject raising = Substitute.For(); - var subject = new PropertyChangedConstraint(raising, r => r.I); - - Assert.That(getMessage(subject, () => raising.I = 3), - Does.StartWith(TextMessageWriter.Pfx_Expected + "raise event 'PropertyChanged'").And - .Contain("PropertyName equal to \"I\"").And - .Contain(TextMessageWriter.Pfx_Actual + "event 'PropertyChanged' not raised")); - } - - [Test] - public void WriteDescriptionTo_WrongPropertyName_ActualWithOffendingValue() - { - IRaisingSubject raising = Substitute.For(); - raising - .When(r => r.I = Arg.Any()) - .Do(ci => raising.PropertyChanged += Raise.Event(raising, new PropertyChangedEventArgs("Wrong"))); - - var subject = new PropertyChangedConstraint(raising, r => r.I); - Assert.That(getMessage(subject, () => raising.I = 3), - Does.Contain(TextMessageWriter.Pfx_Actual + "\"Wrong\"")); - } - - #endregion - - [Test] - public void CanBeNewedUp() - { - var raising = Substitute.For(); - raising - .When(r => r.I = Arg.Any()) - .Do(ci => raising.PropertyChanged += Raise.Event(raising, new PropertyChangedEventArgs("I"))); - - Assert.That(() => raising.I = 3, new PropertyChangedConstraint(raising, r => r.I)); - } - - [Test] - public void CanBeCreatedWithExtension() - { - var raising = Substitute.For(); - raising.When(r => r.I = Arg.Any()) - .Do(ci => raising.PropertyChanged += Raise.Event(raising, new PropertyChangedEventArgs("I"))); - - Assert.That(() => raising.I = 3, Must.Raise.PropertyChanged(raising, r => r.I)); - } - - [Test] - public void AllowsPropertyChanged_ToBeDifferentFromTheMemberName() - { - var raising = Substitute.For(); - raising.When(r => r.I = Arg.Any()) - .Do(ci => raising.PropertyChanged += Raise.Event(raising, - new PropertyChangedEventArgs("somethingElse"))); - - Assert.That(() => raising.I = 3, Must.Raise.PropertyChanged(raising, Is.EqualTo("somethingElse"))); - } - } -} \ No newline at end of file diff --git a/src/Testing.Commons.NUnit.Tests.old/Constraints/PropertyChangingConstraintTester.cs b/src/Testing.Commons.NUnit.Tests.old/Constraints/PropertyChangingConstraintTester.cs deleted file mode 100644 index de944cd..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Constraints/PropertyChangingConstraintTester.cs +++ /dev/null @@ -1,109 +0,0 @@ -using System.ComponentModel; -using NSubstitute; -using NUnit.Framework; -using NUnit.Framework.Internal; -using Testing.Commons.NUnit.Constraints; -using Testing.Commons.NUnit.Constraints.Support; -using Testing.Commons.NUnit.Tests.Subjects; - -namespace Testing.Commons.NUnit.Tests.Constraints -{ - [TestFixture] - public class PropertyChangingConstraintTester : ConstraintTesterBase - { - #region ApplyTo - - [Test] - public void ApplyTo_SetterDoesNotRaiseEvent_False() - { - IRaisingSubject raising = Substitute.For(); - var subject = new PropertyChangingConstraint(raising, r => r.I); - - Assert.That(matches(subject, () => raising.I = 3), Is.False); - } - - [Test] - public void ApplyTo_WrongPropertyName_False() - { - IRaisingSubject raising = Substitute.For(); - raising.When(r => r.I = Arg.Any()) - .Do(i => raising.PropertyChanging += Raise.Event(raising, new PropertyChangingEventArgs("Wrong"))); - - var subject = new PropertyChangingConstraint(raising, r => r.I); - Assert.That(matches(subject, () => raising.I = 3), Is.False); - } - - [Test] - public void ApplyTo_RightPropertyName_True() - { - IRaisingSubject raising = Substitute.For(); - raising.When(r => r.I = Arg.Any()) - .Do(i => raising.PropertyChanging += Raise.Event(raising, new PropertyChangingEventArgs("I"))); - - var subject = new PropertyChangingConstraint(raising, r => r.I); - Assert.That(matches(subject, () => raising.I = 3), Is.True); - } - - #endregion - - #region WriteDescriptionTo - - [Test] - public void WriteDescriptionTo_SetterDoesNotRaiseEvent_ExpectationWithEvent_PropertyName_ActualWithEventNotRaised() - { - IRaisingSubject raising = Substitute.For(); - var subject = new PropertyChangingConstraint(raising, r => r.I); - - Assert.That(getMessage(subject, () => raising.I = 3), - Does.StartWith(TextMessageWriter.Pfx_Expected + "raise event 'PropertyChanging'").And - .Contains("PropertyName equal to \"I\"").And - .Contains(TextMessageWriter.Pfx_Actual + "event 'PropertyChanging' not raised") - ); - } - - [Test] - public void WriteDescriptionTo_WrongPropertyName_ActualWithOffendingValue() - { - IRaisingSubject raising = Substitute.For(); - raising.When(r => r.I = Arg.Any()) - .Do(i => raising.PropertyChanging += Raise.Event(raising, new PropertyChangingEventArgs("Wrong"))); - - var subject = new PropertyChangingConstraint(raising, r => r.I); - Assert.That(getMessage(subject, () => raising.I = 3), Does - .Contain(TextMessageWriter.Pfx_Actual + "\"Wrong\"")); - } - - #endregion - - [Test] - public void CanBeNewedUp() - { - IRaisingSubject raising = Substitute.For(); - raising.When(r => r.I = Arg.Any()) - .Do(i => raising.PropertyChanging += Raise.Event(raising, new PropertyChangingEventArgs("I"))); - - Assert.That(() => raising.I = 3, new PropertyChangingConstraint(raising, r => r.I)); - } - - [Test] - public void CanBeCreatedWithExtension() - { - IRaisingSubject raising = Substitute.For(); - raising.When(r => r.I = Arg.Any()) - .Do(i => raising.PropertyChanging += Raise.Event(raising, new PropertyChangingEventArgs("I"))); - - Assert.That(() => raising.I = 3, Must.Raise.PropertyChanging(raising, r => r.I)); - } - - [Test] - public void AllowsPropertyChanging_ToBeDifferentFromTheMemberName() - { - var raising = Substitute.For(); - raising.When(r => r.I = Arg.Any()) - .Do(ci => raising.PropertyChanging += Raise.Event(raising, - new PropertyChangingEventArgs("somethingElse"))); - - Assert.That(() => raising.I = 3, Must.Raise.PropertyChanging(raising, Is.EqualTo("somethingElse"))); - } - } -} \ No newline at end of file diff --git a/src/Testing.Commons.NUnit.Tests.old/Constraints/SerializationConstraintTester.cs b/src/Testing.Commons.NUnit.Tests.old/Constraints/SerializationConstraintTester.cs deleted file mode 100644 index 093cce6..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Constraints/SerializationConstraintTester.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System.Linq; -using NSubstitute; -using NSubstitute.Core; -using NUnit.Framework; -using NUnit.Framework.Constraints; -using Testing.Commons.NUnit.Constraints; -using Testing.Commons.NUnit.Constraints.Support; -using Testing.Commons.NUnit.Tests.Constraints.Subjects; -using Testing.Commons.Serialization; - -namespace Testing.Commons.NUnit.Tests.Constraints -{ - [TestFixture] - public class SerializationConstraintTester : ConstraintTesterBase - { - #region ApplyTo - - [Test] - public void ApplyTo_AsksDeserializerToDeserializeWhatWasSerialized() - { - var serializable = new Serializable { D = 3m, S = "s" }; - - var serializer = Substitute.For>(); - - var subject = new SerializationConstraint(serializer, Is.Null); - subject.ApplyTo(serializable); - - ICall[] receivedCalls = serializer.ReceivedCalls().ToArray(); - - // first call: .Serialize(serializable) - Assert.That(receivedCalls[0].GetMethodInfo().Name, Is.EqualTo("Serialize")); - Assert.That(receivedCalls[0].GetArguments()[0], Is.SameAs(serializable)); - - // second call: Deserialize() - Assert.That(receivedCalls[1].GetMethodInfo().Name, Is.EqualTo("Deserialize")); - - // third call: Dispose() - Assert.That(receivedCalls[2].GetMethodInfo().Name, Is.EqualTo("Dispose")); - } - - [Test] - public void ApplyTo_AppliesConstraintToDeserialized() - { - var serializable = new Serializable { D = 3m, S = "s" }; - var deserialized = new Serializable(); - - var serializer = Substitute.For>(); - var constraint = Substitute.For(); - serializer.Deserialize().Returns(deserialized); - - var subject = new SerializationConstraint(serializer, constraint); - subject.ApplyTo(serializable); - - constraint.Received().ApplyTo(deserialized); - } - - #endregion - - [Test] - public void CanBeNewedUp() - { - var serializable = new Serializable { D = 3m, S = "s" }; - - var serializer = Substitute.For>(); - serializer.Deserialize().Returns(serializable); - - Assert.That(serializable, - new SerializationConstraint(serializer, - Has.Property("S").EqualTo("s") - .And.Property("D").EqualTo(3m))); - } - - [Test] - public void CanBeCreatedWithExtension() - { - var serializable = new Serializable { D = 3m, S = "s" }; - - var serializer = Substitute.For>(); - serializer.Deserialize().Returns(serializable); - - Assert.That(serializable, - Must.Be.Serializable(serializer, - Has.Property("S").EqualTo("s") - .And.Property("D").EqualTo(3m))); - } - } -} \ No newline at end of file diff --git a/src/Testing.Commons.NUnit.Tests.old/Constraints/Subjects/NonSerializable.cs b/src/Testing.Commons.NUnit.Tests.old/Constraints/Subjects/NonSerializable.cs deleted file mode 100644 index 8107940..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Constraints/Subjects/NonSerializable.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace Testing.Commons.NUnit.Tests.Constraints.Subjects -{ - // missing attribute - public class NonSerializable - { - // missing default constructor - - public NonSerializable(string s) - { - S = s; - } - - public string S { get; private set; } - } -} \ No newline at end of file diff --git a/src/Testing.Commons.NUnit.Tests.old/Constraints/Subjects/Serializable.cs b/src/Testing.Commons.NUnit.Tests.old/Constraints/Subjects/Serializable.cs deleted file mode 100644 index 8cfcd9c..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Constraints/Subjects/Serializable.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.Runtime.Serialization; - -namespace Testing.Commons.NUnit.Tests.Constraints.Subjects -{ - [DataContract] - public partial class Serializable - { - [DataMember] - public string S { get; set; } - [DataMember] - public decimal D { get; set; } - - public static string DataContractString(string s, decimal d) - { - return string.Format("{1}{0}", - s, d); - } - - public static string XmlString(string s, decimal d) - { - return $"{s}{d}"; - } - public static string JsonString(string s, decimal d) - { - return $"{{\"S\":\"{s}\",\"D\":{d}}}"; - } - - public static string DataContractJsonString(string s, decimal d) - { - return $"{{\"D\":{d},\"S\":\"{s}\"}}"; - } - } -} \ No newline at end of file diff --git a/src/Testing.Commons.NUnit.Tests.old/Constraints/Subjects/Serializable.net.cs b/src/Testing.Commons.NUnit.Tests.old/Constraints/Subjects/Serializable.net.cs deleted file mode 100644 index 96f8534..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Constraints/Subjects/Serializable.net.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Testing.Commons.NUnit.Tests.Constraints.Subjects -{ - [System.Serializable] - public partial class Serializable - { - } -} \ No newline at end of file diff --git a/src/Testing.Commons.NUnit.Tests.old/Constraints/Support/UppercaseConstraint.cs b/src/Testing.Commons.NUnit.Tests.old/Constraints/Support/UppercaseConstraint.cs deleted file mode 100644 index a11e5ce..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Constraints/Support/UppercaseConstraint.cs +++ /dev/null @@ -1,20 +0,0 @@ -using NUnit.Framework.Constraints; - -namespace Testing.Commons.NUnit.Tests.Constraints.Support -{ - internal class UppercaseConstraint : Constraint - { - public override ConstraintResult ApplyTo(TActual actual) - { - return new ConstraintResult(this, actual, match(actual)); - } - - private bool match(object current) - { - var c = (char)current; - return char.IsUpper(c); - } - - public override string Description => "An uppercase character"; - } -} \ No newline at end of file diff --git a/src/Testing.Commons.NUnit.Tests.old/Constraints/XmlDeserializationConstraintTester.cs b/src/Testing.Commons.NUnit.Tests.old/Constraints/XmlDeserializationConstraintTester.cs deleted file mode 100644 index a0dd505..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Constraints/XmlDeserializationConstraintTester.cs +++ /dev/null @@ -1,99 +0,0 @@ -using NUnit.Framework; -using NUnit.Framework.Internal; -using Testing.Commons.NUnit.Constraints; -using Testing.Commons.NUnit.Constraints.Support; -using Testing.Commons.NUnit.Tests.Constraints.Subjects; -using Testing.Commons.Serialization; - -namespace Testing.Commons.NUnit.Tests.Constraints -{ - [TestFixture] - public class XmlDeserializationConstraintTester : ConstraintTesterBase - { - #region ApplyTo - - [Test] - public void ApplyTo_MatchingDeserialized_True() - { - var matching = Serializable.XmlString("s", 3m); - var subject = new DeserializationConstraint( - new XmlDeserializer(), - Has.Property("S").EqualTo("s") - .And.Property("D").EqualTo(3m)); - - Assert.That(matches(subject,matching), Is.True); - } - - [Test] - public void ApplyTo_NonSerialized_False() - { - var nonSerializable = ""; - var subject = new DeserializationConstraint( - new XmlDeserializer(), Is.Not.Null); - - Assert.That(matches(subject,nonSerializable), Is.False); - } - - [Test] - public void ApplyTo_NonMatching_False() - { - var nonMatching = Serializable.XmlString("s", 3m); - var subject = new DeserializationConstraint( - new XmlDeserializer(), - Has.Property("S").EqualTo("sS") - .And.Property("D").EqualTo(3m)); - - Assert.That(matches(subject,nonMatching), Is.False); - } - - #endregion - - #region WriteMessageTo - - [Test] - public void WriteMessageTo_NonSerialized_ExpectedContainsConstraintExpectations_ActualContainsExpectationsErrorPlusObject() - { - var nonSerializable = ""; - var subject = new DeserializationConstraint( - new XmlDeserializer(), Is.Not.Null); - - Assert.That(getMessage(subject, nonSerializable), Does - .StartWith(TextMessageWriter.Pfx_Expected + "Deserialized object not null").And - .Contains(TextMessageWriter.Pfx_Actual + "Could not deserialize object")); - } - - [Test] - public void WriteMessageTo_NonMatching_ActualContainsOffendingValueAndActualObject() - { - var nonMatching = Serializable.XmlString("s", 3m); - var subject = new DeserializationConstraint( - new XmlDeserializer(), - Has.Property("S").EqualTo("sS") - .And.Property("D").EqualTo(3m)); - - Assert.That(getMessage(subject, nonMatching), Does.Contain(TextMessageWriter.Pfx_Actual + "\"s\"").And - .Contains(" -> <" + typeof(Serializable).FullName + ">")); - } - - #endregion - - [Test] - public void CanBeNewedUp() - { - Assert.That(Serializable.XmlString("s", 3m), - new DeserializationConstraint( - new XmlDeserializer(), - Has.Property("S").EqualTo("s") - .And.Property("D").EqualTo(3m))); - } - - [Test] - public void CanBeCreatedWithExtension() - { - Assert.That(Serializable.XmlString("s", 3m), - Must.Be.XmlDeserializable( - Has.Property("S").EqualTo("s") - .And.Property("D").EqualTo(3m))); - } - } -} \ No newline at end of file diff --git a/src/Testing.Commons.NUnit.Tests.old/Constraints/XmlSerializationConstraintTester.cs b/src/Testing.Commons.NUnit.Tests.old/Constraints/XmlSerializationConstraintTester.cs deleted file mode 100644 index 4c9cea3..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Constraints/XmlSerializationConstraintTester.cs +++ /dev/null @@ -1,96 +0,0 @@ -using NUnit.Framework; -using NUnit.Framework.Internal; -using Testing.Commons.NUnit.Constraints; -using Testing.Commons.NUnit.Constraints.Support; -using Testing.Commons.NUnit.Tests.Constraints.Subjects; -using Testing.Commons.Serialization; - -namespace Testing.Commons.NUnit.Tests.Constraints -{ - [TestFixture] - public class XmlSerializationConstraintTester : ConstraintTesterBase - { - #region ApplyTo - - [Test] - public void ApplyTo_MatchingSerializable_True() - { - var serializable = new Serializable { D = 3m, S = "s" }; - var subject = new SerializationConstraint(new XmlRoundtripSerializer(), - Is.Not.SameAs(serializable) - .And.Property("S").EqualTo("s") - .And.Property("D").EqualTo(3m)); - - Assert.That(matches(subject, serializable), Is.True); - } - - [Test] - public void ApplyTo_NonSerializable_False() - { - var nonSerializable = new NonSerializable("s"); - var subject = new SerializationConstraint(new XmlRoundtripSerializer(), Is.Not.Null); - - Assert.That(matches(subject, nonSerializable), Is.False); - } - - [Test] - public void ApplyTo_NonMatchingSerializable_False() - { - var serializable = new Serializable { D = 3m, S = "s" }; - var subject = new SerializationConstraint(new XmlRoundtripSerializer(), - Is.Not.SameAs(serializable) - .And.Property("S").EqualTo("sS") - .And.Property("D").EqualTo(3m)); - - Assert.That(matches(subject, serializable), Is.False); - } - - #endregion - - #region WriteMessageTo - - [Test] - public void WriteMessageTo_NonSerializable_ExpectedContainsConstraintExpectations_ActualContainsExpectationsErrorPlusObject() - { - var nonSerializable = new NonSerializable("s"); - var subject = new SerializationConstraint(new XmlRoundtripSerializer(), Is.Not.Null); - - Assert.That(getMessage(subject, nonSerializable), Does - .StartWith(TextMessageWriter.Pfx_Expected + "Deserialized object not null").And - .Contain(TextMessageWriter.Pfx_Actual + "Could not serialize/deserialize object")); - } - - [Test] - public void WriteMessageTo_NonMatchingSerializable_ActualContainsOffendingValueAndActualObject() - { - var serializable = new Serializable { D = 3m, S = "s" }; - var subject = new SerializationConstraint(new XmlRoundtripSerializer(), - Is.Not.SameAs(serializable) - .And.Property("S").EqualTo("sS") - .And.Property("D").EqualTo(3m)); - - Assert.That(getMessage(subject, serializable), Does.Contain(TextMessageWriter.Pfx_Actual + "\"s\"").And - .Contain(" -> <" + typeof(Serializable).FullName + ">")); - } - - #endregion - - [Test] - public void CanBeNewedUp() - { - Assert.That(new Serializable { D = 3m, S = "s" }, - new SerializationConstraint(new XmlRoundtripSerializer(), - Has.Property("S").EqualTo("s") - .And.Property("D").EqualTo(3m))); - } - - [Test] - public void CanBeCreatedWithExtension() - { - Assert.That(new Serializable { D = 3m, S = "s" }, - Must.Be.XmlSerializable( - Has.Property("S").EqualTo("s") - .And.Property("D").EqualTo(3m))); - } - } -} \ No newline at end of file diff --git a/src/Testing.Commons.NUnit.Tests.old/Program.cs b/src/Testing.Commons.NUnit.Tests.old/Program.cs deleted file mode 100644 index f13e9d4..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Program.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Reflection; -using NUnit.Common; -using NUnitLite; - -namespace Testing.Commons.NUnit.Tests -{ - class Program - { - static void Main(string[] args) - { - var writter = new ExtendedTextWrapper(Console.Out); - int exitCode = new AutoRun(typeof(Program).GetTypeInfo().Assembly).Execute(args, writter, Console.In); - Environment.Exit(exitCode); - } - } -} \ No newline at end of file diff --git a/src/Testing.Commons.NUnit.Tests.old/Properties/AssemblyInfo.cs b/src/Testing.Commons.NUnit.Tests.old/Properties/AssemblyInfo.cs deleted file mode 100644 index 6867981..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Testing.Commons.NUnit.Tests")] -[assembly: AssemblyDescription("")] - - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("f2014fe2-af99-4f1a-97df-168202a02337")] \ No newline at end of file diff --git a/src/Testing.Commons.NUnit.Tests.old/Subjects/Address.cs b/src/Testing.Commons.NUnit.Tests.old/Subjects/Address.cs deleted file mode 100644 index 153199b..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Subjects/Address.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Testing.Commons.NUnit.Tests.Subjects -{ - class Address - { - public string AddressLineOne { get; set; } - public string AddressLineTwo { get; set; } - public string City { get; set; } - public string State { get; set; } - public string Zipcode { get; set; } - } -} \ No newline at end of file diff --git a/src/Testing.Commons.NUnit.Tests.old/Subjects/Comparisons/ComparableSubject.cs b/src/Testing.Commons.NUnit.Tests.old/Subjects/Comparisons/ComparableSubject.cs deleted file mode 100644 index 15df221..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Subjects/Comparisons/ComparableSubject.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using NSubstitute; - -namespace Testing.Commons.NUnit.Tests.Subjects.Comparisons -{ - public class ComparableSubject : NamedSubject, IComparable - { - private readonly IComparable _inner; - public ComparableSubject(string name) : base(name) - { - _inner = Substitute.For>(); - } - - public ComparableSubject Setup(ComparableSubject other, int result) - { - _inner.CompareTo(other).Returns(result); - return this; - } - - public int CompareTo(ComparableSubject other) - { - return _inner.CompareTo(other); - } - } - - internal class ComparableSubject : NamedSubject, IComparable - { - private readonly IComparable _inner; - - public ComparableSubject(string name) - : base(name) - { - _inner = Substitute.For>(); - } - - public ComparableSubject Setup(T other, int result) - { - _inner.CompareTo(other).Returns(result); - return this; - } - - public int CompareTo(T other) - { - return _inner.CompareTo(other); - } - } -} \ No newline at end of file diff --git a/src/Testing.Commons.NUnit.Tests.old/Subjects/Comparisons/ComparisonAgainstReference.cs b/src/Testing.Commons.NUnit.Tests.old/Subjects/Comparisons/ComparisonAgainstReference.cs deleted file mode 100644 index 09308f7..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Subjects/Comparisons/ComparisonAgainstReference.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; - -namespace Testing.Commons.NUnit.Tests.Subjects.Comparisons -{ - internal class ComparisonAgainstReference : NamedSubject - { - public ComparisonAgainstReference(string name) : base(name) { } - - public static bool operator >(ComparisonAgainstReference left, string right) - { - return _comparison.GT(left, right); - } - - public static bool operator <(ComparisonAgainstReference left, string right) - { - return _comparison.LT(left, right); - } - - public static bool operator >=(ComparisonAgainstReference left, string right) - { - return _comparison.GTOET(left, right); - } - - public static bool operator <=(ComparisonAgainstReference left, string right) - { - return _comparison.LTOET(left, right); - } - - public static bool operator >(string l, ComparisonAgainstReference r) - { - return _inverse.GT(l, r); - } - - public static bool operator <(string l, ComparisonAgainstReference r) - { - return _inverse.LT(l, r); - } - - public static bool operator >=(string l, ComparisonAgainstReference r) - { - return _inverse.GTOET(l, r); - } - - public static bool operator <=(string l, ComparisonAgainstReference r) - { - return _inverse.LTOET(l, r); - } - - private static ComparisonSubject _comparison; - public static void Setup(Action> comparison) - { - _comparison = new ComparisonSubject(); - comparison(_comparison); - } - - private static ComparisonSubject _inverse; - public static void SetupInverse(Action> comparison) - { - _inverse = new ComparisonSubject(); - comparison(_inverse); - } - } -} \ No newline at end of file diff --git a/src/Testing.Commons.NUnit.Tests.old/Subjects/Comparisons/ComparisonAgainstSelf.cs b/src/Testing.Commons.NUnit.Tests.old/Subjects/Comparisons/ComparisonAgainstSelf.cs deleted file mode 100644 index 75f1a84..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Subjects/Comparisons/ComparisonAgainstSelf.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; - -namespace Testing.Commons.NUnit.Tests.Subjects.Comparisons -{ - internal class ComparisonAgainstSelf : NamedSubject - { - public ComparisonAgainstSelf(string name) : base(name) { } - - public static bool operator >(ComparisonAgainstSelf left, ComparisonAgainstSelf right) - { - return _comparison.GT(left, right); - } - - public static bool operator <(ComparisonAgainstSelf left, ComparisonAgainstSelf right) - { - return _comparison.LT(left, right); - } - - public static bool operator >=(ComparisonAgainstSelf left, ComparisonAgainstSelf right) - { - return _comparison.GTOET(left, right); - } - - public static bool operator <=(ComparisonAgainstSelf left, ComparisonAgainstSelf right) - { - return _comparison.LTOET(left, right); - } - - private static ComparisonSubject _comparison; - public static void Setup(Action> comparison) - { - _comparison = new ComparisonSubject(); - comparison(_comparison); - } - } -} \ No newline at end of file diff --git a/src/Testing.Commons.NUnit.Tests.old/Subjects/Comparisons/ComparisonAgainstValue.cs b/src/Testing.Commons.NUnit.Tests.old/Subjects/Comparisons/ComparisonAgainstValue.cs deleted file mode 100644 index 8285d6e..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Subjects/Comparisons/ComparisonAgainstValue.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; - -namespace Testing.Commons.NUnit.Tests.Subjects.Comparisons -{ - internal class ComparisonAgainstValue : NamedSubject - { - public ComparisonAgainstValue(string name) : base(name) { } - - public static bool operator >(ComparisonAgainstValue left, int right) - { - return _comparison.GT(left, right); - } - - public static bool operator <(ComparisonAgainstValue left, int right) - { - return _comparison.LT(left, right); - } - - public static bool operator >=(ComparisonAgainstValue left, int right) - { - return _comparison.GTOET(left, right); - } - - public static bool operator <=(ComparisonAgainstValue left, int right) - { - return _comparison.LTOET(left, right); - } - - private static ComparisonSubject _comparison; - public static void Setup(Action> comparison) - { - _comparison = new ComparisonSubject(); - comparison(_comparison); - } - } -} diff --git a/src/Testing.Commons.NUnit.Tests.old/Subjects/Comparisons/ComparisonSubject.cs b/src/Testing.Commons.NUnit.Tests.old/Subjects/Comparisons/ComparisonSubject.cs deleted file mode 100644 index f0a03f7..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Subjects/Comparisons/ComparisonSubject.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System; -using NSubstitute; - -namespace Testing.Commons.NUnit.Tests.Subjects.Comparisons -{ - public class ComparisonSubject - { - private static readonly Func _noOp = (_, __) => false; - - public Func GT = _noOp, - LT = _noOp, - GTOET = _noOp, - LTOET = _noOp; - - public ComparisonSubject Gt(T t, U u, bool result) - { - GT = substituteOrSame(GT); - GT.Invoke(t, u).Returns(result); - return this; - } - - public ComparisonSubject Gt(bool result) - { - GT = substituteOrSame(GT); - GT.Invoke(Arg.Any(), Arg.Any()).Returns(result); - return this; - } - - public ComparisonSubject Lt(T t, U u, bool result) - { - LT = LT = substituteOrSame(LT); - LT.Invoke(t, u).Returns(result); - return this; - } - - public ComparisonSubject Lt(bool result) - { - LT = substituteOrSame(LT); - LT.Invoke(Arg.Any(), Arg.Any()).Returns(result); - return this; - } - - public ComparisonSubject Gtoet(T t, U u, bool result) - { - GTOET = substituteOrSame(GTOET); - GTOET.Invoke(t, u).Returns(result); - return this; - } - - public ComparisonSubject Gtoet(bool result) - { - GTOET = substituteOrSame(GTOET); - GTOET.Invoke(Arg.Any(), Arg.Any()).Returns(result); - return this; - } - - public ComparisonSubject Ltoet(T t, U u, bool result) - { - LTOET = substituteOrSame(LTOET); - LTOET.Invoke(t, u).Returns(result); - return this; - } - - public ComparisonSubject Ltoet(bool result) - { - LTOET = substituteOrSame(LTOET); - LTOET.Invoke(Arg.Any(), Arg.Any()).Returns(result); - return this; - } - - private Func substituteOrSame(Func op) - { - return (ReferenceEquals(op, _noOp)) ? Substitute.For>() : op; - } - } -} \ No newline at end of file diff --git a/src/Testing.Commons.NUnit.Tests.old/Subjects/Comparisons/EquatableSubject.cs b/src/Testing.Commons.NUnit.Tests.old/Subjects/Comparisons/EquatableSubject.cs deleted file mode 100644 index fd828c3..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Subjects/Comparisons/EquatableSubject.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using NSubstitute; - -namespace Testing.Commons.NUnit.Tests.Subjects.Comparisons -{ - public class EquatableSubject : NamedSubject, IEquatable - { - private readonly IEquatable _inner; - public EquatableSubject(string name) : base(name) - { - _inner = Substitute.For>(); - } - - public bool Equals(EquatableSubject other) - { - return _inner.Equals(other); - } - - public EquatableSubject Setup(EquatableSubject other, bool result) - { - _inner.Equals(other).Returns(result); - return this; - } - } - - internal class EquatableSubject : NamedSubject, IEquatable - { - private readonly IEquatable _inner; - - public EquatableSubject(string name) - : base(name) - { - _inner = Substitute.For>(); - } - - public EquatableSubject Setup(T other, bool result) - { - _inner.Equals(other).Returns(result); - return this; - } - - public bool Equals(T other) - { - return _inner.Equals(other); - } - } -} \ No newline at end of file diff --git a/src/Testing.Commons.NUnit.Tests.old/Subjects/Customer.cs b/src/Testing.Commons.NUnit.Tests.old/Subjects/Customer.cs deleted file mode 100644 index ae22ab8..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Subjects/Customer.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Testing.Commons.NUnit.Tests.Subjects -{ - class Customer - { - public string Name { get; set; } - public string PhoneNumber { get; set; } - public Address Address { get; set; } - } -} \ No newline at end of file diff --git a/src/Testing.Commons.NUnit.Tests.old/Subjects/CustomerWithCollection.cs b/src/Testing.Commons.NUnit.Tests.old/Subjects/CustomerWithCollection.cs deleted file mode 100644 index 76d8784..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Subjects/CustomerWithCollection.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Collections.Generic; - -namespace Testing.Commons.NUnit.Tests.Subjects -{ - class CustomerWithCollection - { - public string Name { get; set; } - public string PhoneNumber { get; set; } - public IEnumerable
Addresses { get; set; } - } -} \ No newline at end of file diff --git a/src/Testing.Commons.NUnit.Tests.old/Subjects/Equality/Offending/EqualsToNull.cs b/src/Testing.Commons.NUnit.Tests.old/Subjects/Equality/Offending/EqualsToNull.cs deleted file mode 100644 index 8d51538..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Subjects/Equality/Offending/EqualsToNull.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; - -namespace Testing.Commons.NUnit.Tests.Subjects.Equality.Offending -{ - internal class EqualsToNull : IEquatable - { - public EqualsToNull(int value) - { - Value = value; - } - - public int Value { get; private set; } - - public bool Equals(EqualsToNull other) - { - // NOTE: one should never be equal to NULL - if (ReferenceEquals(null, other)) return true; - - if (ReferenceEquals(this, other)) return true; - return other.Value == Value; - } - - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - if (obj.GetType() != typeof(EqualsToNull)) return false; - return Equals((EqualsToNull)obj); - } - - public override int GetHashCode() - { - return Value; - } - } -} diff --git a/src/Testing.Commons.NUnit.Tests.old/Subjects/Equality/Offending/NotEqualToItself.cs b/src/Testing.Commons.NUnit.Tests.old/Subjects/Equality/Offending/NotEqualToItself.cs deleted file mode 100644 index 0cb7056..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Subjects/Equality/Offending/NotEqualToItself.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; - -namespace Testing.Commons.NUnit.Tests.Subjects.Equality.Offending -{ - internal class NotEqualToItself : IEquatable - { - public NotEqualToItself(int value) - { - Value = value; - } - - public int Value { get; private set; } - - public bool Equals(NotEqualToItself other) - { - if (ReferenceEquals(null, other)) return false; - - // NOTE: one should always be equals to oneself - if (ReferenceEquals(this, other)) return false; - return other.Value == Value; - } - - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - if (obj.GetType() != typeof (NotEqualToItself)) return false; - return Equals((NotEqualToItself) obj); - } - - public override int GetHashCode() - { - return Value; - } - } -} diff --git a/src/Testing.Commons.NUnit.Tests.old/Subjects/FlatCustomer.cs b/src/Testing.Commons.NUnit.Tests.old/Subjects/FlatCustomer.cs deleted file mode 100644 index aaff5b2..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Subjects/FlatCustomer.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Testing.Commons.NUnit.Tests.Subjects -{ - class FlatCustomer - { - public string Name { get; set; } - public string PhoneNumber { get; set; } - } -} diff --git a/src/Testing.Commons.NUnit.Tests.old/Subjects/IRaisingSubject.cs b/src/Testing.Commons.NUnit.Tests.old/Subjects/IRaisingSubject.cs deleted file mode 100644 index c39b4e8..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Subjects/IRaisingSubject.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.ComponentModel; - -namespace Testing.Commons.NUnit.Tests.Subjects -{ - public interface IRaisingSubject : INotifyPropertyChanged, INotifyPropertyChanging - { - int I { get; set; } - string S { get; set; } - } -} diff --git a/src/Testing.Commons.NUnit.Tests.old/Subjects/NamedSubject.cs b/src/Testing.Commons.NUnit.Tests.old/Subjects/NamedSubject.cs deleted file mode 100644 index 23d43fe..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Subjects/NamedSubject.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Testing.Commons.NUnit.Tests.Subjects -{ - public class NamedSubject - { - private readonly string _name; - - public NamedSubject(string name) - { - _name = name; - } - - public override string ToString() - { - return _name; - } - } -} \ No newline at end of file diff --git a/src/Testing.Commons.NUnit.Tests.old/Subjects/SubjectWithDependencies.cs b/src/Testing.Commons.NUnit.Tests.old/Subjects/SubjectWithDependencies.cs deleted file mode 100644 index a6365ac..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Subjects/SubjectWithDependencies.cs +++ /dev/null @@ -1,43 +0,0 @@ -namespace Testing.Commons.NUnit.Tests.Subjects -{ - // interfaces must to be public - public interface ISubjectWithDependencies - { - void DoSomethingWithOne(); - void DoSomethingWithTwo(); - void DosomethingWithBoth(); - } - - // implementations can be internal - internal class SubjectWithDependencies : ISubjectWithDependencies - { - private readonly IDependencyOne _one; - private readonly IDependencyTwo _two; - - public SubjectWithDependencies(IDependencyOne one, IDependencyTwo two) - { - _one = one; - _two = two; - } - - public void DoSomethingWithOne() - { - _one.DoSomething(); - } - - public void DoSomethingWithTwo() - { - _two.DoSomethingElse(); - } - - public void DosomethingWithBoth() - { - _one.DoSomething(); - _two.DoSomethingElse(); - } - } - - public interface IDependencyOne { void DoSomething(); } - - public interface IDependencyTwo { void DoSomethingElse(); } -} diff --git a/src/Testing.Commons.NUnit.Tests.old/Testing.Commons.NUnit.Tests.core.csproj b/src/Testing.Commons.NUnit.Tests.old/Testing.Commons.NUnit.Tests.core.csproj deleted file mode 100644 index a189b9c..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Testing.Commons.NUnit.Tests.core.csproj +++ /dev/null @@ -1,38 +0,0 @@ - - - - Exe - netcoreapp1.0 - false - Testing.Commons.NUnit.Tests - Testing.Commons.NUnit.Tests - - - - TRACE;NETCOREAPP1_0 - - - - TRACE;DEBUG;NETCOREAPP1_0 - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Testing.Commons.NUnit.Tests.old/Testing.Commons.NUnit.Tests.csproj b/src/Testing.Commons.NUnit.Tests.old/Testing.Commons.NUnit.Tests.csproj deleted file mode 100644 index 9befac4..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/Testing.Commons.NUnit.Tests.csproj +++ /dev/null @@ -1,117 +0,0 @@ - - - - Debug - AnyCPU - 8.0.30703 - 2.0 - {91C05746-024C-4232-9A66-442821A52980} - Library - Properties - Testing.Commons.NUnit.Tests - Testing.Commons.NUnit.Tests - v4.0 - 512 - false - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\..\packages\NSubstitute.2.0.3\lib\net40\NSubstitute.dll - - - ..\..\packages\NUnit.3.6.1\lib\net40\nunit.framework.dll - - - - - - - - - - Properties\NUnit_AssemblyInfo.cs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {D1EC2C82-5C90-43B7-BDAB-A37C8C355EF6} - Testing.Commons.NUnit - - - {45732451-E1A2-4CAC-88C9-D52F055883D3} - Testing.Commons - - - - - - - - - \ No newline at end of file diff --git a/src/Testing.Commons.NUnit.Tests.old/packages.config b/src/Testing.Commons.NUnit.Tests.old/packages.config deleted file mode 100644 index 5398b3f..0000000 --- a/src/Testing.Commons.NUnit.Tests.old/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/Testing.Commons.NUnit/ArrangingTest.cs b/src/Testing.Commons.NUnit/ArrangingTest.cs index e408b22..efec019 100644 --- a/src/Testing.Commons.NUnit/ArrangingTest.cs +++ b/src/Testing.Commons.NUnit/ArrangingTest.cs @@ -42,7 +42,7 @@ public void Cleanup() protected abstract TSubject initSubject(); /// - /// Override thos method to perform cleanup tasks after every test. + /// Override this method to perform cleanup tasks after every test. /// protected virtual void doCleanup() { } } diff --git a/src/Testing.Commons.NUnit/Contraints/Closeness.cs b/src/Testing.Commons.NUnit/Constraints/Closeness.cs similarity index 100% rename from src/Testing.Commons.NUnit/Contraints/Closeness.cs rename to src/Testing.Commons.NUnit/Constraints/Closeness.cs diff --git a/src/Testing.Commons.NUnit/Contraints/ComposablePropertyConstraint.Extensions.cs b/src/Testing.Commons.NUnit/Constraints/ComposablePropertyConstraint.Extensions.cs similarity index 100% rename from src/Testing.Commons.NUnit/Contraints/ComposablePropertyConstraint.Extensions.cs rename to src/Testing.Commons.NUnit/Constraints/ComposablePropertyConstraint.Extensions.cs diff --git a/src/Testing.Commons.NUnit/Contraints/ComposablePropertyConstraint.cs b/src/Testing.Commons.NUnit/Constraints/ComposablePropertyConstraint.cs similarity index 96% rename from src/Testing.Commons.NUnit/Contraints/ComposablePropertyConstraint.cs rename to src/Testing.Commons.NUnit/Constraints/ComposablePropertyConstraint.cs index 4381f2c..9a5f3d4 100644 --- a/src/Testing.Commons.NUnit/Contraints/ComposablePropertyConstraint.cs +++ b/src/Testing.Commons.NUnit/Constraints/ComposablePropertyConstraint.cs @@ -1,5 +1,6 @@ using System.Linq.Expressions; using NUnit.Framework.Constraints; +using Testing.Commons.NUnit.Constraints.Support; namespace Testing.Commons.NUnit.Constraints; diff --git a/src/Testing.Commons.NUnit/Contraints/ConjunctionConstraint.Extensions.cs b/src/Testing.Commons.NUnit/Constraints/ConjunctionConstraint.Extensions.cs similarity index 100% rename from src/Testing.Commons.NUnit/Contraints/ConjunctionConstraint.Extensions.cs rename to src/Testing.Commons.NUnit/Constraints/ConjunctionConstraint.Extensions.cs diff --git a/src/Testing.Commons.NUnit/Contraints/ConjunctionConstraint.cs b/src/Testing.Commons.NUnit/Constraints/ConjunctionConstraint.cs similarity index 97% rename from src/Testing.Commons.NUnit/Contraints/ConjunctionConstraint.cs rename to src/Testing.Commons.NUnit/Constraints/ConjunctionConstraint.cs index bf8870d..7f58a9a 100644 --- a/src/Testing.Commons.NUnit/Contraints/ConjunctionConstraint.cs +++ b/src/Testing.Commons.NUnit/Constraints/ConjunctionConstraint.cs @@ -44,7 +44,7 @@ public override ConstraintResult ApplyTo(TActual actual) if (!result.IsSuccess) { _beingMatched = constraint; - return new ConjuctionConstraintResult(this, actual, result); + return new ConjuctionConstraintResult(this, actual!, result); } } return new ConstraintResult(this, actual, true); @@ -65,7 +65,6 @@ public override string Description sb.Append(_beingMatched?.Description); return sb.ToString(); } - protected set { } } internal class ConjuctionConstraintResult : ConstraintResult diff --git a/src/Testing.Commons.NUnit/Contraints/ConstrainedEnumerableConstraint.Extensions.cs b/src/Testing.Commons.NUnit/Constraints/ConstrainedEnumerableConstraint.Extensions.cs similarity index 100% rename from src/Testing.Commons.NUnit/Contraints/ConstrainedEnumerableConstraint.Extensions.cs rename to src/Testing.Commons.NUnit/Constraints/ConstrainedEnumerableConstraint.Extensions.cs diff --git a/src/Testing.Commons.NUnit/Contraints/ConstrainedEnumerableConstraint.cs b/src/Testing.Commons.NUnit/Constraints/ConstrainedEnumerableConstraint.cs similarity index 99% rename from src/Testing.Commons.NUnit/Contraints/ConstrainedEnumerableConstraint.cs rename to src/Testing.Commons.NUnit/Constraints/ConstrainedEnumerableConstraint.cs index 0cf0732..bb9140b 100644 --- a/src/Testing.Commons.NUnit/Contraints/ConstrainedEnumerableConstraint.cs +++ b/src/Testing.Commons.NUnit/Constraints/ConstrainedEnumerableConstraint.cs @@ -129,6 +129,8 @@ public override ConstraintResult ApplyTo(TActual actual) return new IndexedResult(_items, _index, _constraint, _constraint.ApplyTo(actual)); } + public override string Description { get; } + class IndexedResult : ConstraintResult { private readonly Array _items; diff --git a/src/Testing.Commons.NUnit/Contraints/DelegatingConstraint.cs b/src/Testing.Commons.NUnit/Constraints/DelegatingConstraint.cs similarity index 96% rename from src/Testing.Commons.NUnit/Contraints/DelegatingConstraint.cs rename to src/Testing.Commons.NUnit/Constraints/DelegatingConstraint.cs index e044b3a..05e4c0d 100644 --- a/src/Testing.Commons.NUnit/Contraints/DelegatingConstraint.cs +++ b/src/Testing.Commons.NUnit/Constraints/DelegatingConstraint.cs @@ -20,7 +20,7 @@ public abstract class DelegatingConstraint : Constraint /// A ConstraintResult public override ConstraintResult ApplyTo(TActual actual) { - return new DelegatingResult(Delegate, matches(actual)); + return new DelegatingResult(Delegate, matches(actual!)); } /// diff --git a/src/Testing.Commons.NUnit/Contraints/DeserializationConstraint.Extensions.cs b/src/Testing.Commons.NUnit/Constraints/DeserializationConstraint.Extensions.cs similarity index 100% rename from src/Testing.Commons.NUnit/Contraints/DeserializationConstraint.Extensions.cs rename to src/Testing.Commons.NUnit/Constraints/DeserializationConstraint.Extensions.cs diff --git a/src/Testing.Commons.NUnit/Contraints/DeserializationConstraint.cs b/src/Testing.Commons.NUnit/Constraints/DeserializationConstraint.cs similarity index 95% rename from src/Testing.Commons.NUnit/Contraints/DeserializationConstraint.cs rename to src/Testing.Commons.NUnit/Constraints/DeserializationConstraint.cs index e0f0cec..c93da07 100644 --- a/src/Testing.Commons.NUnit/Contraints/DeserializationConstraint.cs +++ b/src/Testing.Commons.NUnit/Constraints/DeserializationConstraint.cs @@ -43,7 +43,7 @@ public override ConstraintResult ApplyTo([NotNull] TActual actual) try { // do not know why we need to use null coalescing op - deserialized = getDeserializedObject(actual.ToString() ?? string.Empty); + deserialized = getDeserializedObject(actual!.ToString() ?? string.Empty); result = _constraintOverDeserialized.ApplyTo(deserialized); } catch (Exception caught) @@ -51,7 +51,7 @@ public override ConstraintResult ApplyTo([NotNull] TActual actual) ex = caught; } #pragma warning restore CA1031 - return new DeserializationResult(ex, deserialized, result, this, actual, (result?.IsSuccess).GetValueOrDefault()); + return new DeserializationResult(ex, deserialized, result, this, actual!, (result?.IsSuccess).GetValueOrDefault()); } diff --git a/src/Testing.Commons.NUnit/Contraints/EnumerableTallyConstraint.Extensions.cs b/src/Testing.Commons.NUnit/Constraints/EnumerableTallyConstraint.Extensions.cs similarity index 100% rename from src/Testing.Commons.NUnit/Contraints/EnumerableTallyConstraint.Extensions.cs rename to src/Testing.Commons.NUnit/Constraints/EnumerableTallyConstraint.Extensions.cs diff --git a/src/Testing.Commons.NUnit/Contraints/EnumerableTallyConstraint.cs b/src/Testing.Commons.NUnit/Constraints/EnumerableTallyConstraint.cs similarity index 94% rename from src/Testing.Commons.NUnit/Contraints/EnumerableTallyConstraint.cs rename to src/Testing.Commons.NUnit/Constraints/EnumerableTallyConstraint.cs index 94f1b41..e14ae1f 100644 --- a/src/Testing.Commons.NUnit/Contraints/EnumerableTallyConstraint.cs +++ b/src/Testing.Commons.NUnit/Constraints/EnumerableTallyConstraint.cs @@ -35,14 +35,17 @@ public override ConstraintResult ApplyTo(TActual actual) ConstraintResult result = _beingMatched.ApplyTo(actual); if (result.IsSuccess) { - var collection = (IEnumerable)actual; - ushort count = calculateCount(collection); + var collection = (IEnumerable)actual!; + ushort count = calculateCount(collection!); _beingMatched = new CountConstraint(_countConstraint, collection); result = _beingMatched.ApplyTo(count); } return result; } + /// + public override string Description { get; } + private static ushort calculateCount(IEnumerable current) { ushort num = 0; @@ -65,7 +68,7 @@ internal class TypeRevealingConstraint : InstanceOfTypeConstraint public override ConstraintResult ApplyTo(TActual actual) { - return new TypeRevealingResult(this, actual, base.ApplyTo(actual)); + return new TypeRevealingResult(this, actual!, base.ApplyTo(actual)); } class TypeRevealingResult : ConstraintResult diff --git a/src/Testing.Commons.NUnit/Contraints/JsonEqualConstraint.Extensions.cs b/src/Testing.Commons.NUnit/Constraints/JsonEqualConstraint.Extensions.cs similarity index 100% rename from src/Testing.Commons.NUnit/Contraints/JsonEqualConstraint.Extensions.cs rename to src/Testing.Commons.NUnit/Constraints/JsonEqualConstraint.Extensions.cs diff --git a/src/Testing.Commons.NUnit/Contraints/JsonEqualConstraint.cs b/src/Testing.Commons.NUnit/Constraints/JsonEqualConstraint.cs similarity index 100% rename from src/Testing.Commons.NUnit/Contraints/JsonEqualConstraint.cs rename to src/Testing.Commons.NUnit/Constraints/JsonEqualConstraint.cs diff --git a/src/Testing.Commons.NUnit/Contraints/JsonExtensions.cs b/src/Testing.Commons.NUnit/Constraints/JsonExtensions.cs similarity index 100% rename from src/Testing.Commons.NUnit/Contraints/JsonExtensions.cs rename to src/Testing.Commons.NUnit/Constraints/JsonExtensions.cs diff --git a/src/Testing.Commons.NUnit/Contraints/MatchingConstraint.Extensions.cs b/src/Testing.Commons.NUnit/Constraints/MatchingConstraint.Extensions.cs similarity index 100% rename from src/Testing.Commons.NUnit/Contraints/MatchingConstraint.Extensions.cs rename to src/Testing.Commons.NUnit/Constraints/MatchingConstraint.Extensions.cs diff --git a/src/Testing.Commons.NUnit/Contraints/MatchingConstraint.cs b/src/Testing.Commons.NUnit/Constraints/MatchingConstraint.cs similarity index 97% rename from src/Testing.Commons.NUnit/Contraints/MatchingConstraint.cs rename to src/Testing.Commons.NUnit/Constraints/MatchingConstraint.cs index 446f39a..603b608 100644 --- a/src/Testing.Commons.NUnit/Contraints/MatchingConstraint.cs +++ b/src/Testing.Commons.NUnit/Constraints/MatchingConstraint.cs @@ -41,7 +41,7 @@ public override ConstraintResult ApplyTo(TActual actual) _writer.GetFormattedResults(); _exposed = _writer.Exposed; } - return new MatchingResult(_exposed, this, actual, matched); + return new MatchingResult(_exposed, this, actual!, matched); } /// diff --git a/src/Testing.Commons.NUnit/Contraints/NoPropertyChangedConstraint.Extensions.cs b/src/Testing.Commons.NUnit/Constraints/NoPropertyChangedConstraint.Extensions.cs similarity index 100% rename from src/Testing.Commons.NUnit/Contraints/NoPropertyChangedConstraint.Extensions.cs rename to src/Testing.Commons.NUnit/Constraints/NoPropertyChangedConstraint.Extensions.cs diff --git a/src/Testing.Commons.NUnit/Contraints/NoPropertyChangedConstraint.cs b/src/Testing.Commons.NUnit/Constraints/NoPropertyChangedConstraint.cs similarity index 100% rename from src/Testing.Commons.NUnit/Contraints/NoPropertyChangedConstraint.cs rename to src/Testing.Commons.NUnit/Constraints/NoPropertyChangedConstraint.cs diff --git a/src/Testing.Commons.NUnit/Contraints/NoPropertyChangingConstraint.Extensions.cs b/src/Testing.Commons.NUnit/Constraints/NoPropertyChangingConstraint.Extensions.cs similarity index 100% rename from src/Testing.Commons.NUnit/Contraints/NoPropertyChangingConstraint.Extensions.cs rename to src/Testing.Commons.NUnit/Constraints/NoPropertyChangingConstraint.Extensions.cs diff --git a/src/Testing.Commons.NUnit/Contraints/NoPropertyChangingConstraint.cs b/src/Testing.Commons.NUnit/Constraints/NoPropertyChangingConstraint.cs similarity index 100% rename from src/Testing.Commons.NUnit/Contraints/NoPropertyChangingConstraint.cs rename to src/Testing.Commons.NUnit/Constraints/NoPropertyChangingConstraint.cs diff --git a/src/Testing.Commons.NUnit/Contraints/NoRaisingConstraint.cs b/src/Testing.Commons.NUnit/Constraints/NoRaisingConstraint.cs similarity index 96% rename from src/Testing.Commons.NUnit/Contraints/NoRaisingConstraint.cs rename to src/Testing.Commons.NUnit/Constraints/NoRaisingConstraint.cs index fc4183a..7cd7ac9 100644 --- a/src/Testing.Commons.NUnit/Contraints/NoRaisingConstraint.cs +++ b/src/Testing.Commons.NUnit/Constraints/NoRaisingConstraint.cs @@ -45,7 +45,7 @@ protected void OnEventRaised(TEventArgs e) /// A ConstraintResult public override ConstraintResult ApplyTo(TActual actual) { - return new NoRaisingResult(EventName, this, actual, !_eventRaised); + return new NoRaisingResult(EventName, this, actual!, !_eventRaised); } /// diff --git a/src/Testing.Commons.NUnit/Contraints/PropertyChangedConstraint.Extensions.cs b/src/Testing.Commons.NUnit/Constraints/PropertyChangedConstraint.Extensions.cs similarity index 100% rename from src/Testing.Commons.NUnit/Contraints/PropertyChangedConstraint.Extensions.cs rename to src/Testing.Commons.NUnit/Constraints/PropertyChangedConstraint.Extensions.cs diff --git a/src/Testing.Commons.NUnit/Contraints/PropertyChangedConstraint.cs b/src/Testing.Commons.NUnit/Constraints/PropertyChangedConstraint.cs similarity index 100% rename from src/Testing.Commons.NUnit/Contraints/PropertyChangedConstraint.cs rename to src/Testing.Commons.NUnit/Constraints/PropertyChangedConstraint.cs diff --git a/src/Testing.Commons.NUnit/Contraints/PropertyChangingConstraint.Extensions.cs b/src/Testing.Commons.NUnit/Constraints/PropertyChangingConstraint.Extensions.cs similarity index 100% rename from src/Testing.Commons.NUnit/Contraints/PropertyChangingConstraint.Extensions.cs rename to src/Testing.Commons.NUnit/Constraints/PropertyChangingConstraint.Extensions.cs diff --git a/src/Testing.Commons.NUnit/Contraints/PropertyChangingConstraint.cs b/src/Testing.Commons.NUnit/Constraints/PropertyChangingConstraint.cs similarity index 100% rename from src/Testing.Commons.NUnit/Contraints/PropertyChangingConstraint.cs rename to src/Testing.Commons.NUnit/Constraints/PropertyChangingConstraint.cs diff --git a/src/Testing.Commons.NUnit/Contraints/RaisingConstraint.cs b/src/Testing.Commons.NUnit/Constraints/RaisingConstraint.cs similarity index 98% rename from src/Testing.Commons.NUnit/Contraints/RaisingConstraint.cs rename to src/Testing.Commons.NUnit/Constraints/RaisingConstraint.cs index ef2dacf..5004530 100644 --- a/src/Testing.Commons.NUnit/Contraints/RaisingConstraint.cs +++ b/src/Testing.Commons.NUnit/Constraints/RaisingConstraint.cs @@ -2,6 +2,7 @@ using System.Linq.Expressions; using NUnit.Framework; using NUnit.Framework.Constraints; +using Testing.Commons.NUnit.Constraints.Support; namespace Testing.Commons.NUnit.Constraints; diff --git a/src/Testing.Commons.NUnit/Contraints/SerializationConstraint.Extensions..cs b/src/Testing.Commons.NUnit/Constraints/SerializationConstraint.Extensions..cs similarity index 100% rename from src/Testing.Commons.NUnit/Contraints/SerializationConstraint.Extensions..cs rename to src/Testing.Commons.NUnit/Constraints/SerializationConstraint.Extensions..cs diff --git a/src/Testing.Commons.NUnit/Contraints/SerializationConstraint.cs b/src/Testing.Commons.NUnit/Constraints/SerializationConstraint.cs similarity index 94% rename from src/Testing.Commons.NUnit/Contraints/SerializationConstraint.cs rename to src/Testing.Commons.NUnit/Constraints/SerializationConstraint.cs index 6480449..317bfa0 100644 --- a/src/Testing.Commons.NUnit/Contraints/SerializationConstraint.cs +++ b/src/Testing.Commons.NUnit/Constraints/SerializationConstraint.cs @@ -46,7 +46,7 @@ public override ConstraintResult ApplyTo(TActual actual) #pragma warning disable CA1031 try { - T deserialized = getDeserializedObject((T)((object)actual)); + T deserialized = getDeserializedObject((T)((object)actual!)); result = _constraintOverDeserialized.ApplyTo(deserialized); } catch (Exception caught) @@ -54,7 +54,7 @@ public override ConstraintResult ApplyTo(TActual actual) ex = caught; } #pragma warning restore CA1031 - return new SerializationResult(ex, result, this, actual, (result?.IsSuccess).GetValueOrDefault()); + return new SerializationResult(ex, result, this, actual!, (result?.IsSuccess).GetValueOrDefault()); } /// diff --git a/src/Testing.Commons.NUnit/Contraints/Support/ConstraintTesterBase.cs b/src/Testing.Commons.NUnit/Constraints/Support/ConstraintTesterBase.cs similarity index 88% rename from src/Testing.Commons.NUnit/Contraints/Support/ConstraintTesterBase.cs rename to src/Testing.Commons.NUnit/Constraints/Support/ConstraintTesterBase.cs index 413489f..e2d5ed6 100644 --- a/src/Testing.Commons.NUnit/Contraints/Support/ConstraintTesterBase.cs +++ b/src/Testing.Commons.NUnit/Constraints/Support/ConstraintTesterBase.cs @@ -10,12 +10,12 @@ namespace Testing.Commons.NUnit.Constraints.Support; public abstract class ConstraintTesterBase { /// - /// Gets the error message of a failing contraint. + /// Gets the error message of a failing constraint. /// /// Constraint to be tested. /// The value to be tested. /// Type of the tested value. - /// The message of a failing contraint or if is not failing. + /// The message of a failing constraint or if is not failing. protected static string getMessage([NotNull] Constraint subject, T actual) { string message = getMessage(subject.ApplyTo(actual)); @@ -23,12 +23,12 @@ protected static string getMessage([NotNull] Constraint subject, T actual) } /// - /// Gets the error message of a failing contraint. + /// Gets the error message of a failing constraint. /// /// Constraint to be tested. /// The action to be tested. /// Type of the tested value. - /// The message of a failing contraint or if is not failing. + /// The message of a failing constraint or if is not failing. protected static string getMessage([NotNull] Constraint subject, ActualValueDelegate actual) { string message = getMessage(subject.ApplyTo(actual)); diff --git a/src/Testing.Commons.NUnit/Contraints/Support/ExposingWriter.cs b/src/Testing.Commons.NUnit/Constraints/Support/ExposingWriter.cs similarity index 100% rename from src/Testing.Commons.NUnit/Contraints/Support/ExposingWriter.cs rename to src/Testing.Commons.NUnit/Constraints/Support/ExposingWriter.cs diff --git a/src/Testing.Commons.NUnit/Contraints/Support/MessageWriterExtensions.cs b/src/Testing.Commons.NUnit/Constraints/Support/MessageWriterExtensions.cs similarity index 100% rename from src/Testing.Commons.NUnit/Contraints/Support/MessageWriterExtensions.cs rename to src/Testing.Commons.NUnit/Constraints/Support/MessageWriterExtensions.cs diff --git a/src/Testing.Commons.NUnit/Contraints/Support/Name.cs b/src/Testing.Commons.NUnit/Constraints/Support/Name.cs similarity index 95% rename from src/Testing.Commons.NUnit/Contraints/Support/Name.cs rename to src/Testing.Commons.NUnit/Constraints/Support/Name.cs index 4027d40..e6c6287 100644 --- a/src/Testing.Commons.NUnit/Contraints/Support/Name.cs +++ b/src/Testing.Commons.NUnit/Constraints/Support/Name.cs @@ -2,7 +2,7 @@ using System.Reflection; using Testing.Commons.NUnit.Resources; -namespace Testing.Commons.NUnit.Constraints +namespace Testing.Commons.NUnit.Constraints.Support { internal static class Name { diff --git a/src/Testing.Commons.NUnit/Contraints/Support/WritableEqualityResult.cs b/src/Testing.Commons.NUnit/Constraints/Support/WritableEqualityResult.cs similarity index 84% rename from src/Testing.Commons.NUnit/Contraints/Support/WritableEqualityResult.cs rename to src/Testing.Commons.NUnit/Constraints/Support/WritableEqualityResult.cs index 9e4cc8e..e9a66a5 100644 --- a/src/Testing.Commons.NUnit/Contraints/Support/WritableEqualityResult.cs +++ b/src/Testing.Commons.NUnit/Constraints/Support/WritableEqualityResult.cs @@ -5,7 +5,7 @@ namespace Testing.Commons.NUnit.Constraints.Support; /// -/// Adapter that allows writting an instance of to a . +/// Adapter that allows writing an instance of to a . /// internal class WritableEqualityResult : EqualityResult { @@ -32,9 +32,9 @@ public void WriteActual(MessageWriter writer) { writer.Write("element was missing"); } - else if (Actual is IUnexpectedElement) + else if (Actual is IUnexpectedElement element) { - writer.WriteActualValue(((IUnexpectedElement)Actual).Element); + writer.WriteActualValue(element.Element); } else { diff --git a/src/Testing.Commons.NUnit/Contraints/Time.extensions.cs b/src/Testing.Commons.NUnit/Constraints/Time.extensions.cs similarity index 100% rename from src/Testing.Commons.NUnit/Contraints/Time.extensions.cs rename to src/Testing.Commons.NUnit/Constraints/Time.extensions.cs diff --git a/src/Testing.Commons.NUnit/Testing.Commons.NUnit.csproj b/src/Testing.Commons.NUnit/Testing.Commons.NUnit.csproj index 80d9901..3ab0915 100644 --- a/src/Testing.Commons.NUnit/Testing.Commons.NUnit.csproj +++ b/src/Testing.Commons.NUnit/Testing.Commons.NUnit.csproj @@ -30,10 +30,10 @@ - 5.0.0.0 - 5.0.0.0 - 5.0.0.0 - 5.0.0.0 + 6.0.0.0 + 6.0.0.0 + 6.0.0.0 + 6.0.0.0 @@ -53,7 +53,7 @@ - + diff --git a/tests/Testing.Commons.NUnit.Tests/Constraints/ComposablePropertyConstraintTester.cs b/tests/Testing.Commons.NUnit.Tests/Constraints/ComposablePropertyConstraintTester.cs index e73ed77..4c45cb2 100644 --- a/tests/Testing.Commons.NUnit.Tests/Constraints/ComposablePropertyConstraintTester.cs +++ b/tests/Testing.Commons.NUnit.Tests/Constraints/ComposablePropertyConstraintTester.cs @@ -1,4 +1,3 @@ -using NUnit.Framework.Constraints; using NUnit.Framework.Internal; using Testing.Commons.NUnit.Constraints; using Testing.Commons.NUnit.Constraints.Support; @@ -50,7 +49,6 @@ public void WriteMessageTo_FailingConstraint_ContainsMember() } - [Test] public void WriteMessageTo_FailingConstraint_ContainsSpecificMessage() { @@ -62,13 +60,12 @@ public void WriteMessageTo_FailingConstraint_ContainsSpecificMessage() } - [Test] public void WriteMessageTo_FailingConstraint_ActualContainsActual() { var subject = new ComposablePropertyConstraint( - nameof(FlatCustomer.Name), - Is.EqualTo("lol")); + nameof(FlatCustomer.Name), + Is.EqualTo("lol")); Assert.That(getMessage(subject, new FlatCustomer { Name = "Bob" }), Does.Contain(TextMessageWriter.Pfx_Actual + "\"Bob\"") @@ -76,5 +73,4 @@ public void WriteMessageTo_FailingConstraint_ActualContainsActual() } #endregion - } diff --git a/tests/Testing.Commons.NUnit.Tests/Constraints/ConjuctionContraintTester.cs b/tests/Testing.Commons.NUnit.Tests/Constraints/ConjuctionConstraintTester.cs similarity index 98% rename from tests/Testing.Commons.NUnit.Tests/Constraints/ConjuctionContraintTester.cs rename to tests/Testing.Commons.NUnit.Tests/Constraints/ConjuctionConstraintTester.cs index 6d38c02..44fd160 100644 --- a/tests/Testing.Commons.NUnit.Tests/Constraints/ConjuctionContraintTester.cs +++ b/tests/Testing.Commons.NUnit.Tests/Constraints/ConjuctionConstraintTester.cs @@ -7,7 +7,7 @@ namespace Testing.Commons.NUnit.Tests.Constraints; [TestFixture] -public class ConjuctionContraintTester : ConstraintTesterBase +public class ConjuctionConstraintTester : ConstraintTesterBase { #region ApplyTo diff --git a/tests/Testing.Commons.NUnit.Tests/Constraints/DateContraintsTester.cs b/tests/Testing.Commons.NUnit.Tests/Constraints/DateConstraintsTester.cs similarity index 98% rename from tests/Testing.Commons.NUnit.Tests/Constraints/DateContraintsTester.cs rename to tests/Testing.Commons.NUnit.Tests/Constraints/DateConstraintsTester.cs index 43ea7a0..c944465 100644 --- a/tests/Testing.Commons.NUnit.Tests/Constraints/DateContraintsTester.cs +++ b/tests/Testing.Commons.NUnit.Tests/Constraints/DateConstraintsTester.cs @@ -1,5 +1,3 @@ -using System; -using NUnit.Framework; using Testing.Commons.NUnit.Constraints; using Testing.Commons.Time; diff --git a/tests/Testing.Commons.NUnit.Tests/Constraints/EnumerableTallyConstraintTester.cs b/tests/Testing.Commons.NUnit.Tests/Constraints/EnumerableTallyConstraintTester.cs index 9c0ba70..7ac3fed 100644 --- a/tests/Testing.Commons.NUnit.Tests/Constraints/EnumerableTallyConstraintTester.cs +++ b/tests/Testing.Commons.NUnit.Tests/Constraints/EnumerableTallyConstraintTester.cs @@ -119,6 +119,7 @@ public void WriteMessageTo_EnumerableWithNotMatchingCount_ExpectedContainsCount_ { IEnumerable e = new[] { '1', '2', '3' }.Where(i => i <= '2'); var subject = new EnumerableTallyConstraint(Is.GreaterThan(4)); + Assert.That(getMessage(subject, e), Does .StartWith(TextMessageWriter.Pfx_Expected + "number of elements greater than 4").And .Contains(TextMessageWriter.Pfx_Actual + "2 -> < '1', '2' >")); diff --git a/tests/Testing.Commons.NUnit.Tests/Testing.Commons.NUnit.Tests.csproj b/tests/Testing.Commons.NUnit.Tests/Testing.Commons.NUnit.Tests.csproj index 3127d8c..d7d896e 100644 --- a/tests/Testing.Commons.NUnit.Tests/Testing.Commons.NUnit.Tests.csproj +++ b/tests/Testing.Commons.NUnit.Tests/Testing.Commons.NUnit.Tests.csproj @@ -10,12 +10,12 @@ - - - + + + - - + + diff --git a/tests/Testing.Commons.Tests/Testing.Commons.Tests.csproj b/tests/Testing.Commons.Tests/Testing.Commons.Tests.csproj index 0bfb14c..0d95630 100644 --- a/tests/Testing.Commons.Tests/Testing.Commons.Tests.csproj +++ b/tests/Testing.Commons.Tests/Testing.Commons.Tests.csproj @@ -10,11 +10,11 @@ - - + + - - + +