diff --git a/Contracts/Synergy.Contracts.Test/Failures/Because/Fail.Because.cs b/Contracts/Synergy.Contracts.Test/Failures/Because/Fail.Because.cs new file mode 100644 index 0000000..f7b66b0 --- /dev/null +++ b/Contracts/Synergy.Contracts.Test/Failures/Because/Fail.Because.cs @@ -0,0 +1,80 @@ +using Synergy.Contracts.Samples.Domain; +using Xunit; + +namespace Synergy.Contracts.Test.Failures.Because; + +public class FailBecauseTest +{ + [Fact] + public void BecauseWith0Arguments() + { + // ACT + var exception = Fail.Because("Always"); + + // ASSERT + Assert.NotNull(exception); + Assert.Equal("Always", exception.Message); + } + + [Fact] + public void BecauseWith1Argument() + { + // ACT + // ReSharper disable once HeapView.BoxingAllocation + var exception = Fail.Because("Always {0}", 1); + + // ASSERT + Assert.NotNull(exception); + Assert.Equal("Always 1", exception.Message); + } + + [Fact] + public void BecauseWith2Arguments() + { + // ACT + // ReSharper disable once HeapView.BoxingAllocation + var exception = Fail.Because("Always {0} {1}", "fails", 1); + + // ASSERT + Assert.NotNull(exception); + Assert.Equal("Always fails 1", exception.Message); + } + + [Fact] + public void BecauseWith3Arguments() + { + // ACT + // ReSharper disable once HeapView.BoxingAllocation + var exception = Fail.Because("Always {0} {1} {2}", "fails", 1, "times"); + + // ASSERT + Assert.NotNull(exception); + Assert.Equal("Always fails 1 times", exception.Message); + } + + [Fact] + public void BecauseWithNArguments() + { + // ACT + // ReSharper disable once HeapView.BoxingAllocation + var exception = Fail.Because("Always {0} {1} {2} {3}", "fails", 1, "times", "frequently"); + + // ASSERT + Assert.NotNull(exception); + Assert.Equal("Always fails 1 times frequently", exception.Message); + } + + [Fact] + public void BecauseSample() + { + // ARRANGE + var contractor = new Contractor(); + + // ACT + var exception = Assert.Throws( + () => contractor.SetPersonName("Marcin", "Celej")); + + // ASSERT + Assert.Equal("Not implemented yet", exception.Message); + } +} \ No newline at end of file diff --git a/Contracts/Synergy.Contracts.Test/Failures/FailBecauseTest.cs b/Contracts/Synergy.Contracts.Test/Failures/FailBecauseTest.cs deleted file mode 100644 index 5d56427..0000000 --- a/Contracts/Synergy.Contracts.Test/Failures/FailBecauseTest.cs +++ /dev/null @@ -1,18 +0,0 @@ -using NUnit.Framework; - -namespace Synergy.Contracts.Test.Failures -{ - [TestFixture] - public class FailBecauseTest - { - [Test] - public void fail_because_message() - { - // ACT - var exception = Fail.Because("failure description"); - - // ASSERT - Assert.That(exception.Message, Is.EqualTo("failure description")); - } - } -} \ No newline at end of file diff --git a/Contracts/Synergy.Contracts.Test/Failures/FailTest.cs b/Contracts/Synergy.Contracts.Test/Failures/FailTest.cs deleted file mode 100644 index 669e7ed..0000000 --- a/Contracts/Synergy.Contracts.Test/Failures/FailTest.cs +++ /dev/null @@ -1,86 +0,0 @@ -using NUnit.Framework; -using Synergy.Contracts.Samples.Domain; - -namespace Synergy.Contracts.Test.Failures -{ - [TestFixture] - public class FailTest - { - #region Fail.Because - - [Test] - public void BecauseWith0Arguments() - { - // ACT - DesignByContractViolationException exception = Fail.Because("Always"); - - // ASSERT - Assert.That(exception, Is.Not.Null); - Assert.That(exception.Message, Is.EqualTo("Always")); - } - - [Test] - public void BecauseWith1Argument() - { - // ACT - // ReSharper disable once HeapView.BoxingAllocation - DesignByContractViolationException exception = Fail.Because("Always {0}", 1); - - // ASSERT - Assert.That(exception, Is.Not.Null); - Assert.That(exception.Message, Is.EqualTo("Always 1")); - } - - [Test] - public void BecauseWith2Arguments() - { - // ACT - // ReSharper disable once HeapView.BoxingAllocation - DesignByContractViolationException exception = Fail.Because("Always {0} {1}", "fails", 1); - - // ASSERT - Assert.That(exception, Is.Not.Null); - Assert.That(exception.Message, Is.EqualTo("Always fails 1")); - } - - [Test] - public void BecauseWith3Arguments() - { - // ACT - // ReSharper disable once HeapView.BoxingAllocation - DesignByContractViolationException exception = Fail.Because("Always {0} {1} {2}", "fails", 1, "times"); - - // ASSERT - Assert.That(exception, Is.Not.Null); - Assert.That(exception.Message, Is.EqualTo("Always fails 1 times")); - } - - [Test] - public void BecauseWithNArguments() - { - // ACT - // ReSharper disable once HeapView.BoxingAllocation - DesignByContractViolationException exception = Fail.Because("Always {0} {1} {2} {3}", "fails", 1, "times", "frequently"); - - // ASSERT - Assert.That(exception, Is.Not.Null); - Assert.That(exception.Message, Is.EqualTo("Always fails 1 times frequently")); - } - - [Test] - public void BecauseSample() - { - // ARRANGE - var contractor = new Contractor(); - - // ACT - var exception = Assert.Throws( - () => contractor.SetPersonName("Marcin", "Celej")); - - // ASSERT - Assert.That(exception.Message, Is.EqualTo("Not implemented yet")); - } - - #endregion - } -} \ No newline at end of file