public void RegisterByNullKey() { var child = new TestSupportServices(); var service = new TestService1(); child.ServiceContainer.RegisterService(null, service); Assert.AreEqual(service, child.ServiceContainer.GetService <IService1>()); }
public void GetServiceByKey_PreferParent() { var parent = new TestSupportServices(); var child = new TestSupportServices(); var service2 = new TestService2(); child.ServiceContainer.RegisterService("key", service2); child.ParentViewModel = parent; Assert.AreEqual(service2, child.ServiceContainer.GetService <IService2>("key", ServiceSearchMode.PreferParents)); }
public void T711283() { var defaultServiceContainer = new DefaultServiceContainer2(); defaultServiceContainer.Resources.Add("testService", null); ServiceContainer.Default = defaultServiceContainer; var vm = new TestSupportServices(); vm.GetService <IMessageBoxService>(); }
IDocument IDocumentManagerService.CreateDocument(string documentType, object viewModel, object parameter, object parentViewModel) { TestDocument doc = new TestDocument(documentType, viewModel, parameter, parentViewModel); ViewHelper.CreateAndInitializeView(doc, string.Empty, viewModel, parameter, parentViewModel); var vm = new TestSupportServices(); vm.ParentViewModel = parentViewModel; DocumentUIServiceBase.SetTitleBinding(doc, TestDocument.TitleProperty, doc); vm.Parameter = parameter; doc.Content = vm; docs.Add(doc); return doc; }
public void YieldToParentTest4() { var child = new TestSupportServices(); var service2Local = new TestService2(); child.ServiceContainer.RegisterService("key", service2Local, true); Assert.AreEqual(service2Local, child.ServiceContainer.GetService <IService2>("key", ServiceSearchMode.LocalOnly)); Assert.AreEqual(service2Local, child.ServiceContainer.GetService <IService2>("key", ServiceSearchMode.PreferParents)); Assert.AreEqual(service2Local, child.ServiceContainer.GetService <IService2>("key", ServiceSearchMode.PreferLocal)); }
public void B235125_GetServiceFromSecondParent() { var parent1 = new TestSupportServices(); var parent2 = new TestSupportServices(); var child = new TestSupportServices(); var service1 = new TestService1(); var service2 = new TestService1(); parent1.ServiceContainer.RegisterService(service1); parent2.ServiceContainer.RegisterService(service2); child.ParentViewModel = parent1; parent1.ParentViewModel = parent2; Assert.AreEqual(service1, child.ServiceContainer.GetService<IService1>()); Assert.AreEqual(service2, child.ServiceContainer.GetService<IService1>(ServiceSearchMode.PreferParents)); }
public void GetServiceFromParentByKey_InvalidParent() { var child = new TestSupportServices(); var service2 = new TestService2(); child.ServiceContainer.RegisterService("key", service2); Assert.AreEqual(service2, child.ServiceContainer.GetService <IService2>("key")); Assert.AreEqual(null, child.ServiceContainer.GetService <IService1>("key2")); child.ParentViewModel = child; Assert.AreEqual(service2, child.ServiceContainer.GetService <IService2>("key")); Assert.AreEqual(null, child.ServiceContainer.GetService <IService1>("key2")); }
IDocument IDocumentManagerService.CreateDocument(string documentType, object viewModel, object parameter, object parentViewModel) { TestDocument doc = new TestDocument(documentType, viewModel, parameter, parentViewModel); ViewHelper.CreateAndInitializeView(doc, string.Empty, viewModel, parameter, parentViewModel); var vm = new TestSupportServices(); vm.ParentViewModel = parentViewModel; DocumentUIServiceBase.SetTitleBinding(doc, TestDocument.TitleProperty, doc); vm.Parameter = parameter; doc.Content = vm; docs.Add(doc); return(doc); }
public void B235125_GetServiceFromSecondParentByKey() { var parent1 = new TestSupportServices(); var parent2 = new TestSupportServices(); var child = new TestSupportServices(); var service1 = new TestService1(); var service2 = new TestService1(); parent1.ServiceContainer.RegisterService("key", service1); parent2.ServiceContainer.RegisterService("key", service2); child.ParentViewModel = parent1; parent1.ParentViewModel = parent2; Assert.AreEqual(service1, child.ServiceContainer.GetService <IService1>("key")); Assert.AreEqual(service2, child.ServiceContainer.GetService <IService1>("key", ServiceSearchMode.PreferParents)); }
public void YieldToParentTest2() { var parent = new TestSupportServices(); var child = new TestSupportServices(); var service2 = new TestService2(); parent.ServiceContainer.RegisterService(service2); child.ParentViewModel = parent; var service2Local = new TestService2(); child.ServiceContainer.RegisterService(service2Local, true); Assert.AreEqual(service2, child.ServiceContainer.GetService <IService2>(ServiceSearchMode.PreferParents)); Assert.AreEqual(service2Local, child.ServiceContainer.GetService <IService2>(ServiceSearchMode.LocalOnly)); Assert.AreEqual(service2, child.ServiceContainer.GetService <IService2>(ServiceSearchMode.PreferLocal)); }
public void ContainersLoopTest() { var child = new TestSupportServices(); var parent = new TestSupportServices(); child.ParentViewModel = parent; parent.ParentViewModel = child; var service1 = new TestService1(); child.ServiceContainer.RegisterService(service1, true); AssertHelper.AssertThrows <Exception>(() => { child.ServiceContainer.GetService <IService1>(); }, e => { Assert.AreEqual("A ServiceContainer should not be a direct or indirect parent for itself.", e.Message); }); }
public void Clear() { var parent = new TestSupportServices(); var child = new TestSupportServices(); var service2 = new TestService2(); child.ServiceContainer.RegisterService(service2); Assert.AreEqual(service2, child.ServiceContainer.GetService <IService2>()); child.ServiceContainer.Clear(); Assert.AreEqual(null, child.ServiceContainer.GetService <IService2>()); child.ServiceContainer.RegisterService("key", service2); child.ServiceContainer.Clear(); Assert.AreEqual(null, child.ServiceContainer.GetService <IService2>()); Assert.AreEqual(null, child.ServiceContainer.GetService <IService2>("key")); }
public void RegisterServiceWithoutNameTwice() { var viewModel = new TestSupportServices(); viewModel.ServiceContainer.RegisterService(new TestService1()); var service1_2 = new TestService1_2(); viewModel.ServiceContainer.RegisterService(service1_2); Assert.AreEqual(service1_2, viewModel.ServiceContainer.GetService <IService1>()); Assert.AreEqual(service1_2, viewModel.ServiceContainer.GetService <IService2>()); var service2 = new TestService2(); viewModel.ServiceContainer.RegisterService(service2); Assert.AreEqual(service1_2, viewModel.ServiceContainer.GetService <IService1>()); Assert.AreEqual(service2, viewModel.ServiceContainer.GetService <IService2>()); }
public void GetLastParent() { var root = new TestSupportServices(); var parent = new TestSupportServices(); var child = new TestSupportServices(); parent.ParentViewModel = root; child.ParentViewModel = parent; var rootSrv = new TestService1(); var parentSrv = new TestService1(); var childSrv = new TestService1(); root.ServiceContainer.RegisterService(rootSrv); parent.ServiceContainer.RegisterService(parentSrv); child.ServiceContainer.RegisterService(childSrv); Assert.AreEqual(rootSrv, child.ServiceContainer.GetService <IService1>(ServiceSearchMode.PreferParents)); }
public void GetServiceFromParent() { var parent = new TestSupportServices(); var child = new TestSupportServices(); var service1 = new TestService1(); child.ServiceContainer.RegisterService(service1); Assert.AreEqual(service1, child.ServiceContainer.GetService<IService1>()); var service2 = new TestService2(); parent.ServiceContainer.RegisterService(service2); Assert.AreEqual(null, child.ServiceContainer.GetService<IService2>()); child.ParentViewModel = parent; Assert.AreEqual(service2, child.ServiceContainer.GetService<IService2>()); Assert.AreEqual(null, child.ServiceContainer.GetService<IService2>(ServiceSearchMode.LocalOnly)); var service2Local = new TestService2(); child.ServiceContainer.RegisterService(service2Local); Assert.AreEqual(service2Local, child.ServiceContainer.GetService<IService2>(ServiceSearchMode.LocalOnly)); Assert.AreEqual(service2, child.ServiceContainer.GetService<IService2>(ServiceSearchMode.PreferParents)); }
public void GetServiceFromParentByKey() { var parent = new TestSupportServices(); var child = new TestSupportServices(); var service2 = new TestService2(); parent.ServiceContainer.RegisterService("key", service2); Assert.AreEqual(null, child.ServiceContainer.GetService <IService2>("key")); child.ParentViewModel = parent; Assert.AreEqual(service2, child.ServiceContainer.GetService <IService2>("key")); Assert.AreEqual(null, child.ServiceContainer.GetService <IService2>("key", ServiceSearchMode.LocalOnly)); var service2Local = new TestService2(); child.ServiceContainer.RegisterService("key", service2Local); Assert.AreEqual(service2Local, child.ServiceContainer.GetService <IService2>("key", ServiceSearchMode.LocalOnly)); Assert.AreEqual(service2, child.ServiceContainer.GetService <IService2>("key", ServiceSearchMode.PreferParents)); Assert.AreEqual(service2Local, child.ServiceContainer.GetService <IService2>("key", ServiceSearchMode.PreferLocal)); }
public void GetApplicationService() { var defaultServiceContainer = new DefaultServiceContainer2(); var service2InApp = new TestService2(); defaultServiceContainer.Resources.Add("testService2", service2InApp); var service11 = new TestService1(); var service12 = new TestService1(); defaultServiceContainer.Resources.Add("testService11", service11); defaultServiceContainer.Resources.Add("testService12", service12); ServiceContainer.Default = defaultServiceContainer; var parent = new TestSupportServices(); var child = new TestSupportServices(); var service2 = new TestService2(); child.ServiceContainer.RegisterService(service2); child.ParentViewModel = parent; Assert.AreEqual(service2, child.ServiceContainer.GetService <IService2>(ServiceSearchMode.PreferParents)); Assert.AreEqual(service2, child.ServiceContainer.GetService <IService2>()); Assert.IsNotNull(child.ServiceContainer.GetService <IService1>()); Assert.AreEqual(service11, child.ServiceContainer.GetService <IService1>("testService11")); }
public void GetServiceFromParent_InvalidParent() { var child = new TestSupportServices(); var service2 = new TestService2(); child.ServiceContainer.RegisterService(service2); Assert.AreEqual(service2, child.ServiceContainer.GetService <IService2>()); Assert.AreEqual(null, child.ServiceContainer.GetService <IService1>()); child.ParentViewModel = child; Assert.AreEqual(service2, child.ServiceContainer.GetService <IService2>()); Assert.AreEqual(null, child.ServiceContainer.GetService <IService1>()); var service1 = new TestService1(); ServiceContainer.Default.RegisterService(service1); try { Assert.AreEqual(service1, child.ServiceContainer.GetService <IService1>()); } finally { ServiceContainer.Default.Clear(); } Assert.AreEqual(null, child.ServiceContainer.GetService <IService1>()); }
public void GetServiceByKey_PreferParent() { var parent = new TestSupportServices(); var child = new TestSupportServices(); var service2 = new TestService2(); child.ServiceContainer.RegisterService("key", service2); child.ParentViewModel = parent; Assert.AreEqual(service2, child.ServiceContainer.GetService<IService2>("key", ServiceSearchMode.PreferParents)); }
public void GetServiceFromParent_InvalidParent() { var child = new TestSupportServices(); var service2 = new TestService2(); child.ServiceContainer.RegisterService(service2); Assert.AreEqual(service2, child.ServiceContainer.GetService<IService2>()); Assert.AreEqual(null, child.ServiceContainer.GetService<IService1>()); child.ParentViewModel = child; Assert.AreEqual(service2, child.ServiceContainer.GetService<IService2>()); Assert.AreEqual(null, child.ServiceContainer.GetService<IService1>()); var service1 = new TestService1(); ServiceContainer.Default.RegisterService(service1); try { Assert.AreEqual(service1, child.ServiceContainer.GetService<IService1>()); } finally { ServiceContainer.Default.Clear(); } Assert.AreEqual(null, child.ServiceContainer.GetService<IService1>()); }
public void RegisterNullByKey() { var child = new TestSupportServices(); child.ServiceContainer.RegisterService("key", null); }
public void GetServiecByNullKey() { var child = new TestSupportServices(); child.ServiceContainer.GetService<IService1>(null); }
public void RegisterByNullKey() { var child = new TestSupportServices(); var service = new TestService1(); child.ServiceContainer.RegisterService(null, service); Assert.AreEqual(service, child.ServiceContainer.GetService<IService1>()); }
public void Clear() { var parent = new TestSupportServices(); var child = new TestSupportServices(); var service2 = new TestService2(); child.ServiceContainer.RegisterService(service2); Assert.AreEqual(service2, child.ServiceContainer.GetService<IService2>()); child.ServiceContainer.Clear(); Assert.AreEqual(null, child.ServiceContainer.GetService<IService2>()); child.ServiceContainer.RegisterService("key", service2); child.ServiceContainer.Clear(); Assert.AreEqual(null, child.ServiceContainer.GetService<IService2>()); Assert.AreEqual(null, child.ServiceContainer.GetService<IService2>("key")); }
public void RegisterServiceWithoutNameTwice() { var viewModel = new TestSupportServices(); viewModel.ServiceContainer.RegisterService(new TestService1()); var service1_2 = new TestService1_2(); viewModel.ServiceContainer.RegisterService(service1_2); Assert.AreEqual(service1_2, viewModel.ServiceContainer.GetService<IService1>()); Assert.AreEqual(service1_2, viewModel.ServiceContainer.GetService<IService2>()); var service2 = new TestService2(); viewModel.ServiceContainer.RegisterService(service2); Assert.AreEqual(service1_2, viewModel.ServiceContainer.GetService<IService1>()); Assert.AreEqual(service2, viewModel.ServiceContainer.GetService<IService2>()); }
public void GetServiceFromParentByKey_InvalidParent() { var child = new TestSupportServices(); var service2 = new TestService2(); child.ServiceContainer.RegisterService("key", service2); Assert.AreEqual(service2, child.ServiceContainer.GetService<IService2>("key")); Assert.AreEqual(null, child.ServiceContainer.GetService<IService1>("key2")); child.ParentViewModel = child; Assert.AreEqual(service2, child.ServiceContainer.GetService<IService2>("key")); Assert.AreEqual(null, child.ServiceContainer.GetService<IService1>("key2")); }