コード例 #1
0
        public void TestSetGetMethodStub()
        {
            StubContainer <IFoo> container = new StubContainer <IFoo>();
            BasicDelegate        del       = () => { };

            container.SetMethodStub(del, 1, true);

            Assert.AreEqual(del, container.GetMethodStub <BasicDelegate>("Foo"));
        }
コード例 #2
0
        public void TestThatSetStubOverridesExistingStub()
        {
            StubContainer <IFoo> container = new StubContainer <IFoo>();
            BasicDelegate        del       = () => { };
            BasicDelegate        del2      = () => { throw new Exception(); };

            container.SetMethodStub(del, Times.Forever, true);
            container.SetMethodStub(del2, Times.Forever, true);

            Assert.AreEqual(del2, container.GetMethodStub <BasicDelegate>("Foo"));
        }
コード例 #3
0
        public void TestThatGenericDelegatesWithDifferentGenericTypeDontConflict()
        {
            StubContainer <IFoo>     container = new StubContainer <IFoo>();
            GenericDelegate <int>    del       = () => 1;
            GenericDelegate <string> del2      = () => "text";

            container.SetMethodStub(del, Times.Forever, true);
            container.SetMethodStub(del2, Times.Forever, true);

            Assert.AreEqual(del, container.GetMethodStub <GenericDelegate <int> >("Foo1"));
            Assert.AreEqual(del2, container.GetMethodStub <GenericDelegate <string> >("Foo2"));
        }
コード例 #4
0
        public void TestThatDelegatesWithTheSameSignatureDontConflict()
        {
            StubContainer <IFoo> container = new StubContainer <IFoo>();
            BasicDelegate        del       = () => { };
            BasicDelegate2       del2      = () => { throw new Exception(); };

            container.SetMethodStub(del, Times.Forever, true);
            container.SetMethodStub(del2, Times.Forever, true);

            Assert.AreEqual(del, container.GetMethodStub <BasicDelegate>("Foo1"));
            Assert.AreEqual(del2, container.GetMethodStub <BasicDelegate2>("Foo2"));
        }
コード例 #5
0
        public void ShouldRegisterTypesWithContainer()
        {
            // Arrange
            var container           = new StubContainer();
            var asmDiscovery        = new StubAssemblyDiscovery(Assembly.GetExecutingAssembly().FullName);
            var attributedDiscovery = new AttributedTypeDiscoveryService(asmDiscovery);
            var bootstrapper        = new AbtBootstrapper(container, attributedDiscovery);

            // Act
            bootstrapper.Initialize();

            // Assert
            Assert.That(container.TypeRegistrations.ContainsKey(typeof(IExportedType)));
            Assert.That(container.SingletonRegistrations.ContainsKey(typeof(IExportedSingleton)));
            Assert.That(container.SingletonRegistrations.ContainsKey(typeof(ISomeConfig)));
            Assert.That(container.SingletonRegistrations.ContainsKey(typeof(ISomeOtherConfig)));
        }
コード例 #6
0
        public void TestGetMethodStubWhenNotSetup()
        {
            StubContainer <IFoo> container = new StubContainer <IFoo>();

            container.GetMethodStub <BasicDelegate>("Foo");
        }