public void Should_be_able_to_cast_fake_object_of_one_type_to_other_using_generic_method() { var foo = A.Fake <IFoo>(); var bar = Fake.CastTo <IBar>(foo); Assert.That(bar, Is.Not.Null.And.SameAs(foo)); }
public void Should_be_able_to_cast_fake_object_of_one_type_to_other_interface_type() { var foo = A.Fake <IFoo>(); Fake.CastTo(typeof(IBar), foo); var bar = foo as IBar; Assert.That(bar, Is.Not.Null.And.SameAs(foo)); }
public void GenericCastTo_should_be_null_guarded() { // Arrange // Act // Assert NullGuardedConstraint.Assert(() => Fake.CastTo <IBar>(A.Fake <IFoo>())); }
public void CastTo_should_be_null_guarded() { // Arrange // Act // Assert NullGuardedConstraint.Assert(() => Fake.CastTo(typeof(IBar), A.Fake <IFoo>())); }
public void CastTo_should_resolve_fake_cast_manager() { // Arrange this.StubResolveWithFake <IFakeCastManager>(); // Act var foo = A.Fake <IFoo>(); Fake.CastTo(typeof(IBar), foo); // Assert A.CallTo(() => ServiceLocator.Current.Resolve(typeof(IFakeCastManager))).Assert(Happened.Once); }
public void CastTo_should_call_cast_to_on_fake_manager() { // Arrange var foo = A.Fake <IFoo>(); var bar = A.Fake <IBar>(); var manager = this.StubResolveWithFake <IFakeCastManager>(); // Act Fake.CastTo(typeof(IBar), foo); // Assert A.CallTo(() => manager.CastTo(typeof(IBar), foo)).Assert(Happened.Once); }
public void GenericCastTo_should_return_passed_in_object() { // Arrange var foo = new FakeThatImplementsIBar(A.Fake <IFoo>()); var manager = this.StubResolveWithFake <IFakeCastManager>(); // Act var result = Fake.CastTo <IBar>(foo); // Assert Assert.That(result, Is.SameAs(foo)); }
public void Generic_CastTo_should_call_CastTo_on_fake_manager() { // Arrange var foo = new FakeThatImplementsIBar(A.Fake <IFoo>()); var manager = this.StubResolveWithFake <IFakeCastManager>(); // Act Fake.CastTo <IBar>(foo); // Assert A.CallTo(() => manager.CastTo(typeof(IBar), foo)).Assert(Happened.Once); }
public void Generic_CastTo_should_resolve_fake_cast_manager() { // Arrange var bar = A.Fake <IBar>(); var manager = this.StubResolveWithFake <IFakeCastManager>(); // Act var foo = new FakeThatImplementsIBar(A.Fake <IFoo>()); Fake.CastTo <IBar>(foo); // Assert A.CallTo(() => ServiceLocator.Current.Resolve(typeof(IFakeCastManager))).Assert(Happened.Once); }