public void ShouldDecoratePropertiesOnInstantiatedObjects()
        {
            inst.obj = new MockPropertyAttribute();

            MockObject obj = new MockObject();

            decorator.Decorate(obj);

            SharpWeld.Attributes.PropertyAttribute pa = obj.AttributeProperty;
            Assert.IsNotNull(((MockPropertyAttribute)pa).Obj);
            Assert.IsNotNull(((MockPropertyAttribute)pa).PropertyInfo);
            Assert.AreEqual("DecoratedString", ((MockPropertyAttribute)pa).PropertyInfo.Name);
        }
 public void ShouldBuildAbstractTypeThenGetDecoratedWith2Args()
 {
     MockClass3 actual = builder.BuildAssemblyFromType<MockClass3>(typeof(MockClass3), null);
     Decorator decorator = new ObjectDecorator(new ObjectInstantiator());
     decorator.Decorate<MockClass3>(actual);
     Assert.AreEqual("some1", actual.OtherMagic("some", 1));
 }
 public void ShouldBuildAbstractTypeThenGetDecoratedWith3Args()
 {
     MockClass actual = builder.BuildAssemblyFromType<MockClass>(typeof(MockClass), null);
     Decorator decorator = new ObjectDecorator(new ObjectInstantiator());
     decorator.Decorate<MockClass>(actual);
     Assert.AreEqual("some1help", actual.DoSomeMagic("some", 1, "help"));
 }
 public void ShouldBuildAbstractTypeThenGetDecorated()
 {
     MockClass1 actual = builder.BuildAssemblyFromType<MockClass1>(typeof(MockClass1), null);
     Decorator decorator = new ObjectDecorator(new ObjectInstantiator());
     decorator.Decorate<MockClass1>(actual);
     Assert.AreEqual("This is a sentence", actual.OtherMagic());
 }
Example #5
0
        public void ShouldBuildAbstractTypeThenGetDecoratedWith4Args()
        {
            MockClass4 actual    = builder.BuildAssemblyFromType <MockClass4>(typeof(MockClass4), null);
            Decorator  decorator = new ObjectDecorator(new ObjectInstantiator());

            decorator.Decorate <MockClass4>(actual);
            Assert.AreEqual("some1helpme", actual.DoSomeMagic("some", 1, "help", "me"));
        }
Example #6
0
        public void ShouldBuildAbstractTypeThenGetDecoratedWith2Args()
        {
            MockClass3 actual    = builder.BuildAssemblyFromType <MockClass3>(typeof(MockClass3), null);
            Decorator  decorator = new ObjectDecorator(new ObjectInstantiator());

            decorator.Decorate <MockClass3>(actual);
            Assert.AreEqual("some1", actual.OtherMagic("some", 1));
        }
Example #7
0
        public void ShouldBuildAbstractTypeThenGetDecorated()
        {
            MockClass1 actual    = builder.BuildAssemblyFromType <MockClass1>(typeof(MockClass1), null);
            Decorator  decorator = new ObjectDecorator(new ObjectInstantiator());

            decorator.Decorate <MockClass1>(actual);
            Assert.AreEqual("This is a sentence", actual.OtherMagic());
        }
Example #8
0
        public void ShouldImplementPropertiesAndDecorateThem()
        {
            MockInjectable actual    = builder.BuildAssemblyFromType <MockInjectable>(typeof(MockInjectable), null);
            Decorator      decorator = new ObjectDecorator(new ObjectInstantiator());

            decorator.Decorate <MockInjectable>(actual);
            Assert.IsNotNull(actual.Earth);
        }
        public void ShouldInterruptTheAbstractMethodAndUseAttributeFunction()
        {
            AbstractObjectBuilder<MockClass> builder = new AbstractObjectBuilder<MockClass>(new AssemblyBuilder(new CSharpProvider()));
            MockClass mock = builder.Construct(typeof(MockClass), null);
            Decorator decorator = new ObjectDecorator(new ObjectInstantiator());
            decorator.Decorate<MockClass>(mock);

            Assert.AreEqual("some1helpme", mock.DoSomeMagic("some", 1, "helpme"));
        }
Example #10
0
        private static void Method2ToBenchMark()
        {
            AssemblyOpCodeBuilder builder = new AssemblyOpCodeBuilder();
            MockClass mock = builder.BuildAssemblyFromType<MockClass>(typeof(MockClass), null);
            Decorator decorator = new ObjectDecorator(new ObjectInstantiator());
            decorator.Decorate<MockClass>(mock);

            double value = mock.GetZero();
        }
