public void PerformClusterTesting()
            {
                var cluster = new FakeCluster <ScopeCustomNonGenericHierarchy2_Cluster>(
                    null
                    );

                var scope0 = cluster.CreateCustomScope();
                var scope1 = cluster.CreateCustomScope();

                var b0_0 = (IB)cluster.Get(typeof(IB), scope0);

                Assert.IsNotNull(b0_0);
                Assert.IsNotNull(b0_0.A);
                Assert.AreEqual(Message, b0_0.Message);

                var b1 = (IB)cluster.Get(typeof(IB), scope1);

                Assert.IsNotNull(b1);
                Assert.IsNotNull(b1.A);
                Assert.AreEqual(Message, b1.Message);

                var b0_1 = (IB)cluster.Get(typeof(IB), scope0);

                Assert.IsNotNull(b0_1);
                Assert.IsNotNull(b0_1.A);
                Assert.AreEqual(Message, b0_1.Message);

                Assert.AreNotSame(b0_0, b0_1);
                Assert.AreSame(b0_0.A, b0_1.A);

                Assert.AreNotSame(b0_0, b1);
                Assert.AreNotSame(b0_0.A, b1.A);
            }
            public void PerformClusterTesting()
            {
                var cluster = new FakeCluster <ScopeCustomNonGenericSingleObject_Cluster>(
                    null
                    );

                try
                {
                    var a0 = cluster.Get(typeof(IA));

                    Assert.Fail("This line should never be executed");
                }
                catch (DpdtException excp)
                    when(excp.Type == DpdtExceptionTypeEnum.CustomScopeObjectDoesNotFound && excp.AdditionalArgument == typeof(A).FullName)
                    {
                        //this is ok, test is green
                    }

                var scope1 = cluster.CreateCustomScope();
                var scope2 = cluster.CreateCustomScope();

                var a1 = (IA)cluster.Get(typeof(IA), scope1);

                Assert.IsNotNull(a1);
                Assert.IsFalse(a1.Disposed);

                var a2 = (IA)cluster.Get(typeof(IA), scope2);

                Assert.IsNotNull(a2);
                Assert.IsFalse(a2.Disposed);

                Assert.AreNotSame(a1, a2);

                var a1_2 = (IA)cluster.Get(typeof(IA), scope1);

                Assert.IsNotNull(a1_2);
                Assert.AreSame(a1, a1_2);

                scope1.Dispose();
                Assert.IsTrue(a1.Disposed);
                Assert.IsFalse(a2.Disposed);

                scope2.Dispose();
                Assert.IsTrue(a2.Disposed);
            }
        public void PerformClusterTesting()
        {
            var firstCluster = new FakeCluster <ScopeCustomGenericHierarchy2DifferentCluster_FirstCluster>(
                null
                );
            var lastCluster = new FakeCluster <ScopeCustomGenericHierarchy2DifferentCluster_LastCluster>(
                firstCluster
                );

            var scope0 = lastCluster.CreateCustomScope();
            var scope1 = lastCluster.CreateCustomScope();

            var b0_0 = lastCluster.Get <IB>(scope0);

            Assert.IsNotNull(b0_0);
            Assert.IsNotNull(b0_0.A);
            Assert.AreEqual(ScopeCustomGenericHierarchy2DifferentCluster_LastCluster.Message, b0_0.Message);

            var b1 = lastCluster.Get <IB>(scope1);

            Assert.IsNotNull(b1);
            Assert.IsNotNull(b1.A);
            Assert.AreEqual(ScopeCustomGenericHierarchy2DifferentCluster_LastCluster.Message, b1.Message);

            var b0_1 = lastCluster.Get <IB>(scope0);

            Assert.IsNotNull(b0_1);
            Assert.IsNotNull(b0_1.A);
            Assert.AreEqual(ScopeCustomGenericHierarchy2DifferentCluster_LastCluster.Message, b0_1.Message);



            Assert.AreNotSame(b0_0, b0_1);
            Assert.AreSame(b0_0.A, b0_1.A);

            Assert.AreNotSame(b0_0, b1);
            Assert.AreNotSame(b0_0.A, b1.A);
        }
Beispiel #4
0
            public void PerformClusterTesting()
            {
                var cluster = new FakeCluster <DefaultValueCustom_Cluster>(
                    null
                    );

                using var scope = cluster.CreateCustomScope();

                var int_const = cluster.Get <Int_Const>(scope);

                Assert.IsNotNull(int_const);
                Assert.AreEqual(Int_Const.DefValue, int_const.A);

                var int_default = cluster.Get <Int_Default>(scope);

                Assert.IsNotNull(int_default);
                Assert.AreEqual(default(int), int_default.A);



                var string_const = cluster.Get <String_Const>(scope);

                Assert.IsNotNull(string_const);
                Assert.AreEqual(String_Const.DefValue, string_const.A);

                var string_default = cluster.Get <String_Default>(scope);

                Assert.IsNotNull(string_default);
                Assert.AreEqual(default(string), string_default.A);



                var char_const = cluster.Get <Char_Const>(scope);

                Assert.IsNotNull(char_const);
                Assert.AreEqual(Char_Const.DefValue, char_const.A);

                var char_default = cluster.Get <Char_Default>(scope);

                Assert.IsNotNull(char_default);
                Assert.AreEqual(default(char), char_default.A);



                var float_const = cluster.Get <Float_Const>(scope);

                Assert.IsNotNull(float_const);
                Assert.AreEqual(Float_Const.DefValue, float_const.A);

                var float_default = cluster.Get <Float_Default>(scope);

                Assert.IsNotNull(float_default);
                Assert.AreEqual(default(float), float_default.A);



                var double_const = cluster.Get <Double_Const>(scope);

                Assert.IsNotNull(double_const);
                Assert.AreEqual(Double_Const.DefValue, double_const.A);

                var double_default = cluster.Get <Double_Default>(scope);

                Assert.IsNotNull(double_default);
                Assert.AreEqual(default(double), double_default.A);



                var decimal_const = cluster.Get <Decimal_Const>(scope);

                Assert.IsNotNull(decimal_const);
                Assert.AreEqual(Decimal_Const.DefValue, decimal_const.A);

                var decimal_default = cluster.Get <Decimal_Default>(scope);

                Assert.IsNotNull(decimal_default);

                Assert.AreEqual(default(decimal), decimal_default.A);



                var enum_const = cluster.Get <Enum_Const>();

                Assert.IsNotNull(enum_const);
                Assert.AreEqual(Enum_Const.DefValue, enum_const.A);

                var enum_default = cluster.Get <Enum_Default>();

                Assert.IsNotNull(enum_default);
                Assert.AreEqual(default(DefaultEnum), enum_default.A);



                var reference_default = cluster.Get <Reference_Default>(scope);

                Assert.IsNotNull(reference_default);
                Assert.AreEqual(default(object), reference_default.A);
            }