public void ValidationContext_Exposes_Services_Through_Callbacks_In_Parent_Container() { MyServiceContainer container = new MyServiceContainer(); container.AddService(typeof(MyTestService), new System.ComponentModel.Design.ServiceCreatorCallback((c, t) => { return(new MyTestService()); })); ValidationContext context = new ValidationContext(this, container, null); Assert.IsInstanceOfType(context.GetService(typeof(MyTestService)), typeof(MyTestService)); }
public void ValidationContext_Can_Accept_Container_And_Return_Service_From_GetService() { MyServiceContainer container = new MyServiceContainer(); MyTestService service = new MyTestService(); container.AddService(service.GetType(), service); ValidationContext context = new ValidationContext(this, container, null); Assert.AreSame(service, context.GetService(service.GetType())); }
public void ValidationContext_Can_Remove_Service_From_Parent_Container_Implicitly() { MyServiceContainer container = new MyServiceContainer(); container.AddService(typeof(MyTestService), new MyTestService()); ValidationContext context = new ValidationContext(this, container, null); Assert.IsInstanceOfType(context.GetService(typeof(MyTestService)), typeof(MyTestService)); context.ServiceContainer.RemoveService(typeof(MyTestService)); // Implicit promotion Assert.IsNull(context.GetService(typeof(MyTestService))); }
public void ValidationContext_Remove_Service_Can_Not_Affect_Parent() { MyServiceContainer container = new MyServiceContainer(); container.AddService(typeof(MyTestService), new MyTestService()); ValidationContext context = new ValidationContext(this, container, null); Assert.IsInstanceOfType(context.GetService(typeof(MyTestService)), typeof(MyTestService)); context.ServiceContainer.RemoveService(typeof(MyTestService), false); Assert.IsInstanceOfType(context.GetService(typeof(MyTestService)), typeof(MyTestService)); }
public void ValidationContext_Exposes_Services_Through_Callbacks_In_Parent_Container() { MyServiceContainer container = new MyServiceContainer(); container.AddService(typeof(MyTestService), new System.ComponentModel.Design.ServiceCreatorCallback((c, t) => { return new MyTestService(); })); ValidationContext context = new ValidationContext(this, container, null); Assert.IsInstanceOfType(context.GetService(typeof(MyTestService)), typeof(MyTestService)); }