private void PostProcessTProxiedObject(ProcessedObjectChecker test) { AppDomain domain = null; try { domain = AppDomain.CreateDomain("Spring"); object foo = domain.CreateInstanceAndUnwrap(GetType().Assembly.FullName, typeof(MockContextAwareObject).FullName); MockApplicationContext ctx = new MockApplicationContext(); ApplicationContextAwareProcessor processor = new ApplicationContextAwareProcessor(ctx); MockContextAwareObject afterFoo = (MockContextAwareObject)processor.PostProcessBeforeInitialization(foo, "MyContextAwareObject"); test(afterFoo); } finally { try { AppDomain.Unload(domain); } catch (Exception ex) { Console.Write("Error unloading AppDomain used during testing : " + ex); } } }
public void AfterInitReturnsSameInstanceAsWasPassedIn() { MockApplicationContext ctx = new MockApplicationContext(); ApplicationContextAwareProcessor processor = new ApplicationContextAwareProcessor(ctx); object obj = new object(); object obj1 = processor.PostProcessAfterInitialization(obj, "MyContextAwareObject"); Assert.AreEqual(obj, obj1, "Objects don't equal"); }
public void DoNotAttachContextForRegularObject() { MockApplicationContext ctx = new MockApplicationContext(); ApplicationContextAwareProcessor processor = new ApplicationContextAwareProcessor(ctx); object obj = new object(); object obj1 = processor.PostProcessBeforeInitialization(obj, "MyContextAwareObject"); Assert.AreEqual(obj, obj1, "Objects don't equal"); }
public void AttachContext() { MockApplicationContext ctx = new MockApplicationContext(); ApplicationContextAwareProcessor processor = new ApplicationContextAwareProcessor(ctx); MockContextAwareObject obj = new MockContextAwareObject(); Assert.IsNull(obj.GetApplicationContext(), "Context Does Not Equal"); MockContextAwareObject obj2 = (MockContextAwareObject)processor.PostProcessBeforeInitialization(obj, "MyContextAwareObject"); Assert.AreEqual(ctx, obj2.GetApplicationContext(), "Context Does Not Equal"); }