public static void RemoveTransformsSource() { var bindingSource = new Source { Property = 1 }; var binding = new Binding("Property", BindingMode.OneWay, null, null, null, bindingSource); var rect = new Mux.Markup.RectTransform(); try { var templated = new WithProperty(); var transformsSource = new ObservableCollection <int> { 2 }; templated.SetBinding(WithProperty.PropertyProperty, binding); rect.TransformsSource = transformsSource; rect.TransformTemplate = new DataTemplate(() => templated); transformsSource.RemoveAt(0); bindingSource.Property = 3; Assert.AreEqual(1, templated.Property); } finally { rect.Destroy(); } }
public static void ReplaceTransformsSource() { var bindingSource = new Source { Property = 1 }; var binding = new Binding("Property", BindingMode.OneWay, null, null, null, bindingSource); var rect = new Mux.Markup.RectTransform(); try { var selector = new DataTemplateSelector(); var templated = new WithProperty(); var transformsSource = new ObservableCollection <int> { 2 }; templated.SetBinding(WithProperty.PropertyProperty, binding); selector.template = new DataTemplate(() => templated); rect.TransformsSource = transformsSource; rect.TransformTemplate = selector; var oldTemplated = templated; templated = new WithProperty(); selector.template = new DataTemplate(() => templated); transformsSource[0] = 3; bindingSource.Property = 4; Assert.AreEqual(1, oldTemplated.Property); Assert.AreEqual(3, templated.BindingContext); } finally { rect.Destroy(); } }
public void Should_CreateEditor_ForEnum() { var field = new ObjectPropertiesField(); _window.rootVisualElement.Add(field); var block = new WithProperty <PortCapacity>(); field.PropertyBlock = block; var editor = field.Q(null, BaseField <string> .ussClassName); Assert.That(editor, Is.Not.Null); Assert.That(editor, Is.AssignableTo(typeof(BaseField <string>))); (editor as BaseField <string>).value = PortCapacity.Multiple.ToString(); Assert.That(block.Property, Is.EqualTo(PortCapacity.Multiple)); }
public void WithIllegalIndexerProperty() { var expected = this is DiffTests.FieldValues.Throws ? "DiffBy.FieldValues(x, y) failed.\r\n" + "The field WithProperty<WithIndexerType>.<Value>k__BackingField of type WithIndexerType is not supported.\r\n" + "Indexers are not supported.\r\n" + " - The property WithIndexerType.Item is an indexer and not supported.\r\n" + "Solve the problem by any of:\r\n" + "* Implement IEquatable<WithProperty<WithIndexerType>> for WithProperty<WithIndexerType> or use a type that does.\r\n" + "* Implement IEquatable<WithIndexerType> for WithIndexerType or use a type that does.\r\n" + "* Use FieldsSettings and specify how comparing is performed:\r\n" + " - Exclude a combination of the following:\r\n" + " - The field WithProperty<WithIndexerType>.<Value>k__BackingField.\r\n" + " - The indexer property WithIndexerType.Item.\r\n" + " - The type WithIndexerType.\r\n" : "DiffBy.PropertyValues(x, y) failed.\r\n" + "The property WithProperty<WithIndexerType>.Value of type WithIndexerType is not supported.\r\n" + "Indexers are not supported.\r\n" + " - The property WithIndexerType.Item is an indexer and not supported.\r\n" + "Solve the problem by any of:\r\n" + "* Implement IEquatable<WithProperty<WithIndexerType>> for WithProperty<WithIndexerType> or use a type that does.\r\n" + "* Implement IEquatable<WithIndexerType> for WithIndexerType or use a type that does.\r\n" + "* Use PropertiesSettings and specify how comparing is performed:\r\n" + " - Exclude a combination of the following:\r\n" + " - The property WithProperty<WithIndexerType>.Value.\r\n" + " - The indexer property WithIndexerType.Item.\r\n" + " - The type WithIndexerType.\r\n"; ; var source = new WithProperty <WithIndexerType>(); var target = new WithProperty <WithIndexerType>(); var exception = Assert.Throws <NotSupportedException>(() => this.DiffMethod(source, target, ReferenceHandling.Structural)); Assert.AreEqual(expected, exception.Message); }