Пример #1
0
        protected TestBaseFor(params object[] useInstances)
        {
            var instances = new ActivateInstances(useInstances);
            var rules     = DefaultRules.All
                            .After(this.GetType().GetActivateAnythingRuleAttributes())
                            .After(instances);

            Activator = new AnythingActivator(this, rules);
        }
Пример #2
0
        public void ForAClass()
        {
            var result =
                new AnythingActivator(new CreateFromMock(typeof(INterface)))
                .New <ClassWith1ConstructorParam <INterface> >();

            //
            Assert.That(result.Param1, x => CreateFromMock.IsAKnownMock(x));
        }
Пример #3
0
        public void AndAABuildsRequestedType()
        {
            var activator = new AnythingActivator(this);
            var wrappable = activator.New <IWrappable>();

            wrappable.ShouldNotBeNull()
            .ShouldBeAssignableTo <IWrappable>()
            .ShouldBeOfType <WrappableBackstop>();
        }
        public void ForAClass()
        {
            var myObject = new AClass();
            var result   =
                new AnythingActivator(DefaultRules.All.After(new ActivateInstances(myObject)))
                .New <AClass>();

            //
            Assert.That(myObject == result);
        }
        public void ChooseConstructorWithFewestParametersAttribute()
        {
            IEnumerable <IActivateAnythingRule> rules = new[] { new ConstructorWithFewestParametersRule() };
            //
            var result = new AnythingActivator(rules).New <ClassWithMultipleConstructors>();

            //
            result.param1.ShouldBeNull();
            result.param2.ShouldBeNull();
        }
        public void ForAString()
        {
            var result =
                new AnythingActivator(
                    DefaultRules.All
                    .After(new ActivateInstances("ACustomString")))
                .New <string>();

            //
            result.ShouldBe("ACustomString");
        }
Пример #7
0
        public void ForAString()
        {
            var result =
                new AnythingActivator(
                    DefaultRules.All
                    .Union(new ActivateForType <string>("ACustomString")))
                .New <string>();

            //
            result.ShouldBe("ACustomString");
        }
Пример #8
0
        public void ForAClass()
        {
            var myObject = new AClass();
            var result   =
                new AnythingActivator(
                    DefaultRules.All
                    .Union(new ActivateForType <AClass>(myObject)))
                .New <AClass>();

            //
            Assert.That(myObject == result);
        }
Пример #9
0
        public void ForAClass()
        {
            const string aCustomString = "ACustomString";
            var          result        =
                new AnythingActivator(
                    DefaultRules.All
                    .Union(new CreateFromFactoryMethod(
                               typeof(AClass),
                               typeof(AFactory),
                               "BuildMethod",
                               aCustomString))).New <AClass>();

            //
            result.Aparameter.ShouldBe(aCustomString);
        }
        public void ForAFuncOf()
        {
            var myObject = new AClass();
            var myString = "String!";

            //
            var uut     = new AnythingActivator(DefaultRules.All.After(new ActivateInstances(myObject, myString)));
            var result1 = uut.New <Func <AClass> >();
            var result2 = uut.New <Func <string> >();

            //Debug
            xconsole.WriteLine(string.Join(Environment.NewLine, uut.LastErrorList));
            xconsole.WriteLine(string.Join(Environment.NewLine, uut.LastActivationTree));

            //
            Assert.That(result1, x => x() == myObject);
            Assert.That(result2, x => x() == myString);
        }
Пример #11
0
 protected TestBaseFor()
 {
     Activator     = new AnythingActivator(this);
     UnitUnderTest = Activator.New <T>();
 }