Example #1
0
        public void RequestingMultipleInstancesAfterRegisteringProvidedInstanceReturnsSameInstance()
        {
            var t = typeof(ITestInterfaceBase);
            var instance = new TestClass(42);

            // Register as singleton
            instance.RegisterAsProvidedInstance(t);

            // Grab a few instances
            var a = t.ProvideInstanceOf();
            var b = t.ProvideInstanceOf();

            // Check that the items are the same instance
            instance.ShouldBeSameAs(a);
            instance.ShouldBeSameAs(b);
            a.ShouldBeSameAs(b);
        }