示例#1
0
        public void RegisterMultiple_Instances_Of_Type()
        {
            var service = GetService();

            var i1 = new InstanceTest {
                MyString = "Original 1"
            };
            var c1 = new InstanceTest {
                MyString = "Cloned 1"
            };

            var i2 = new InstanceTest {
                MyString = "Original 2"
            };
            var c2 = new InstanceTest {
                MyString = "Cloned 2"
            };

            service.AddInstance(i1, c1);
            service.AddInstance(i2, c2);

            var r1 = service.TryGetInstance(i1);

            Assert.AreEqual("Cloned 1", ((InstanceTest)r1).MyString);
        }
示例#2
0
        public void DeepClone_Public()
        {
            var service = GetService();

            var i1 = new InstanceTest {
                MyString = "Original 1"
            };
            var c1 = new InstanceTest {
                MyString = "Cloned 1"
            };

            var i2 = new InstanceTest2 {
                MyString = "Original 2"
            };
            var c2 = new InstanceTest2 {
                MyString = "Cloned 2"
            };

            service.AddInstance(i1, c1);
            service.AddInstance(i2, c2);

            var r1 = service.TryGetInstance(i1);

            Assert.AreEqual("Cloned 1", ((InstanceTest)r1).MyString);
        }