public void When_two_equal_objects_should_not_be_equal_it_should_throw() { //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- var subject = new ComparableOfString("Hello"); var other = new ComparableOfString("Hello"); //----------------------------------------------------------------------------------------------------------- // Act //----------------------------------------------------------------------------------------------------------- Action act = () => subject.Should().NotBe(other, "they represent different things"); //----------------------------------------------------------------------------------------------------------- // Assert //----------------------------------------------------------------------------------------------------------- act .Should().Throw <XunitException>() .WithMessage( #if NETCOREAPP1_1 "*Did not expect object to be equal to*Hello*because they represent different things.*"); #else "*Did not expect subject to be equal to*Hello*because they represent different things.*"); #endif }
public void When_two_instances_are_equal_it_should_succeed() { // Arrange var subject = new ComparableOfString("Hello"); var other = new ComparableOfString("Hello"); // Act / Assert subject.Should().Be(other); }
public void When_subject_is_greater_than_another_subject_and_greater_or_equal_is_expected_it_should_not_throw() { // Arrange var subject = new ComparableOfString("xyz"); var other = new ComparableOfString("abc"); // Act Action act = () => subject.Should().BeGreaterOrEqualTo(other); // Assert act.Should().NotThrow(); }
public void When_two_unequal_objects_should_not_be_equal_it_should_not_throw() { // Arrange var subject = new ComparableOfString("Hello"); var other = new ComparableOfString("Hi"); // Act Action act = () => subject.Should().NotBe(other); // Assert act.Should().NotThrow(); }
public void When_subject_is_less_than_another_subject_and_less_or_equal_is_expected_it_should_not_throw() { // Arrange var subject = new ComparableOfString("City"); var other = new ComparableOfString("World"); // Act Action act = () => subject.Should().BeLessOrEqualTo(other); // Assert act.Should().NotThrow(); }
public void When_subect_is_not_ranked_equal_to_another_subject_and_that_is_expected_it_should_not_throw() { // Arrange var subject = new ComparableOfString("Hello"); var other = new ComparableOfString("Hi"); // Act Action act = () => subject.Should().NotBeRankedEquallyTo(other); // Assert act.Should().NotThrow(); }
public void When_subject_is_equal_to_another_subject_and_expected_to_be_greater_it_should_throw() { // Arrange var subject = new ComparableOfString("efg"); var other = new ComparableOfString("efg"); // Act Action act = () => subject.Should().BeGreaterThan(other); // Assert act.Should().Throw <XunitException>(); }
public void When_assertion_an_instance_not_to_be_null_and_it_is_not_null_it_should_succeed() { // Arrange var subject = new ComparableOfString(""); // Act Action action = () => subject.Should().NotBeNull(); // Assert action.Should().NotThrow(); }
public void When_assertion_an_instance_to_be_null_and_it_is_not_null_it_should_throw() { // Arrange var subject = new ComparableOfString(""); // Act Action action = () => subject.Should().BeNull(); // Assert action.Should().Throw <XunitException>() .WithMessage("Expected subject to be <null>, but found*"); }
public void When_assertion_an_instance_not_to_be_null_and_it_is_null_it_should_throw() { // Arrange ComparableOfString subject = null; // Act Action action = () => subject.Should().NotBeNull(); // Assert action.Should().Throw <XunitException>() .WithMessage("Expected subject not to be <null>."); }
public void When_subject_is_not_greater_than_another_subject_but_that_is_expected_it_should_throw() { // Arrange var subject = new ComparableOfString("abc"); var other = new ComparableOfString("def"); // Act Action act = () => subject.Should().BeGreaterThan(other, "'a' is smaller then 'e'"); // Assert act .Should().Throw <XunitException>() .WithMessage("Expected subject*abc*to be greater than*def*because 'a' is smaller then 'e'."); }
public void When_subject_is_greater_than_another_subject_and_that_is_not_expected_it_should_throw() { // Arrange var subject = new ComparableOfString("World"); var other = new ComparableOfString("City"); // Act Action act = () => subject.Should().BeLessOrEqualTo(other, "we want to order them"); // Assert act .Should().Throw <XunitException>() .WithMessage("Expected subject*World*to be less or equal to*City*because we want to order them."); }
public void When_subject_is_not_ranked_equal_to_another_subject_but_that_is_expected_it_should_throw() { // Arrange var subject = new ComparableOfString("42"); var other = new ComparableOfString("Forty two"); // Act Action act = () => subject.Should().BeRankedEquallyTo(other, "they represent the same number"); // Assert act .Should().Throw <XunitException>() .WithMessage("Expected subject*42*to be ranked as equal to*Forty two*because they represent the same number."); }
public void When_subject_is_ranked_equal_to_another_subject_but_that_is_not_expected_it_should_throw() { // Arrange var subject = new ComparableOfString("Lead"); var other = new ComparableOfString("Lead"); // Act Action act = () => subject.Should().NotBeRankedEquallyTo(other, "they represent different concepts"); // Assert act .Should().Throw <XunitException>() .WithMessage("Expected subject*Lead*not to be ranked as equal to*Lead*because they represent different concepts."); }
public void When_subject_is_not_less_than_another_subject_but_that_is_expected_it_should_throw() { // Arrange var subject = new ComparableOfString("World"); var other = new ComparableOfString("City"); // Act Action act = () => subject.Should().BeLessThan(other, "a city is smaller than the world"); // Assert act .Should().Throw <XunitException>() .WithMessage("Expected subject*World*to be less than*City*because a city is smaller than the world."); }
public void When_subject_is_less_than_another_subject_and_that_is_not_expected_it_should_throw() { // Arrange var subject = new ComparableOfString("abc"); var other = new ComparableOfString("def"); // Act Action act = () => subject.Should().BeGreaterOrEqualTo(other, "'d' is bigger then 'a'"); // Assert act .Should().Throw <XunitException>() .WithMessage("Expected subject*abc*to be greater or equal to*def*because 'd' is bigger then 'a'."); }
public void When_two_instances_are_not_equal_it_should_throw() { // Arrange var subject = new ComparableOfString("Hello"); var other = new ComparableOfString("Hi"); // Act Action act = () => subject.Should().Be(other, "they have the same property values"); // Assert act .Should().Throw <XunitException>() .WithMessage( "Expected*Hi*because they have the same property values, but found*Hello*."); }
public void When_subject_is_less_than_another_subject_and_that_is_expected_it_should_not_throw() { //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- var subject = new ComparableOfString("City"); var other = new ComparableOfString("World"); //----------------------------------------------------------------------------------------------------------- // Act //----------------------------------------------------------------------------------------------------------- Action act = () => subject.Should().BeLessThan(other); //----------------------------------------------------------------------------------------------------------- // Assert //----------------------------------------------------------------------------------------------------------- act.ShouldNotThrow(); }
public void When_assertion_an_instance_to_be_null_and_it_is_null_it_should_succeed() { //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- ComparableOfString subject = null; //----------------------------------------------------------------------------------------------------------- // Act //----------------------------------------------------------------------------------------------------------- Action action = () => subject.Should().BeNull(); //----------------------------------------------------------------------------------------------------------- // Assert //----------------------------------------------------------------------------------------------------------- action.Should().NotThrow(); }
public void When_subject_is_equal_to_another_subject_and_that_is_equal_or_greater_it_should_not_throw() { //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- var subject = new ComparableOfString("def"); var other = new ComparableOfString("def"); //----------------------------------------------------------------------------------------------------------- // Act //----------------------------------------------------------------------------------------------------------- Action act = () => subject.Should().BeGreaterOrEqualTo(other); //----------------------------------------------------------------------------------------------------------- // Assert //----------------------------------------------------------------------------------------------------------- act.ShouldNotThrow(); }
public void When_subject_is_greater_than_another_subject_and_that_is_expected_it_should_not_throw() { //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- var subject = new ComparableOfString("efg"); var other = new ComparableOfString("abc"); //----------------------------------------------------------------------------------------------------------- // Act //----------------------------------------------------------------------------------------------------------- Action act = () => subject.Should().BeGreaterThan(other); //----------------------------------------------------------------------------------------------------------- // Assert //----------------------------------------------------------------------------------------------------------- act.ShouldNotThrow(); }
public void When_assertion_an_instance_not_to_be_null_and_it_is_null_it_should_throw() { //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- ComparableOfString subject = null; //----------------------------------------------------------------------------------------------------------- // Act //----------------------------------------------------------------------------------------------------------- Action action = () => subject.Should().NotBeNull(); //----------------------------------------------------------------------------------------------------------- // Assert //----------------------------------------------------------------------------------------------------------- action.ShouldThrow <AssertFailedException>() .WithMessage( "Expected object not to be <null>.", ComparisonMode.Wildcard); }
public void When_two_instances_are_not_equal_it_should_throw() { //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- var subject = new ComparableOfString("Hello"); var other = new ComparableOfString("Hi"); //----------------------------------------------------------------------------------------------------------- // Act //----------------------------------------------------------------------------------------------------------- Action act = () => subject.Should().Be(other, "they have the same property values"); //----------------------------------------------------------------------------------------------------------- // Assert //----------------------------------------------------------------------------------------------------------- act .ShouldThrow <AssertFailedException>() .WithMessage( "Expected*Hi*because they have the same property values, but found*Hello*.", ComparisonMode.Wildcard); }
public void When_subject_is_not_greater_than_another_subject_but_that_is_expected_it_should_throw() { //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- var subject = new ComparableOfString("abc"); var other = new ComparableOfString("def"); //----------------------------------------------------------------------------------------------------------- // Act //----------------------------------------------------------------------------------------------------------- Action act = () => subject.Should().BeGreaterThan(other, "'a' is smaller then 'e'"); //----------------------------------------------------------------------------------------------------------- // Assert //----------------------------------------------------------------------------------------------------------- act .ShouldThrow <AssertFailedException>() .WithMessage("Expected object*abc*to be greater than*def*because 'a' is smaller then 'e'.", ComparisonMode.Wildcard); }
public void When_subject_is_less_than_another_subject_and_that_is_not_expected_it_should_throw() { //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- var subject = new ComparableOfString("abc"); var other = new ComparableOfString("def"); //----------------------------------------------------------------------------------------------------------- // Act //----------------------------------------------------------------------------------------------------------- Action act = () => subject.Should().BeGreaterOrEqualTo(other, "'d' is bigger then 'a'"); //----------------------------------------------------------------------------------------------------------- // Assert //----------------------------------------------------------------------------------------------------------- act .ShouldThrow <AssertFailedException>() .WithMessage("Expected object*abc*to be greater or equal to*def*because 'd' is bigger then 'a'.", ComparisonMode.Wildcard); }
public void When_subject_is_greater_than_another_subject_and_that_is_not_expected_it_should_throw() { //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- var subject = new ComparableOfString("World"); var other = new ComparableOfString("City"); //----------------------------------------------------------------------------------------------------------- // Act //----------------------------------------------------------------------------------------------------------- Action act = () => subject.Should().BeLessOrEqualTo(other, "we want to order them"); //----------------------------------------------------------------------------------------------------------- // Assert //----------------------------------------------------------------------------------------------------------- act .ShouldThrow <AssertFailedException>() .WithMessage("Expected object*World*to be less or equal to*City*because we want to order them.", ComparisonMode.Wildcard); }
public void When_subject_is_not_less_than_another_subject_but_that_is_expected_it_should_throw() { //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- var subject = new ComparableOfString("World"); var other = new ComparableOfString("City"); //----------------------------------------------------------------------------------------------------------- // Act //----------------------------------------------------------------------------------------------------------- Action act = () => subject.Should().BeLessThan(other, "a city is smaller than the world"); //----------------------------------------------------------------------------------------------------------- // Assert //----------------------------------------------------------------------------------------------------------- act .ShouldThrow <AssertFailedException>() .WithMessage("Expected object*World*to be less than*City*because a city is smaller than the world.", ComparisonMode.Wildcard); }
public void When_two_equal_objects_should_not_be_equal_it_should_throw() { //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- var subject = new ComparableOfString("Hello"); var other = new ComparableOfString("Hello"); //----------------------------------------------------------------------------------------------------------- // Act //----------------------------------------------------------------------------------------------------------- Action act = () => subject.Should().NotBe(other, "they represent different things"); //----------------------------------------------------------------------------------------------------------- // Assert //----------------------------------------------------------------------------------------------------------- act .ShouldThrow <AssertFailedException>() .WithMessage( "Did not expect object to be equal to*Hello*because they represent different things.", ComparisonMode.Wildcard); }