Skip to content

Instantly share code, notes, and snippets.

@dgg
Last active June 8, 2016 12:15
Show Gist options
  • Save dgg/f82b2798a501dd8be2e5809da930d556 to your computer and use it in GitHub Desktop.
Save dgg/f82b2798a501dd8be2e5809da930d556 to your computer and use it in GitHub Desktop.
a-case-of-composition-and-communication.simplest
TimeZoneInfo subject = TimeZoneInfo.FindSystemTimeZoneById("Hawaiian Standard Time");
Assert.That(subject, Must.Satisfy.Conjunction(
Must.Have.Property(nameof(TimeZoneInfo.DaylightName), Does.Contain("Nightlight")),
Must.Have.Property(nameof(TimeZoneInfo.DisplayName), Does.Contain("Lanzarote"))));
Expected: property DaylightName String containing "Nightlight" and property DisplayName containing "Lanzarote"
Specifically: property DaylightName String containing "Nightlight"
But was: <(UTC-10:00) Hawaii>
Specifically: "Hawaiian Daylight Time"
public class ComposablePropertyConstraint : PropertyConstraint
{
public ComposablePropertyConstraint(string name, IConstraint baseConstraint) :
base(name, baseConstraint) { }
}
TimeZoneInfo subject = TimeZoneInfo.FindSystemTimeZoneById("Hawaiian Standard Time");
Assert.That(subject, Has.Property(nameof(TimeZoneInfo.DaylightName)).Contain("Nightlight").And
.Property(nameof(TimeZoneInfo.DisplayName)).Contain("Lanzarote"));
Assert.That(subject, Has.Property(nameof(TimeZoneInfo.DaylightName)).Contain("Nightlight") &
Has.Property(nameof(TimeZoneInfo.DisplayName)).Contain("Lanzarote"));
Test 'Testing.Commons.NUnit.Tests.Constraints.CompositionTester.OperatorComposition' failed:
Expected: property DaylightName String containing "Nightlight" and property DisplayName containing "Lanzarote"
But was: "Hawaiian Daylight Time"
TimeZoneInfo subject = TimeZoneInfo.FindSystemTimeZoneById("Hawaiian Standard Time");
Assert.That(subject, Must.Satisfy.Conjunction(
Has.Property(nameof(TimeZoneInfo.DaylightName)).Contain("Nightlight"),
Has.Property(nameof(TimeZoneInfo.DisplayName)).Contain("Lanzarote")));
TimeZoneInfo subject = TimeZoneInfo.FindSystemTimeZoneById("Hawaiian Standard Time");
Assert.That(subject, Has.Property(nameof(TimeZoneInfo.DaylightName)).Contain("Nightlight"));
Assert.That(subject, Has.Property(nameof(TimeZoneInfo.DisplayName)).Contain("Lanzarote"));
Test 'Testing.Commons.NUnit.Tests.Constraints.CompositionTester.Property' failed:
Expected: property DaylightName String containing "Nightlight"
But was: "Hawaiian Daylight Time"
TimeZoneInfo subject = TimeZoneInfo.FindSystemTimeZoneById("Hawaiian Standard Time");
Assert.That(subject.DaylightName, Does.Contain("Nightlight"));
Assert.That(subject.DisplayName, Does.Contain("Lanzarote"));
Test 'Testing.Commons.NUnit.Tests.Constraints.CompositionTester.Simple' failed:
Expected: String containing "Nightlight"
But was: "Hawaiian Daylight Time"
Constraints\CompositionTester.cs(14,0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment