Ejemplo n.º 1
0
        public void AddAndRemove()
        {
            Expect.Once.On(m_extensionA).Method("Attach");
            Expect.Once.On(m_extensionB).Method("Attach");
            Expect.Once.On(m_extensionA).Method("Detach");
            Expect.Once.On(m_extensionB).Method("Detach");

            ModuleExtensionCollection extensions = new ModuleExtensionCollection();

            extensions.Add(typeof(IMockExtensionTypeA), m_extensionA);
            extensions.Add(typeof(IMockExtensionTypeB), m_extensionB);
            extensions.Add(typeof(IMockExtensionTypeC), m_extensionC);

            object extension = extensions[typeof(IMockExtensionTypeA)];

            Assert.AreSame(m_extensionA, extension);
            extension = extensions[typeof(IMockExtensionTypeB)];
            Assert.AreSame(m_extensionB, extension);
            extension = extensions[typeof(IMockExtensionTypeC)];
            Assert.AreSame(m_extensionC, extension);

            extensions.Remove(typeof(IMockExtensionTypeA));
            extensions.Remove(typeof(IMockExtensionTypeB));
            extensions.Remove(typeof(IMockExtensionTypeC));

            m_mockery.VerifyAllExpectationsHaveBeenMet();
        }
Ejemplo n.º 2
0
        public void OverrideAnInstalledExtension()
        {
            Expect.Once.On(m_extensionA).Method("Attach");
            Expect.Once.On(m_extensionB).Method("Attach");
            Expect.Once.On(m_extensionB).Method("Detach");
            Expect.Once.On(m_extensionD).Method("Attach");

            ModuleExtensionCollection extensions = new ModuleExtensionCollection();

            extensions.Add <IMockExtensionTypeA>(m_extensionA);
            extensions.Add <IMockExtensionTypeB>(m_extensionB);
            extensions.Add <IMockExtensionTypeC>(m_extensionC);

            IMockExtensionTypeA extensionA = extensions.Get <IMockExtensionTypeA>();

            Assert.AreSame(m_extensionA, extensionA);

            IMockExtensionTypeB extensionB = extensions.Get <IMockExtensionTypeB>();

            Assert.AreSame(m_extensionB, extensionB);

            IMockExtensionTypeC extensionC = extensions.Get <IMockExtensionTypeC>();

            Assert.AreSame(m_extensionC, extensionC);

            extensions.Add <IMockExtensionTypeB>(m_extensionD);

            IMockExtensionTypeB extensionD = extensions.Get <IMockExtensionTypeB>();

            Assert.AreSame(m_extensionD, extensionD);

            m_mockery.VerifyAllExpectationsHaveBeenMet();
        }
Ejemplo n.º 3
0
        public void AddAndGetWithGenerics()
        {
            Expect.Once.On(m_extensionA).Method("Attach");
            Expect.Once.On(m_extensionB).Method("Attach");

            ModuleExtensionCollection extensions = new ModuleExtensionCollection();

            extensions.Add <IMockExtensionTypeA>(m_extensionA);
            extensions.Add <IMockExtensionTypeB>(m_extensionB);
            extensions.Add <IMockExtensionTypeC>(m_extensionC);

            IMockExtensionTypeA extensionA = extensions.Get <IMockExtensionTypeA>();

            Assert.AreSame(m_extensionA, extensionA);

            IMockExtensionTypeB extensionB = extensions.Get <IMockExtensionTypeB>();

            Assert.AreSame(m_extensionB, extensionB);

            IMockExtensionTypeC extensionC = extensions.Get <IMockExtensionTypeC>();

            Assert.AreSame(m_extensionC, extensionC);

            IMockExtensionTypeD extensionD = extensions.Get <IMockExtensionTypeD>();

            Assert.IsNull(extensionD);

            m_mockery.VerifyAllExpectationsHaveBeenMet();
        }
        public void AddAndRemove()
        {
            Expect.Once.On(m_extensionA).Method("Attach");
            Expect.Once.On(m_extensionB).Method("Attach");
            Expect.Once.On(m_extensionA).Method("Detach");
            Expect.Once.On(m_extensionB).Method("Detach");

            ModuleExtensionCollection extensions = new ModuleExtensionCollection();
            extensions.Add(typeof(IMockExtensionTypeA), m_extensionA);
            extensions.Add(typeof(IMockExtensionTypeB), m_extensionB);
            extensions.Add(typeof(IMockExtensionTypeC), m_extensionC);

            object extension = extensions[typeof(IMockExtensionTypeA)];
            Assert.AreSame(m_extensionA, extension);
            extension = extensions[typeof(IMockExtensionTypeB)];
            Assert.AreSame(m_extensionB, extension);
            extension = extensions[typeof(IMockExtensionTypeC)];
            Assert.AreSame(m_extensionC, extension);
            
            extensions.Remove(typeof(IMockExtensionTypeA));
            extensions.Remove(typeof(IMockExtensionTypeB));
            extensions.Remove(typeof(IMockExtensionTypeC));

            m_mockery.VerifyAllExpectationsHaveBeenMet();
        }
        public void OverrideAnInstalledExtension()
        {
            Expect.Once.On(m_extensionA).Method("Attach");
            Expect.Once.On(m_extensionB).Method("Attach");
            Expect.Once.On(m_extensionB).Method("Detach");
            Expect.Once.On(m_extensionD).Method("Attach");

            ModuleExtensionCollection extensions = new ModuleExtensionCollection();
            extensions.Add<IMockExtensionTypeA>(m_extensionA);
            extensions.Add<IMockExtensionTypeB>(m_extensionB);
            extensions.Add<IMockExtensionTypeC>(m_extensionC);

            IMockExtensionTypeA extensionA = extensions.Get<IMockExtensionTypeA>();
            Assert.AreSame(m_extensionA, extensionA);

            IMockExtensionTypeB extensionB = extensions.Get<IMockExtensionTypeB>();
            Assert.AreSame(m_extensionB, extensionB);

            IMockExtensionTypeC extensionC = extensions.Get<IMockExtensionTypeC>();
            Assert.AreSame(m_extensionC, extensionC);

            extensions.Add<IMockExtensionTypeB>(m_extensionD);

            IMockExtensionTypeB extensionD = extensions.Get<IMockExtensionTypeB>();
            Assert.AreSame(m_extensionD, extensionD);

            m_mockery.VerifyAllExpectationsHaveBeenMet();
        }
        public void AddAndGetWithGenerics()
        {
            Expect.Once.On(m_extensionA).Method("Attach");
            Expect.Once.On(m_extensionB).Method("Attach");

            ModuleExtensionCollection extensions = new ModuleExtensionCollection();
            extensions.Add<IMockExtensionTypeA>(m_extensionA);
            extensions.Add<IMockExtensionTypeB>(m_extensionB);
            extensions.Add<IMockExtensionTypeC>(m_extensionC);

            IMockExtensionTypeA extensionA = extensions.Get<IMockExtensionTypeA>();
            Assert.AreSame(m_extensionA, extensionA);

            IMockExtensionTypeB extensionB = extensions.Get<IMockExtensionTypeB>();
            Assert.AreSame(m_extensionB, extensionB);

            IMockExtensionTypeC extensionC = extensions.Get<IMockExtensionTypeC>();
            Assert.AreSame(m_extensionC, extensionC);

            IMockExtensionTypeD extensionD = extensions.Get<IMockExtensionTypeD>();
            Assert.IsNull(extensionD);

            m_mockery.VerifyAllExpectationsHaveBeenMet();
        }