Exemplo n.º 1
0
        public void NameableStatics()
        {
            // Arrange
            var value1 = new Nameable <int>(1);
            var value2 = new Nameable <int>(2, "Name");

            // Act
            var compare1 = Nameable.Compare(value1, value1);
            var compare2 = Nameable.Compare(value1, value2);
            var equals1  = Nameable.Equals(value1, value1);
            var equals2  = Nameable.Equals(value1, value2);
            var type1    = Nameable.GetUnderlyingType(value1.GetType());

            // Assert
            Assert.Equal(0, actual: compare1); Assert.Equal(-1, actual: compare2);
            Assert.True(equals1); Assert.False(equals2);
            Assert.Equal(typeof(int), type1);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NameableConverter"/> class.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <exception cref="System.ArgumentException">NameableConverterBadCtorArg - type</exception>
 public NameableConverter(Type type)
 {
     NameableType            = type;
     UnderlyingType          = Nameable.GetUnderlyingType(type) ?? throw new ArgumentException(nameof(type), "type");
     UnderlyingTypeConverter = TypeDescriptor.GetConverter(UnderlyingType);
 }