예제 #1
0
        public void Resolve_AsInterfaceAndInstance_ShouldSame()
        {
            IResolveAsSingleton resolveAsSingleton = new ResolveAsSingleton();
            var resolveDemoTestResult = ObjectIntanceTestResult.Create(resolveAsSingleton.Resolve <ResolveDemo, IResolveDemo>(), resolveAsSingleton.Resolve <ResolveDemo>());

            resolveDemoTestResult.ShouldSame();
        }
예제 #2
0
        public void Resolve_SingleThread_Singleton_ShouldSame()
        {
            IResolveAsSingleton resolveAsSingleton = new ResolveAsSingleton();
            var resolveDemoTestResult = ObjectIntanceTestResult.Create(resolveAsSingleton.Resolve <ResolveDemo>(), resolveAsSingleton.Resolve <ResolveDemo>());

            resolveDemoTestResult.ShouldSame();
        }
예제 #3
0
        public void Resolve_MultiThread_Singleton_ShouldSame()
        {
            IResolveAsSingleton resolveAsSingleton = new ResolveAsSingleton();

            ObjectIntanceTestResult.RunTestInMultiTasks(multiThreadTaskCount
                                                        , resolveAsSingleton.Resolve <ResolveDemo>
                                                        , resolveAsSingleton.Resolve <ResolveDemo>
                                                        , true);
        }
예제 #4
0
        public void Resolve_Should_Return_Default_First()
        {
            IResolveAsSingleton resolveAsSingleton = new ResolveAsSingleton();
            var resolveDemo  = resolveAsSingleton.Resolve <ResolveDemo>();
            var resolveDemo2 = resolveAsSingleton.Resolve <ResolveDemo>();

            resolveDemo.Desc.ShouldNull();
            resolveDemo2.Desc.ShouldNull();
            var resolveDemoTestResult = ObjectIntanceTestResult.Create(resolveDemo, resolveDemo2);

            resolveDemoTestResult.ShouldSame();
        }
예제 #5
0
        //ingore singleton test problems
        //[TestMethod]
        public void Factory_Replace_ShouldOK()
        {
            var mockNinjectReslover = new MockNinjectReslover();

            ResolveAsSingleton.Factory = () => mockNinjectReslover;

            var resolveDemo  = ResolveAsSingleton.Resolve <ResolveDemo, IResolveDemo>();
            var resolveDemo2 = ResolveAsSingleton.Resolve <ResolveDemo, IResolveDemo>();
            var resolveDemo3 = ResolveAsSingleton.Resolve <ResolveDemo>();
            var resolveDemo4 = ResolveAsSingleton.Resolve <ResolveDemo>();

            ObjectIntanceTestResult.Create(resolveDemo, resolveDemo2).ShouldSame();
            ObjectIntanceTestResult.Create(resolveDemo, resolveDemo3).ShouldSame();
            ObjectIntanceTestResult.Create(resolveDemo, resolveDemo4).ShouldSame();

            mockNinjectReslover.InvokedResolve.ShouldTrue();
            mockNinjectReslover.InvokedResolveAsInterface.ShouldTrue();
        }