public void PossibleTypes_NullsAreRemoved() { var attrib = new PossibleTypesAttribute(null, typeof(GraphRootAttribute)); Assert.AreEqual(1, attrib.PossibleTypes.Count); Assert.IsTrue(attrib.PossibleTypes.Contains(typeof(GraphRootAttribute))); }
public void PossibleTypesAttribute() { // Arrange var attrWithBase = new PossibleTypesAttribute(typeof(SomeBase)); var attrWithArray = new PossibleTypesAttribute(new[] { typeof(SomeImpl) }); var attrWithFull = new PossibleTypesAttribute(typeof(SomeBase)) { UseFullname = true }; // Act var valuesFromBase = attrWithBase.GetValues(null).ToArray(); var valuesFromArray = attrWithArray.GetValues(null).ToArray(); var valuesWithFull = attrWithFull.GetValues(null).ToArray(); // Assert // Check values from base type Assert.AreEqual(2, valuesFromBase.Length); Assert.AreEqual(nameof(SomeBase), valuesFromBase[0]); Assert.AreEqual(nameof(SomeImpl), valuesFromBase[1]); // Check values from array types Assert.AreEqual(1, valuesFromArray.Length); Assert.AreEqual(nameof(SomeImpl), valuesFromArray[0]); // Check values from base type with full name Assert.AreEqual(2, valuesWithFull.Length); Assert.AreEqual(typeof(SomeBase).FullName, valuesWithFull[0]); Assert.AreEqual(typeof(SomeImpl).FullName, valuesWithFull[1]); }
public void PossibleTypes_AllTypesReturned_PropertyCheck() { var attrib = new PossibleTypesAttribute(typeof(AttributeDataIntegrityTests), typeof(GraphRootAttribute)); Assert.AreEqual(2, attrib.PossibleTypes.Count); Assert.IsTrue(attrib.PossibleTypes.Contains(typeof(AttributeDataIntegrityTests))); Assert.IsTrue(attrib.PossibleTypes.Contains(typeof(GraphRootAttribute))); }