コード例 #1
0
        public void Given_both_enumerations_have_the_same_KeyCode_value_and_Type_When_Equality_operator_is_invoked_Then_true_should_be_returned()
        {
            // Arrange.
            Enumeration enumeration      = new TestEnumeration("BEANS", "are great");
            Enumeration otherEnumeration = new TestEnumeration("BEANS", "are good");

            // Act.
            bool result = enumeration == otherEnumeration;

            // Assert.
            enumeration.Should().NotBeSameAs(otherEnumeration);
            result.Should().BeTrue();
        }
コード例 #2
0
        public void Given_both_enumerations_have_the_same_KeyCode_value_and_Type_When_Inequality_operator_is_invoked_Then_false_should_be_returned()
        {
            // Arrange.
            Enumeration enumeration      = new TestEnumeration("BEANS", "Beans");
            Enumeration otherEnumeration = new TestEnumeration("BEANS", "Maybe not");

            // Act.
            bool result = enumeration != otherEnumeration;

            // Assert.
            enumeration.Should().NotBeSameAs(otherEnumeration);
            result.Should().BeFalse();
        }
コード例 #3
0
        public void Given_an_object_which_has_the_same_KeyCode_value_and_has_the_same_Type_When_Equals_is_called_Then_true_should_be_returned()
        {
            // Arrange.
            Enumeration enumeration      = new TestEnumeration("SALAD", "Yummy yummy");
            Enumeration otherEnumeration = new TestEnumeration("SALAD", "In my tummy");

            // Act.
            bool result = enumeration.Equals(otherEnumeration);

            // Assert.
            // Ensure that we are asserting that Equals does equivalency by value of `KeyCode` rather than by reference equality.
            enumeration.Should().NotBeSameAs(otherEnumeration);
            result.Should().BeTrue();
        }