Exemplo n.º 1
0
    public void SetValue_NoopsIfNullIsBeingAssignedToValueType()
    {
        // Arrange
        var propertyInfo      = typeof(TestSubject).GetProperty(nameof(TestSubject.ValueTypeProperty));
        var lifecycleProperty = new LifecycleProperty(propertyInfo, "test-key");
        var subject           = new TestSubject {
            ValueTypeProperty = 42
        };

        // Act
        lifecycleProperty.SetValue(subject, null);

        // Assert
        Assert.Equal(42, subject.ValueTypeProperty);
    }
Exemplo n.º 2
0
    public void SetValue_SetsNullValue_ForNullableProperties()
    {
        // Arrange
        var propertyInfo      = typeof(TestSubject).GetProperty(nameof(TestSubject.NullableProperty));
        var lifecycleProperty = new LifecycleProperty(propertyInfo, "test-key");
        var subject           = new TestSubject {
            NullableProperty = 42
        };

        // Act
        lifecycleProperty.SetValue(subject, null);

        // Assert
        Assert.Null(subject.NullableProperty);
    }
Exemplo n.º 3
0
    public void SetValue_SetsPropertyValue()
    {
        // Arrange
        var propertyInfo      = typeof(TestSubject).GetProperty(nameof(TestSubject.TestProperty));
        var lifecycleProperty = new LifecycleProperty(propertyInfo, "test-key");
        var subject           = new TestSubject {
            TestProperty = "test-value"
        };

        // Act
        lifecycleProperty.SetValue(subject, "new-value");

        // Assert
        Assert.Equal("new-value", subject.TestProperty);
    }