public void Resolve_AsInterfaceAndInstance_ShouldSame() { IResolveAsSingleton resolveAsSingleton = new ResolveAsSingleton(); var resolveDemoTestResult = ObjectIntanceTestResult.Create(resolveAsSingleton.Resolve <ResolveDemo, IResolveDemo>(), resolveAsSingleton.Resolve <ResolveDemo>()); resolveDemoTestResult.ShouldSame(); }
public void Resolve_SingleThread_Singleton_ShouldSame() { IResolveAsSingleton resolveAsSingleton = new ResolveAsSingleton(); var resolveDemoTestResult = ObjectIntanceTestResult.Create(resolveAsSingleton.Resolve <ResolveDemo>(), resolveAsSingleton.Resolve <ResolveDemo>()); resolveDemoTestResult.ShouldSame(); }
public void Resolve_MultiThread_Singleton_ShouldSame() { IResolveAsSingleton resolveAsSingleton = new ResolveAsSingleton(); ObjectIntanceTestResult.RunTestInMultiTasks(multiThreadTaskCount , resolveAsSingleton.Resolve <ResolveDemo> , resolveAsSingleton.Resolve <ResolveDemo> , true); }
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); }
public static ObjectIntanceTestResult Create(Object object1, object object2) { var resolveDemoTestResult = new ObjectIntanceTestResult { CreateInThreadId = Thread.CurrentThread.ManagedThreadId, Object1 = object1, Object2 = object2 }; return(resolveDemoTestResult); }
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(); }
//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(); }