Beispiel #1
0
        public void PhyrEvent_Message(string type, string expectedMessage)
        {
            TestEnum eventType = type;

            eventType.Should().NotBeNull();
            eventType.Should().Be(type);
            eventType.Name.ToUpperInvariant().Should().Be(type.ToUpperInvariant());
        }
        public void When_enum_does_not_have_the_unexpected_flag_it_should_succeed()
        {
            // Arrange
            TestEnum someObject = TestEnum.One | TestEnum.Two;

            // Act / Assert
            someObject.Should().NotHaveFlag(TestEnum.Three);
        }
        public void When_enum_does_not_have_the_unexpected_value_it_should_succeed()
        {
            // Arrange
            TestEnum someObject = TestEnum.One;

            // Act / Assert
            someObject.Should().NotHaveValue(3);
        }
        public void When_enum_has_the_expected_value_it_should_succeed()
        {
            // Arrange
            TestEnum someObject = TestEnum.One;

            // Act / Assert
            someObject.Should().HaveValue(1);
        }
        public void When_enum_has_the_expected_flag_it_should_succeed()
        {
            // Arrange
            TestEnum someObject = TestEnum.One | TestEnum.Two;

            // Act / Assert
            someObject.Should().HaveFlag(TestEnum.One);
        }
Beispiel #6
0
        public void When_enum_does_have_specified_flag_it_should_fail_with_a_descriptive_message()
        {
            // Arrange
            TestEnum someObject = TestEnum.One | TestEnum.Two;

            // Act
            Action act = () => someObject.Should().NotHaveFlag(TestEnum.Two);

            // Assert
            act.Should().Throw <XunitException>().WithMessage("Did not expect the enum to have flag Two.");
        }
Beispiel #7
0
        public void When_enum_is_not_of_the_same_type_it_should_fail_with_a_descriptive_message()
        {
            // Arrange
            TestEnum someObject = TestEnum.One | TestEnum.Two;

            // Act
            Action act = () => someObject.Should().HaveFlag(OtherEnum.First);

            // Assert
            act.Should().Throw <XunitException>().WithMessage("Expected*type*OtherEnum*TestEnum*");
        }
Beispiel #8
0
        public void When_enum_does_not_have_specified_flag_it_should_fail_with_a_descriptive_message()
        {
            // Arrange
            TestEnum someObject = TestEnum.One | TestEnum.Two;

            // Act
            Action act = () => someObject.Should().HaveFlag(TestEnum.Three);

            // Assert
            act.Should().Throw <XunitException>().WithMessage("The enum was expected to have flag Three but found One, Two.");
        }
        public void When_enum_does_have_specified_flag_it_should_fail_with_a_descriptive_message()
        {
            // Arrange
            TestEnum someObject = TestEnum.One | TestEnum.Two;

            // Act
            Action act = () => someObject.Should().NotHaveFlag(TestEnum.Two, "we want to test the failure {0}", "message");

            // Assert
            act.Should().Throw <XunitException>()
            .WithMessage("Expected*someObject*to not have flag TestEnum.Two {value: 2}*because we want to test the failure message*");
        }
        public void When_enum_does_not_have_specified_value_it_should_fail_with_a_descriptive_message()
        {
            // Arrange
            TestEnum someObject = TestEnum.One;

            // Act
            Action act = () => someObject.Should().HaveValue(3, "we want to test the failure {0}", "message");

            // Assert
            act.Should().Throw <XunitException>()
            .WithMessage("Expected*have value 3*because we want to test the failure message*but found*");
        }
        public void GetEnumValueFromDescription_GivenDescription_ReturnsEnumValue()
        {
            //arrange
            const string green = "green";

            //Act
            TestEnum testEnum = green.GetEnumValueFromDescription <TestEnum>();

            //Assert
            testEnum
            .Should()
            .Be(TestEnum.Green);
        }