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

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

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

            ObjectIntanceTestResult.RunTestInMultiTasks(multiThreadTaskCount
                                                        , resolveAsSingleton.Resolve <ResolveDemo>
                                                        , resolveAsSingleton.Resolve <ResolveDemo>
                                                        , true);
        }
Exemple #4
0
        public static ObjectIntanceTestResult CreateWithFunc(Func <Object> createFunc1, Func <Object> createFunc2)
        {
            var resolveDemoTestResult = new ObjectIntanceTestResult
            {
                CreateInThreadId = Thread.CurrentThread.ManagedThreadId,
                Object1          = createFunc1.Invoke(),
                Object2          = createFunc2.Invoke()
            };

            return(resolveDemoTestResult);
        }
Exemple #5
0
        public static ObjectIntanceTestResult Create(Object object1, object object2)
        {
            var resolveDemoTestResult = new ObjectIntanceTestResult
            {
                CreateInThreadId = Thread.CurrentThread.ManagedThreadId,
                Object1          = object1,
                Object2          = object2
            };

            return(resolveDemoTestResult);
        }
Exemple #6
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();
        }
Exemple #7
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();
        }