public void Replace_NonCompatibleType_Fails() { // Arrange var targetObject = new List <int> { 10, 20 }; var listAdapter = new ListAdapter(); var options = new JsonSerializerOptions(); // Act var replaceStatus = listAdapter.TryReplace(targetObject, typeof(List <int>), "-", options, "James", out var message); // Assert Assert.False(replaceStatus); Assert.Equal("The value 'James' is invalid for target location.", message); }
public void Replace_ReplacesValue_AtGivenPosition(string position, List <int> expected) { // Arrange var targetObject = new List <int> { 10, 20 }; var listAdapter = new ListAdapter(); var options = new JsonSerializerOptions(); // Act var replaceStatus = listAdapter.TryReplace(targetObject, typeof(List <int>), position, options, "30", out var message); // Assert Assert.True(replaceStatus); Assert.True(string.IsNullOrEmpty(message), "Expected no error message"); Assert.Equal(expected, targetObject); }
public void Replace_NonCompatibleType_Fails() { // Arrange var resolver = new DefaultContractResolver(); var targetObject = new List <int>() { 10, 20 }; var listAdapter = new ListAdapter(); // Act var replaceStatus = listAdapter.TryReplace(targetObject, "-", resolver, "James", out var message); // Assert Assert.False(replaceStatus); Assert.Equal("The value 'James' is invalid for target location.", message); }
public void Replace_ReplacesValue_AtGivenPosition(string position, List <int> expected) { // Arrange var resolver = new DefaultContractResolver(); var targetObject = new List <int>() { 10, 20 }; var listAdapter = new ListAdapter(); // Act var replaceStatus = listAdapter.TryReplace(targetObject, position, resolver, "30", out var message); // Assert Assert.True(replaceStatus); Assert.True(string.IsNullOrEmpty(message), "Expected no error message"); Assert.Equal(expected, targetObject); }