public void ImplicitConversion() { ISomeInterface i = new CastingAndConversionOperators(); Assert.NotNull(i); SomeBaseClass c = new CastingAndConversionOperators(); Assert.NotNull(c); }
public void IsOperator() { var target = new CastingAndConversionOperators(); //Example of 'is' in action Assert.True(((object)new Mixin()) is SomeBaseClass); //Unfortunately, there's no way to do this with classes: //http://stackoverflow.com/questions/18390664/c-sharp-implicit-conversion-operator-and-is-as-operator Assert.False(target is SomeBaseClass); Assert.True(target.Is <SomeBaseClass>()); //Works on interfaces just fine Assert.True(target is ISomeInterface); }