Esempio n. 1
0
        public void RegisterTemplate_AlreadyRegistered_Throws()
        {
            var name = "foobar";
            var template = new ManosTemplateStub ();

            TemplateFactory.Register (name, template);

            Assert.Throws<InvalidOperationException> (() => TemplateFactory.Register (name, template));
        }
Esempio n. 2
0
        public void RegisterTemplate_RegisterAndRetrieve_ItemIsRegistered()
        {
            var name = "foobar";
            var expected = new ManosTemplateStub ();

            TemplateFactory.Register (name, expected);

            var retrieved = TemplateFactory.Get (name);

            Assert.AreEqual (expected, retrieved);
        }
Esempio n. 3
0
        public void Clear_RegisteredItems_UnregistersItems()
        {
            var name = "blah";
            IManosTemplate template = new ManosTemplateStub ();

            TemplateFactory.Register (name, template);

            TemplateFactory.Clear ();

            template = TemplateFactory.Get (name);
            Assert.IsNull (template);
        }
Esempio n. 4
0
        public void RegisterTemplate_NullName_Throws()
        {
            IManosTemplate template = new ManosTemplateStub ();

            Assert.Throws<ArgumentNullException> (() => TemplateFactory.Register (null, template));
        }
Esempio n. 5
0
        public void TryGet_RegisteredTemplate_SetsTemplate()
        {
            var name = "manbearpig";
            IManosTemplate expected = new ManosTemplateStub ();

            TemplateFactory.Register (name, expected);

            IManosTemplate actual = null;
            TemplateFactory.TryGet (name, out actual);

            Assert.AreSame (expected, actual);
        }
Esempio n. 6
0
        public void TryGet_RegisteredTemplate_ReturnsTrue()
        {
            var name = "barkingpossum";
            IManosTemplate template = new ManosTemplateStub ();

            TemplateFactory.Register (name, template);

            bool found = TemplateFactory.TryGet (name, out template);

            Assert.IsTrue (found);
        }
Esempio n. 7
0
        public void TryGet_NonExistant_SetsTemplateNull()
        {
            var name = "wolfbear";
            IManosTemplate template = new ManosTemplateStub ();

            TemplateFactory.TryGet (name, out template);

            Assert.IsNull (template);
        }