public void TryReplace_ThrowsPathNotFoundException_ForNonExistingProperty()
        {
            // Arrange
            var     adapter  = new DynamicObjectAdapter();
            dynamic target   = new DynamicTestObject();
            var     segment  = "NewProperty";
            var     resolver = new DefaultContractResolver();

            // Act
            var status = adapter.TryReplace(target, segment, resolver, "test", out string errorMessage);

            // Assert
            Assert.False(status);
            Assert.Equal($"The target location specified by path segment '{segment}' was not found.", errorMessage);
        }
        public void TryReplace_ThrowsPropertyInvalidException_IfNewValueIsNotTheSameTypeAsInitialValue()
        {
            // Arrange
            var     adapter = new DynamicObjectAdapter();
            dynamic target  = new DynamicTestObject();

            target.NewProperty = 1;
            var segment  = "NewProperty";
            var resolver = new DefaultContractResolver();

            // Act
            var status = adapter.TryReplace(target, segment, resolver, "test", out string errorMessage);

            // Assert
            Assert.False(status);
            Assert.Equal($"The value 'test' is invalid for target location.", errorMessage);
        }
        public void TryReplace_ReplacesPropertyValue()
        {
            // Arrange
            var     adapter = new DynamicObjectAdapter();
            dynamic target  = new DynamicTestObject();

            target.NewProperty = new object();
            var segment  = "NewProperty";
            var resolver = new DefaultContractResolver();

            // Act
            var status = adapter.TryReplace(target, segment, resolver, "new", out string errorMessage);

            // Assert
            Assert.True(status);
            Assert.Null(errorMessage);
            Assert.Equal("new", target.NewProperty);
        }