public DocumentationAttribute(string name, Type ConverterToDocumentationString, string defaultValue) { this.Name = name; //TODO Check if ConverterToDocumentationString is an interface, if it is not - take StringGetter type this.ConverterToDocumentationString = (IConverterToDocumentationString)Activator.CreateInstance(ConverterToDocumentationString); this.DefaultValue = defaultValue; }
public void Constructor2TestMethod() { DocumentationAttribute _attribute = new DocumentationAttribute("name", typeof(StringGetter)); Assert.IsNotNull(_attribute); Assert.AreEqual <string>("name", _attribute.Name); IConverterToDocumentationString _converter = _attribute.ConverterToDocumentationString; Assert.IsNotNull(_converter); Assert.AreSame(_converter.GetType(), typeof(StringGetter)); }
public void Constructor1TestMethod() { DocumentationAttribute _attribute = new DocumentationAttribute("name"); Assert.IsNotNull(_attribute); Assert.AreEqual <string>("name", _attribute.Name); IConverterToDocumentationString _converter = _attribute.ConverterToDocumentationString; Assert.IsNotNull(_converter); Assert.AreSame(_converter.GetType(), typeof(StringGetter)); TestClass _TestClass = new TestClass(); Assert.AreEqual <string>(_TestClass.TestString, _converter.ConvertToString(_TestClass, String.Empty)); }
public void DateTimeGetterTest() { DocumentationAttribute _attribute = new DocumentationAttribute("name", typeof(DateTimeGetter)); Assert.IsNotNull(_attribute); Assert.AreEqual <string>("name", _attribute.Name); IConverterToDocumentationString _converter = _attribute.ConverterToDocumentationString; Assert.IsNotNull(_converter); Assert.AreSame(_converter.GetType(), typeof(DateTimeGetter)); DateTime?_TestDate = DateTime.Today; Assert.AreEqual <string>(_TestDate.ToString(), _converter.ConvertToString(_TestDate, String.Empty)); Assert.AreEqual <string>("Null date", _converter.ConvertToString(new Nullable <DateTime>(), "Null date")); Assert.AreEqual <string>("Null date", _converter.ConvertToString(null, "Null date")); Assert.AreEqual <string>("Null date", _converter.ConvertToString(new TestClass(), "Null date")); }
public DocumentationAttribute(string name) { this.Name = name; this.ConverterToDocumentationString = new StringGetter(); }