コード例 #1
0
        public void ValidateReferenceTypeToBeOfType()
        {
            // Given
            var validator = new ReferenceTypeValidator <object>(42);

            // When
            validator.BeOfType <Int32>();

            // Then
            Assert.True(true);
        }
コード例 #2
0
        public void ValidateReferenceTypeToBeOfTypeViolated()
        {
            // Given
            var validator = new ReferenceTypeValidator <object>(42);

            // When
            var exception = Assert.Throws <XunitException>(() => validator.BeOfType <String>());

            // Then
            Assert.NotNull(exception);
            var rn = Environment.NewLine;

            Assert.Equal(
                $"{rn}validator{rn}is \"Int32\"{rn}but was expected to be of type \"String\"",
                exception.UserMessage);
        }