Exemplo n.º 1
0
            public void OnAfterCallIntercepted(ICompletedFakeObjectCall call, IFakeObjectCallRule ruleThatWasApplied)
            {
                Guard.AgainstNull(call, "call");

                if (call.Method.Name.Equals("TrapConstraints"))
                {
                    this.realTrap.TrapConstraints(call.GetArgument <Action>(0));
                }
            }
Exemplo n.º 2
0
        public void CreateFake_should_pass_options_builder_that_returns_itself_for_any_call(Func <IFakeOptionsBuilder <Foo>, IFakeOptionsBuilder <Foo> > call)
        {
            Guard.AgainstNull(call, "call");

            // Arrange
            IFakeOptionsBuilder <Foo> builderPassedToAction = null;

            // Act
            this.creator.CreateFake <Foo>(x => { builderPassedToAction = x; });

            // Assert
            Assert.That(call.Invoke(builderPassedToAction), Is.SameAs(builderPassedToAction));
        }
Exemplo n.º 3
0
        public void CreateFake_should_pass_options_object_that_returns_itself_for_any_call(Func <IFakeOptions <Foo>, IFakeOptions <Foo> > call)
        {
            Guard.AgainstNull(call, "call");

            // Arrange
            IFakeOptions <Foo> optionsPassedToAction = null;

            // Act
            this.creator.CreateFake <Foo>(x => { optionsPassedToAction = x; });

            // Assert
            call.Invoke(optionsPassedToAction).Should().BeSameAs(optionsPassedToAction);
        }
Exemplo n.º 4
0
        public void Should_provide_expected_description(Func <Repeated> repeated, string expectedDescription)
        {
            Guard.AgainstNull(repeated, "repeated");

            // Arrange
            var repeatedInstance = repeated.Invoke();

            // Act
            var description = repeatedInstance.ToString();

            // Assert
            description.Should().Be(expectedDescription);
        }
Exemplo n.º 5
0
        public void Should_succeed_for_interceptable_methods(InterceptionTestCase testCase)
        {
            Guard.AgainstNull(testCase, "testCase");

            // Arrange
            string reason = null;

            // Act
            var result = this.validator.MethodCanBeInterceptedOnInstance(testCase.Method, testCase.Target, out reason);

            // Assert
            Assert.That(result, Is.True);
            Assert.That(reason, Is.Null);
        }
Exemplo n.º 6
0
        public void Should_fail_for_non_interceptable_methods(NonInterceptableTestCase testCase)
        {
            Guard.AgainstNull(testCase, "testCase");

            // Arrange
            string reason = null;

            // Act
            var result = this.validator.MethodCanBeInterceptedOnInstance(testCase.Method, testCase.Target, out reason);

            // Assert
            Assert.That(result, Is.False);
            Assert.That(reason, Is.EqualTo(testCase.FailReason));
        }
        public void Should_return_dummy_from_container_when_available(object dummyInContainer)
        {
            Guard.AgainstNull(dummyInContainer, "dummyInContainer");

            // Arrange
            this.StubContainerWithValue(dummyInContainer);

            // Act
            object dummy;
            var    result = this.session.TryResolveDummyValue(dummyInContainer.GetType(), out dummy);

            // Assert
            Assert.That(result, Is.True);
            Assert.That(dummy, Is.SameAs(dummyInContainer));
        }
Exemplo n.º 8
0
        public void Should_return_dummy_from_container_when_available(object dummyInContainer)
        {
            Guard.AgainstNull(dummyInContainer, "dummyInContainer");

            // Arrange
            var session = new DummyValueCreationSession(
                this.CreateDummyFactoryThatMakes(dummyInContainer),
                this.fakeObjectCreator);

            // Act
            object dummy;
            var    result = session.TryResolveDummyValue(dummyInContainer.GetType(), out dummy);

            // Assert
            result.Should().BeTrue();
            dummy.Should().BeSameAs(dummyInContainer);
        }