示例#1
0
        public void CheckForNull_DefaultObject_ReturnsProvidedObject()
        {
            //Arrange
            TestObject testObject = null;

            // Act
            int?result = testObject.CheckForNull(t => t.NullableInt, 42);

            // Assert
            result.Should().Be(42);
        }
示例#2
0
        public void CheckForNull_NullObject_ReturnsEmptyString()
        {
            //Arrange
            TestObject testObject = null;

            // Act
            // ReSharper disable once ExpressionIsAlwaysNull
            var result = testObject.CheckForNull(t => t.SomeString);

            // Assert
            result.Should().BeEmpty();
        }
示例#3
0
        public void CheckForNull_NullObjectForNullableInt_ReturnsNull()
        {
            //Arrange
            TestObject testObject = null;

            // Act
            // ReSharper disable once ExpressionIsAlwaysNull
            var result = testObject.CheckForNull(t => t.NullableInt);

            // Assert
            result.Should().Be(null);
        }
示例#4
0
        public void CheckForNull_IntegerForNullableInt_ReturnsNullableInt()
        {
            //Arrange
            var testObject = new TestObject()
            {
                NullableInt = 3,
            };

            // Act
            int?result = testObject.CheckForNull(t => t.NullableInt);

            // Assert
            result.Should().Be(3);
        }
示例#5
0
        public void CheckForNull_NonNullWithDefaultObject_ReturnsProvidedValue()
        {
            //Arrange
            var testObject = new TestObject()
            {
                NullableInt = 3,
            };

            // Act
            int?result = testObject.CheckForNull(t => t.NullableInt, 42);

            // Assert
            result.Should().Be(3);
        }