Ejemplo n.º 1
0
        public void TryCreateTest()
        {
            var factory = new IntFactory();

            FactoryRegistry <int> .RegisterFactory(factory);

            Assert.IsTrue(FactoryRegistry <int> .TryCreate(out var created, 1234));
            Assert.AreEqual(1234, created);
        }
Ejemplo n.º 2
0
        public void CreateTest()
        {
            var factory = new IntFactory();

            FactoryRegistry <int> .RegisterFactory(factory);

            Assert.AreEqual(0, factory.Create());
            Assert.AreEqual(1234, factory.Create(1234));
        }
Ejemplo n.º 3
0
        public void RegisterFactoryTest()
        {
            Assert.IsNull(FactoryRegistry <int> .Factory);

            var factory = new IntFactory();

            Assert.IsTrue(FactoryRegistry <int> .RegisterFactory(factory));
            Assert.AreEqual(factory, FactoryRegistry <int> .Factory);
            Assert.IsNotNull(FactoryRegistry <int> .Factory);

            var factory2 = new IntFactory();

            Assert.AreNotEqual(factory, factory2);
            Assert.IsFalse(FactoryRegistry <int> .RegisterFactory(factory2));
            Assert.AreEqual(factory, FactoryRegistry <int> .Factory);

            Assert.IsTrue(FactoryRegistry <int> .RegisterFactory(factory2, true));
            Assert.AreEqual(factory2, FactoryRegistry <int> .Factory);
        }