public void InstanceIsExactlyTypeReference() { ModelBase act = new ModelDerived(); Type t = typeof(ModelBase); // MSTest does not support this case. // NUnit Assert.That(act, Is.TypeOf(t), () => "Some context"); // Some context // Expected: <ModelBase> // But was: <ModelDerived> // XUnit XUnitAssert.IsType(t, act); // Assert.IsType() Failure // Expected: ModelBase // Actual: ModelDerived // Fluent act.Should().BeOfType(t, "SOME REASONS"); // Expected type to be ModelBase because SOME REASONS, but found ModelDerived. // Shouldly act.ShouldBeOfType(t, "Some context"); // act // should be of type // ModelBase // but was // ModelDerived // // Additional Info: // Some context }
public void InstanceIsExactlyStaticType() { ModelBase act = new ModelDerived(); ModelBase iModel; // MSTest does not support this case. // NUnit Assert.That(act, Is.TypeOf <ModelBase>(), () => "Some context"); // Some context // Expected: <ModelBase> // But was: <ModelDerived> // XUnit iModel = XUnitAssert.IsType <ModelBase>(act); // Assert.IsType() Failure // Expected: ModelBase // Actual: ModelDerived // Fluent iModel = act.Should().BeOfType <ModelBase>("SOME REASONS").Which; // Expected type to be ModelBase because SOME REASONS, but found ModelDerived. // Shouldly iModel = act.ShouldBeOfType <ModelBase>("Some context"); // act // should be of type // ModelBase // but was // ModelDerived // // Additional Info: // Some context }
public void InstanceIsNotAssignableToStaticType() { ModelBase act = new ModelDerived(); // MSTest does not support this case. // NUnit Assert.That(act, Is.Not.InstanceOf <IModel>(), () => "Some context"); // Some context // Expected: not instance of <IModel> // But was: <ModelDerived> // XUnit does not support this case. // Fluent act.Should().NotBeAssignableTo <IModel>("SOME REASONS"); // Expected act to not be assignable to IModel because SOME REASONS, but ModelDerived is. // Shouldly act.ShouldNotBeAssignableTo <IModel>("Some context"); // act // should not be assignable to // IModel // but was // ModelDerived (13726014) // // Additional Info: // Some context }
public void InstanceIsNotAssignableToTypeReference() { ModelBase act = new ModelDerived(); Type t = typeof(IModel); // MSTest MSTestAssert.IsNotInstanceOfType(act, t, "Some context"); // Assert.IsNotInstanceOfType failed. Wrong Type:<IModel>. Actual type:<ModelDerived>. Some context // NUnit Assert.That(act, Is.Not.InstanceOf(t), () => "Some context"); // Some context // Expected: not instance of <IModel> // But was: <ModelDerived> // XUnit does not support this case. // Fluent act.Should().NotBeAssignableTo(t, "SOME REASONS"); // Expected act to not be assignable to IModel because SOME REASONS, but ModelDerived is. // Shouldly act.ShouldNotBeAssignableTo(t, "Some context"); // act // should not be assignable to // IModel // but was // ModelDerived (63566392) // // Additional Info: // Some context }
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 }