Exemplo n.º 1
0
        public void Calls_to_returns_fake_configuration_for_the_faked_object_when_void_call_is_specified()
        {
            var fake = new Fake <IFoo>();

            IVoidConfiguration <IFoo> voidConfiguration = fake.CallsTo(x => x.Bar()) as FakeConfiguration <IFoo>;
            var configuration = voidConfiguration as FakeConfiguration <IFoo>;

            Assert.That(configuration.Fake.Object, Is.SameAs(fake.FakedObject));
        }
Exemplo n.º 2
0
        public void AnyCall_returns_fake_configuration_for_the_faked_object()
        {
            var fake = new Fake <IFoo>();

            IVoidConfiguration <IFoo> voidConfiguration = fake.AnyCall();
            var configuration = voidConfiguration as FakeConfiguration <IFoo>;

            Assert.That(configuration.Fake.Object, Is.SameAs(fake.FakedObject));
        }
        public static void MultipleAssignOutAndRefParameters(
            IHaveARef subject, string outValue, IVoidConfiguration callSpec, Exception exception)
        {
            "Given a fake with a method that has a ref parameter"
            .x(() => subject = A.Fake <IHaveARef>());

            "And a call specification on that fake"
            .x(() => callSpec = A.CallTo(() => subject.MightReturnAKnownValue(ref outValue)).WithAnyArguments());

            "And the call specification is configured to assign out and ref parameters"
            .x(() => callSpec.AssignsOutAndRefParameters("test1"));

            "When the fake is configured to assign out and ref parameters again"
            .x(() => exception = Record.Exception(() => callSpec.AssignsOutAndRefParameters("test2")));

            "Then it throws an invalid operation exception"
            .x(() => exception.Should().BeAnExceptionOfType <InvalidOperationException>());
        }
 private static IPropertySetterConfiguration AsPropertySetterConfiguration(
     IVoidConfiguration voidArgumentValidationConfiguration) =>
 new PropertySetterAdapter(voidArgumentValidationConfiguration);
 public IPropertySetterConfiguration Invokes(Action <IFakeObjectCall> action)
 {
     this.voidConfiguration = this.voidConfiguration.Invokes(action);
     return(this);
 }
 public PropertySetterAdapter(IVoidConfiguration voidArgumentValidationConfiguration)
 {
     this.voidConfiguration = voidArgumentValidationConfiguration;
 }
        public static void MultipleAssignOutAndRefParameters(
            IHaveARef subject, string outValue, IVoidConfiguration callSpec, Exception exception)
        {
            "Given a fake with a method that has a ref parameter"
                .x(() => subject = A.Fake<IHaveARef>());

            "And a call specification on that fake"
                .x(() => callSpec = A.CallTo(() => subject.MightReturnAKnownValue(ref outValue)).WithAnyArguments());

            "And the call specification is configured to assign out and ref parameters"
                .x(() => callSpec.AssignsOutAndRefParameters("test1"));

            "When the fake is configured to assign out and ref parameters again"
                .x(() => exception = Record.Exception(() => callSpec.AssignsOutAndRefParameters("test2")));

            "Then it throws an invalid operation exception"
                .x(() => exception.Should().BeAnExceptionOfType<InvalidOperationException>());
        }