Exemple #1
0
        public void ConfigureFake_should_be_null_guarded()
        {
            var configurator = new TestableConfigurator <IFoo>() as IFakeConfigurator;

            NullGuardedConstraint.Assert(() =>
                                         configurator.ConfigureFake(A.Fake <IFoo>()));
        }
Exemple #2
0
        public void ConfigureFake_should_throw_when_the_specified_fake_object_is_not_of_the_correct_type()
        {
            var configurator = new TestableConfigurator <IFoo>() as IFakeConfigurator;

            var thrown = Assert.Throws <ArgumentException>(() =>
                                                           configurator.ConfigureFake(""));

            Assert.That(thrown.Message, Is.StringStarting("The FakeItEasy.Core.FakeConfiguratorTests+TestableConfigurator`1[FakeItEasy.Tests.IFoo] can only configure fakes of the type 'FakeItEasy.Tests.IFoo'."));
            Assert.That(thrown.ParamName, Is.EqualTo("fakeObject"));
        }
Exemple #3
0
        public void ConfigureFake_should_call_abstract_method()
        {
            var configurator = new TestableConfigurator <IFoo>();

            var foo = A.Fake <IFoo>();

            ((IFakeConfigurator)configurator).ConfigureFake(foo);

            Assert.That(configurator.InstancePassedToConfigureFake, Is.SameAs(foo));
        }
Exemple #4
0
        public void ConfigureFake_should_throw_when_the_specified_fake_object_is_not_of_the_correct_type()
        {
            var expectedMessage = string.Format(
                CultureInfo.CurrentCulture,
                "The {0} can only configure fakes of type '{1}'.*",
                typeof(TestableConfigurator <IFoo>),
                typeof(IFoo));

            var configurator = new TestableConfigurator <IFoo>() as IFakeConfigurator;

            var exception = Record.Exception(() =>
                                             configurator.ConfigureFake(string.Empty));

            exception.Should()
            .BeAnExceptionOfType <ArgumentException>()
            .WithMessage(expectedMessage)
            .And.ParamName.Should().Be("fakeObject");
        }
Exemple #5
0
        public void ForType_should_return_type_of_type_parameter()
        {
            var configurator = new TestableConfigurator <IFoo>();

            Assert.That(configurator.ForType, Is.EqualTo(typeof(IFoo)));
        }