Exemple #1
0
        public void GetterVoidTest()
        {
            var tPoco = new VoidMethodPoco();

            dynamic tTest = new DynamicObjects.Get(tPoco);

            tTest.Action();
        }
Exemple #2
0
        public void GetterArrayTest()
        {
            var tArray = new int[] { 1, 2, 3 };

            dynamic tTest = new DynamicObjects.Get(tArray);

            Dynamic.ApplyEquivalentType(tTest, typeof(IStringIntIndexer));

            Assert.AreEqual(tArray[2].ToString(), tTest[2]);
        }
Exemple #3
0
        public void GetterAnonTest()
        {
            var tAnon = new { Prop1 = "Test", Prop2 = 42L, Prop3 = Guid.NewGuid() };

            dynamic tTest = new DynamicObjects.Get(tAnon);

            Assert.AreEqual(tAnon.Prop1, tTest.Prop1);
            Assert.AreEqual(tAnon.Prop2, tTest.Prop2);
            Assert.AreEqual(tAnon.Prop3, tTest.Prop3);
        }
Exemple #4
0
        public void GetterEventTest2()
        {
            dynamic dynEvent = new DynamicObjects.Get(new PocoEvent());

            Dynamic.ApplyEquivalentType(dynEvent, typeof(IEvent));
            var tSet = false;
            EventHandler <EventArgs> tActsLikeOnEvent = (obj, args) => tSet = true;

            dynEvent.Event += tActsLikeOnEvent;
            dynEvent.Event -= tActsLikeOnEvent;
            dynEvent.OnEvent(null, null);
            Assert.AreEqual(false, tSet);
        }
Exemple #5
0
        public void GetterDynamicTest()
        {
            dynamic tNew = new ExpandoObject();

            tNew.Prop1 = "Test";
            tNew.Prop2 = 42L;
            tNew.Prop3 = Guid.NewGuid();

            dynamic tTest = new DynamicObjects.Get(tNew);


            Assert.AreEqual(tNew.Prop1, tTest.Prop1);
            Assert.AreEqual(tNew.Prop2, tTest.Prop2);
            Assert.AreEqual(tNew.Prop3, tTest.Prop3);
        }
Exemple #6
0
        public void TestAnonInterface()
        {
            dynamic tInterface = new DynamicObjects.Get(new
            {
                CopyArray =
                    ReturnVoid.Arguments <Array, int>(
                        (ar, i) => Enumerable.Range(1, 10)),
                Count          = 10,
                IsSynchronized = false,
                SyncRoot       = this,
                GetEnumerator  =
                    Return <IEnumerator> .Arguments(
                        () => Enumerable.Range(1, 10).GetEnumerator())
            });

            Dynamic.ApplyEquivalentType(tInterface, typeof(ICollection), typeof(IEnumerable));

            Assert.AreEqual(10, tInterface.Count);
            Assert.AreEqual(false, tInterface.IsSynchronized);
            Assert.AreEqual(this, tInterface.SyncRoot);
            Assert.That((object)tInterface.GetEnumerator(), Is.InstanceOf <IEnumerator>());
        }
        public void TestAnonInterface()
        {
            dynamic tInterface = new DynamicObjects.Get(new
                                                            {
                                                                CopyArray =
                                                            ReturnVoid.Arguments<Array, int>(
                                                                (ar, i) => Enumerable.Range(1, 10)),
                                                                Count = 10,
                                                                IsSynchronized = false,
                                                                SyncRoot = this,
                                                                GetEnumerator =
                                                            Return<IEnumerator>.Arguments(
                                                                () => Enumerable.Range(1, 10).GetEnumerator())
                                                            });

            Dynamic.ApplyEquivalentType(tInterface, typeof (ICollection), typeof (IEnumerable));

            Assert.AreEqual(10, tInterface.Count);
            Assert.AreEqual(false, tInterface.IsSynchronized);
            Assert.AreEqual(this, tInterface.SyncRoot);
            Assert.That(tInterface.GetEnumerator(), Is.InstanceOf<IEnumerator>());
        }
        public void GetterVoidTest()
        {
            var tPoco = new VoidMethodPoco();

            dynamic tTest = new DynamicObjects.Get(tPoco);

            tTest.Action();
        }
 public void GetterEventTest2()
 {
     dynamic dynEvent = new DynamicObjects.Get(new PocoEvent());
     Dynamic.ApplyEquivalentType(dynEvent, typeof (IEvent));
     var tSet = false;
     EventHandler<EventArgs> tActsLikeOnEvent = (obj, args) => tSet = true;
     dynEvent.Event += tActsLikeOnEvent;
     dynEvent.Event -= tActsLikeOnEvent;
     dynEvent.OnEvent(null, null);
     Assert.AreEqual(false, tSet);
 }
        public void GetterDynamicTest()
        {
            dynamic tNew = new ExpandoObject();
            tNew.Prop1 = "Test";
            tNew.Prop2 = 42L;
            tNew.Prop3 = Guid.NewGuid();

            dynamic tTest = new DynamicObjects.Get(tNew);

            Assert.AreEqual(tNew.Prop1, tTest.Prop1);
            Assert.AreEqual(tNew.Prop2, tTest.Prop2);
            Assert.AreEqual(tNew.Prop3, tTest.Prop3);
        }
        public void GetterArrayTest()
        {
            var tArray = new int[] {1, 2, 3};

            dynamic tTest = new DynamicObjects.Get(tArray);
            Dynamic.ApplyEquivalentType(tTest, typeof (IStringIntIndexer));

            Assert.AreEqual(tArray[2].ToString(), tTest[2]);
        }
        public void GetterAnonTest()
        {
            var tAnon = new {Prop1 = "Test", Prop2 = 42L, Prop3 = Guid.NewGuid()};

            dynamic tTest = new DynamicObjects.Get(tAnon);

            Assert.AreEqual(tAnon.Prop1, tTest.Prop1);
            Assert.AreEqual(tAnon.Prop2, tTest.Prop2);
            Assert.AreEqual(tAnon.Prop3, tTest.Prop3);
        }