Example #11
0
        private static void Method1ToBenchMark()
        {
            AbstractObjectBuilder<MockClass> builder = new AbstractObjectBuilder<MockClass>(new AssemblyBuilder(new CSharpProvider()));
            MockClass mock = builder.Construct(typeof(MockClass), null);
            Decorator decorator = new ObjectDecorator(new ObjectInstantiator());
            decorator.Decorate<MockClass>(mock);

            double value = mock.GetZero();
        }
Example #12
0
        public void ShouldInterruptTheAbstractMethodAndUseAttributeFunction()
        {
            AbstractObjectBuilder <MockClass> builder = new AbstractObjectBuilder <MockClass>(new AssemblyBuilder(new CSharpProvider()));
            MockClass mock      = builder.Construct(typeof(MockClass), null);
            Decorator decorator = new ObjectDecorator(new ObjectInstantiator());

            decorator.Decorate <MockClass>(mock);

            Assert.AreEqual("some1helpme", mock.DoSomeMagic("some", 1, "helpme"));
        }
Example #13
0
        private static void Method1ToBenchMark()
        {
            AbstractObjectBuilder <MockClass> builder = new AbstractObjectBuilder <MockClass>(new AssemblyBuilder(new CSharpProvider()));
            MockClass mock      = builder.Construct(typeof(MockClass), null);
            Decorator decorator = new ObjectDecorator(new ObjectInstantiator());

            decorator.Decorate <MockClass>(mock);

            double value = mock.GetZero();
        }
Example #14
0
        private static void Method2ToBenchMark()
        {
            AssemblyOpCodeBuilder builder   = new AssemblyOpCodeBuilder();
            MockClass             mock      = builder.BuildAssemblyFromType <MockClass>(typeof(MockClass), null);
            Decorator             decorator = new ObjectDecorator(new ObjectInstantiator());

            decorator.Decorate <MockClass>(mock);

            double value = mock.GetZero();
        }
        public void ShouldBeAbleToCallAbstractMethodsAndBeImplementedByAnAttribute()
        {
            AbstractMockObject mock      = ConstructDiscreteHelper <AbstractMockObject>();
            Decorator          decorator = new ObjectDecorator(new ObjectInstantiator());

            decorator.Decorate <AbstractMockObject>(mock);
            Assert.AreEqual("The Next Employer", mock.TestGetEmployer());
            Assert.AreEqual("MyName 1", mock.GetTitleAndPosition("MyName", 1));
            Assert.AreEqual((-3 - 5 - 7 - 2), mock.Subtract(3, 5, 7, 2));
            Assert.AreEqual((3 + 5 + 7 + 2), mock.Add(3, 5, 7, 2));
            Assert.AreEqual(0, mock.GetZero());
        }
        public void DecoratePropertyTest()
        {
            AssemblyOpCodeBuilder builder = new AssemblyOpCodeBuilder();
            MockInjectable mock = builder.BuildAssemblyFromType<MockInjectable>(typeof(MockInjectable), null);
            Decorator decorator = new ObjectDecorator(new ObjectInstantiator());
            decorator.Decorate<MockInjectable>(mock);

            Assert.IsNotNull(mock.Fire);
            Assert.IsTrue(mock.Fire is Fire);

            Assert.IsNotNull(mock.Water);
            Assert.IsTrue(mock.Water is Water);

            Assert.IsNotNull(mock.Earth);
            Assert.IsTrue(mock.Earth is Earth);
        }
Example #17
0
        public void DecoratePropertyTest()
        {
            AssemblyOpCodeBuilder builder   = new AssemblyOpCodeBuilder();
            MockInjectable        mock      = builder.BuildAssemblyFromType <MockInjectable>(typeof(MockInjectable), null);
            Decorator             decorator = new ObjectDecorator(new ObjectInstantiator());

            decorator.Decorate <MockInjectable>(mock);

            Assert.IsNotNull(mock.Fire);
            Assert.IsTrue(mock.Fire is Fire);

            Assert.IsNotNull(mock.Water);
            Assert.IsTrue(mock.Water is Water);

            Assert.IsNotNull(mock.Earth);
            Assert.IsTrue(mock.Earth is Earth);
        }
 public void ShouldImplementPropertiesAndDecorateThem()
 {
     MockInjectable actual = builder.BuildAssemblyFromType<MockInjectable>(typeof(MockInjectable), null);
     Decorator decorator = new ObjectDecorator(new ObjectInstantiator());
     decorator.Decorate<MockInjectable>(actual);
     Assert.IsNotNull(actual.Earth);
 }