public void ViewSetTest() { var input = new InputViewModel <int, string>(Converters.IntStringWithExeption); input.DefaultModel = 1; using (var subscriber = new PropertyChangedSubscriber(input)) { input.EditValue(10.ToString()); Assert.AreEqual(10.ToString(), input.View); Assert.AreEqual(1, input.Model); Assert.AreEqual(1, input.DefaultModel); input.EndEditing(); Assert.AreEqual(10.ToString(), input.View); Assert.AreEqual(10, input.Model); Assert.AreEqual(1, input.DefaultModel); CollectionAssert.AreEquivalent( new[] { nameof(input.View), nameof(input.Model) }, subscriber.Sequence ); } }
public void TypeAccessorClassSetValueAndNotifyChangedTest() { PropertyChangedSubscriber subscriber = new PropertyChangedSubscriber(); AccessedClass obj = new AccessedClass(); TypeAccessor accessor = obj.GetTypeAccessor(); accessor.SetValueAndNotifyChange(obj, "TextData", "Some text", subscriber); accessor.SetValueAndNotifyChange(obj, "IntegerData", 427, subscriber); Assert.AreEqual("Some text", obj.TextData); Assert.AreEqual(427, obj.IntegerData); Assert.AreEqual(2, subscriber.ChangedProperties.Count); }
public void ModelSetTest() { var input = new InputViewModel <int, string>(Converters.IntStringWithExeption); input.DefaultModel = 1; using (var subscriber = new PropertyChangedSubscriber(input)) { input.Model = 2; Assert.AreEqual(1, input.DefaultModel); Assert.AreEqual(2, input.Model); Assert.AreEqual(Converters.IntStringWithExeption.Convert(2), input.View); CollectionAssert.AreEquivalent( new[] { nameof(input.Model), nameof(input.View) }, subscriber.Sequence); } }