public void ShouldNotChangeValue() { var array = new ArrayOfStructureField("userinfo", "User information"); array.AddIntoStructure(new StringField("username", "User name")); array.AddIntoStructure(new IntegerField("timeout", "Timeout")); var element = new Dictionary <string, object> { { "username", "yashar" }, { "timeout", "20" } }; array.InsertValue(element, false); element["timeout"] = 20; var changed = false; var errors = array.UpdateValue(0, element, out changed, false); var lst = array.GetValues(); Assert.Empty(errors); Assert.Equal(20, (int)lst.First()["timeout"]); Assert.Equal("yashar", (string)lst.First()["username"]); Assert.False(changed); }
public void ShouldAddValueWithError() { var array = new ArrayOfStructureField("userinfo", "User information"); array.AddIntoStructure(new StringField("username", "User name")); array.AddIntoStructure(new IntegerField("timeout", "Timeout")); var element = new Dictionary <string, object> { { "username", "yashar" }, { "timeout", "test" } }; var errors = array.InsertValue(element, false); var lst = array.GetValues(); Assert.Empty(lst); Assert.NotEmpty(errors); }
public void ShouldAddValueSuccessfully() { var array = new ArrayOfStructureField("userinfo", "User information"); array.AddIntoStructure(new StringField("username", "User name")); array.AddIntoStructure(new IntegerField("timeout", "Timeout")); var element = new Dictionary <string, object> { { "username", "yashar" }, { "timeout", 300 } }; var errors = array.InsertValue(element); var lst = array.GetValues(); Assert.NotEmpty(lst); Assert.Empty(errors); Assert.False(string.IsNullOrEmpty(lst.First()["username"].ToString())); Assert.True((int)lst.First()["timeout"] == 300); }