public void InstanceIsNotExactlyTypeReference() { ModelBase act = new ModelDerived(); Type t = typeof(ModelDerived); // MSTest does not support this case. // NUnit Assert.That(act, Is.Not.TypeOf(t), () => "Some context"); // Some context // Expected: not <ModelDerived> // But was: <ModelDerived> // XUnit XUnitAssert.IsNotType(t, act); // Assert.IsNotType() Failure // Expected: typeof(ModelDerived) // Actual: typeof(ModelDerived) // Fluent act.Should().NotBeOfType(t, "SOME REASONS"); // Expected type not to be [ModelDerived, OmniTest, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null] because SOME REASONS, but it is. // Shouldly act.ShouldNotBeOfType(t, "Some context"); // act // should not be of type // ModelDerived // but was // ModelDerived (44338948) // // Additional Info: // Some context }
/// <summary> /// Verifies that an object is not exactly the given type. /// </summary> /// <param name="object">The object to be evaluated</param> /// <param name="expectedType">The type the object should not be</param> /// <exception cref="IsTypeException">Thrown when the object is the given type</exception> public static void ShouldNotBeType(this object @object, Type expectedType) { Assert.IsNotType(expectedType, @object); }
/// <summary> /// Verifies that an object is not exactly the given type. /// </summary> /// <typeparam name="T">The type the object should not be</typeparam> /// <param name="object">The object to be evaluated</param> /// <exception cref="IsTypeException">Thrown when the object is the given type</exception> public static void ShouldNotBeType <T>(this object @object) { Assert.IsNotType <T>(@object); }
/// <summary>Assert.IsNotType.</summary> public static void IsNotInstanceOf <TWrong>(this object value) { Assert.IsNotType <TWrong>(value); }
public static void ShouldNotBeInstanceOf <T> (this object @object) => Assert.IsNotType <T> (@object);
public static void ShouldNotBeOfType(this object actual, Type expected) { Assert.IsNotType(expected, actual); }