public void GetStandardValues () { ReferenceConverter converter = new ReferenceConverter (typeof(TestComponent)); TestComponent component1 = new TestComponent(); TestComponent component2 = new TestComponent(); TestReferenceService referenceService = new TestReferenceService (); referenceService.AddReference ("reference name 1", component1); referenceService.AddReference ("reference name 2", component2); ITypeDescriptorContext context = new TestTypeDescriptorContext (referenceService); TypeConverter.StandardValuesCollection values = converter.GetStandardValues (context); Assert.IsNotNull (values, "#1"); // 2 components + 1 null value Assert.AreEqual (3, values.Count, "#2"); }
public ReferenceComparer(ReferenceConverter converter) { this.converter = converter; }
public void ConvertTo () { ReferenceConverter converter = new ReferenceConverter (typeof(ITestInterface)); string referenceName = "reference name"; Assert.AreEqual ("(none)", (string)converter.ConvertTo (null, null, null, typeof(string)), "#1"); TestComponent component = new TestComponent(); // no context Assert.AreEqual (String.Empty, (string)converter.ConvertTo (null, null, component, typeof(string)), "#2"); // context with IReferenceService TestReferenceService referenceService = new TestReferenceService (); referenceService.AddReference (referenceName, component); TestTypeDescriptorContext context = new TestTypeDescriptorContext (referenceService); Assert.AreEqual (referenceName, (string)converter.ConvertTo (context, null, component, typeof(string)), "#3"); // context with Component without IReferenceService Container container = new Container (); container.Add (component, referenceName); context = new TestTypeDescriptorContext (); context.Container = container; Assert.AreEqual (referenceName, (string)converter.ConvertTo (context, null, component, typeof(string)), "#4"); }
public void CanConvertTo () { ReferenceConverter converter = new ReferenceConverter (typeof(ITestInterface)); Assert.IsTrue (converter.CanConvertTo (new TestTypeDescriptorContext (), typeof(string)), "#1"); }
public void ConvertFrom () { ReferenceConverter converter = new ReferenceConverter (typeof(ITestInterface)); string referenceName = "reference name"; // no context Assert.IsNull (converter.ConvertFrom (null, null, referenceName), "#1"); TestComponent component = new TestComponent(); // context with IReferenceService TestReferenceService referenceService = new TestReferenceService (); referenceService.AddReference (referenceName, component); TestTypeDescriptorContext context = new TestTypeDescriptorContext (referenceService); Assert.AreSame (component, converter.ConvertFrom (context, null, referenceName), "#2"); // context with Component without IReferenceService Container container = new Container (); container.Add (component, referenceName); context = new TestTypeDescriptorContext (); context.Container = container; Assert.AreSame (component, converter.ConvertFrom (context, null, referenceName), "#3"); }
public void CanConvertFrom () { ReferenceConverter converter = new ReferenceConverter (typeof(ITestInterface)); // without context Assert.IsFalse (converter.CanConvertFrom (null, typeof(string)), "#1"); // with context Assert.IsTrue (converter.CanConvertFrom (new TestTypeDescriptorContext (), typeof(string)), "#2"); }
public ReferenceComparer(ReferenceConverter converter) { _converter = converter; }
// Constructor. public ValueComparer(ReferenceConverter converter) { this.converter = converter; }
public DataSourceConverter() : base(typeof(IListSource)) { this.listConverter = new ReferenceConverter(typeof(IList)); }