Esempio n. 1
0
        public virtual void TestThreadSafety()
        {
            CodeResolverRegistry.RegisterCodeResolverRegistryForVersion(SpecificationVersion.R02_04_02, registry1);
            CodeResolverRegistry.RegisterCodeResolverRegistryForVersion(SpecificationVersion.R02_04_03, registry2);
            CodeResolverRegistry.RegisterCodeResolverRegistryForVersion(SpecificationVersion.R02_04_03_AB, registry3);
            CodeResolverRegistry.RegisterCodeResolverRegistryForVersion(SpecificationVersion.V01R04_2_SK, registry4);
            CodeResolverRegistry.RegisterCodeResolverRegistryForVersion(SpecificationVersion.V01R04_3, registry5);
            CodeResolverRegistry.RegisterCodeResolverRegistryForVersion(SpecificationVersion.V01R04_3_ON, registry6);
            IList <CodeResolverRegistryTest.ThreadTest> testList = new List <CodeResolverRegistryTest.ThreadTest>();

            for (int i = 0; i < 100; i++)
            {
                testList.Add(new CodeResolverRegistryTest.ThreadTest(this, i * 6, SpecificationVersion.R02_04_02, registry1));
                testList.Add(new CodeResolverRegistryTest.ThreadTest(this, i * 6 + 1, SpecificationVersion.R02_04_03, registry2));
                testList.Add(new CodeResolverRegistryTest.ThreadTest(this, i * 6 + 2, SpecificationVersion.R02_04_03_AB, registry3));
                testList.Add(new CodeResolverRegistryTest.ThreadTest(this, i * 6 + 3, SpecificationVersion.V01R04_2_SK, registry4));
                testList.Add(new CodeResolverRegistryTest.ThreadTest(this, i * 6 + 4, SpecificationVersion.V01R04_3, registry5));
                testList.Add(new CodeResolverRegistryTest.ThreadTest(this, i * 6 + 5, SpecificationVersion.V01R04_3_ON, registry6));
            }
            foreach (CodeResolverRegistryTest.ThreadTest threadTest in testList)
            {
                threadTest.Start();
            }
            foreach (CodeResolverRegistryTest.ThreadTest threadTest in testList)
            {
                threadTest.Join();
            }
            foreach (CodeResolverRegistryTest.ThreadTest threadTest in testList)
            {
                // "thread " + threadTest.GetThreadId(),
                NUnit.Framework.Assert.IsTrue(threadTest.HasPassedTest());
            }
        }
Esempio n. 2
0
        public virtual void TestEnumResolverUsingInterface()
        {
            CodeResolverRegistry.RegisterResolver(typeof(MockCharacters), new EnumBasedCodeResolver(typeof(MockEnum)));
            MockCharacters fred = CodeResolverRegistry.Lookup <MockCharacters>(MOCK_CHARACTERS_TYPE, "FRED");

            Assert.IsNotNull(fred, "fred");
            Assert.AreEqual(MockEnum.FRED, fred, "fred");
        }
Esempio n. 3
0
        public virtual void TestEnumResolver()
        {
            CodeResolverRegistry.RegisterResolver(typeof(MockEnum), new EnumBasedCodeResolver(typeof(MockEnum)));
            MockEnum fred = CodeResolverRegistry.Lookup <MockEnum>(MOCK_ENUM_TYPE, "FRED");

            Assert.IsNotNull(fred, "fred");
            Assert.AreEqual(MockEnum.FRED, fred, "fred");
        }
Esempio n. 4
0
 public virtual void TestRegistryRegistration()
 {
     CodeResolverRegistry.RegisterCodeResolverRegistryForVersion(SpecificationVersion.R02_04_02, registry1);
     CodeResolverRegistry.RegisterCodeResolverRegistryForVersion(SpecificationVersion.R02_04_03, registry2);
     CodeResolverRegistry.RegisterCodeResolverRegistryForVersion(SpecificationVersion.R02_04_03_AB, registry3);
     NUnit.Framework.Assert.AreEqual(registry1, CodeResolverRegistry.GetCodeResolverRegistryForVersion(SpecificationVersion.R02_04_02));
     NUnit.Framework.Assert.AreEqual(registry2, CodeResolverRegistry.GetCodeResolverRegistryForVersion(SpecificationVersion.R02_04_03));
     NUnit.Framework.Assert.AreEqual(registry3, CodeResolverRegistry.GetCodeResolverRegistryForVersion(SpecificationVersion.R02_04_03_AB));
     NUnit.Framework.Assert.IsNull(CodeResolverRegistry.GetCodeResolverRegistryForVersion(SpecificationVersion.V01R04_3));
 }
Esempio n. 5
0
 public void Run()
 {
     CodeResolverRegistry.SetThreadLocalVersion(this.version);
     try
     {
         Thread.Sleep(1000);
     }
     catch (Exception)
     {
     }
     this.passedTest = (CodeResolverRegistry.GetRegistry() == this.registry);
 }
Esempio n. 6
0
 public virtual void TestRegistryRetrieval()
 {
     CodeResolverRegistry.RegisterCodeResolverRegistryForVersion(SpecificationVersion.R02_04_02, registry1);
     CodeResolverRegistry.RegisterCodeResolverRegistryForVersion(SpecificationVersion.R02_04_03, registry2);
     CodeResolverRegistry.RegisterCodeResolverRegistryForVersion(SpecificationVersion.R02_04_03_AB, registry3);
     CodeResolverRegistry.SetThreadLocalVersion(SpecificationVersion.R02_04_02);
     NUnit.Framework.Assert.AreEqual(registry1, CodeResolverRegistry.GetRegistry());
     CodeResolverRegistry.SetThreadLocalVersion(SpecificationVersion.R02_04_03);
     NUnit.Framework.Assert.AreEqual(registry2, CodeResolverRegistry.GetRegistry());
     CodeResolverRegistry.SetThreadLocalVersion(SpecificationVersion.R02_04_03_AB);
     NUnit.Framework.Assert.AreEqual(registry3, CodeResolverRegistry.GetRegistry());
     CodeResolverRegistry.ClearThreadLocalVersion();
     NUnit.Framework.Assert.AreEqual(CodeResolverRegistry.GetDefaultRegistry(), CodeResolverRegistry.GetRegistry());
 }
Esempio n. 7
0
 public virtual void Teardown()
 {
     CodeResolverRegistry.ClearThreadLocalVersion();
     CodeResolverRegistry.RemoveAllRegistries();
     CodeResolverRegistry.UnregisterAll();
 }
Esempio n. 8
0
 public virtual void TearDown()
 {
     CodeResolverRegistry.UnregisterAll();
 }