コード例 #1
0
        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));
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        public void GenericCastTo_should_be_null_guarded()
        {
            // Arrange

            // Act

            // Assert
            NullGuardedConstraint.Assert(() =>
                                         Fake.CastTo <IBar>(A.Fake <IFoo>()));
        }
コード例 #4
0
        public void CastTo_should_be_null_guarded()
        {
            // Arrange

            // Act

            // Assert
            NullGuardedConstraint.Assert(() =>
                                         Fake.CastTo(typeof(IBar), A.Fake <IFoo>()));
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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));
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        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);
        }