PageRenderTime 45ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/V2.2/trunk/Quickstarts/UI Composition/ViewDiscovery/Desktop/UIComposition.Modules.Employee.Tests/Mocks/MockUnityContainer.cs

#
C# | 341 lines | 259 code | 66 blank | 16 comment | 11 complexity | 192a9e77537748c8f34fb6ca427188b7 MD5 | raw file
  1. //===================================================================================
  2. // Microsoft patterns & practices
  3. // Composite Application Guidance for Windows Presentation Foundation and Silverlight
  4. //===================================================================================
  5. // Copyright (c) Microsoft Corporation. All rights reserved.
  6. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
  7. // OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
  8. // LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  9. // FITNESS FOR A PARTICULAR PURPOSE.
  10. //===================================================================================
  11. // The example companies, organizations, products, domain names,
  12. // e-mail addresses, logos, people, places, and events depicted
  13. // herein are fictitious. No association with any real company,
  14. // organization, product, domain name, email address, logo, person,
  15. // places, or events is intended or should be inferred.
  16. //===================================================================================
  17. using System;
  18. using System.Collections.Generic;
  19. using Microsoft.Practices.Unity;
  20. using UIComposition.Modules.Project;
  21. namespace UIComposition.Modules.Employee.Tests.Mocks
  22. {
  23. public class MockUnityContainer : IUnityContainer
  24. {
  25. public Dictionary<Type, Type> Types = new Dictionary<Type, Type>();
  26. private Dictionary<Type, object> Instances = new Dictionary<Type, object>();
  27. public IUnityContainer RegisterType<TFrom, TTo>() where TTo : TFrom
  28. {
  29. return RegisterType<TFrom, TTo>(new InjectionMember[0]);
  30. }
  31. public IUnityContainer RegisterType<TFrom, TTo>(params InjectionMember[] injectionMembers) where TTo : TFrom
  32. {
  33. Types.Add(typeof(TFrom), typeof(TTo));
  34. return this;
  35. }
  36. public IUnityContainer RegisterType<TFrom, TTo>(LifetimeManager lifetimeManager, params InjectionMember[] injectionMembers) where TTo : TFrom
  37. {
  38. return RegisterType<TFrom, TTo>(new InjectionMember[0]);
  39. }
  40. public IUnityContainer RegisterInstance<TInterface>(TInterface instance)
  41. {
  42. Instances.Add(typeof(TInterface), instance);
  43. return this;
  44. }
  45. public T Resolve<T>()
  46. {
  47. if (typeof(T) == typeof(EmployeesPresenter))
  48. {
  49. object presenter = new EmployeesPresenter(new MockEmployeesView()
  50. , new MockEmployeesController());
  51. return (T)presenter;
  52. }
  53. else if (typeof(T) == typeof(IEmployeesDetailsPresenter))
  54. {
  55. object presenter = new MockEmployeesDetailsPresenter();
  56. return (T)presenter;
  57. }
  58. else if (typeof(T) == typeof(IProjectsListPresenter))
  59. {
  60. object presenter = new MockProjectsListPresenter();
  61. return (T)presenter;
  62. }
  63. else if (typeof(T) == typeof(EmployeesListPresenter))
  64. {
  65. object presenter = new EmployeesListPresenter(new MockEmployeesListView(), new MockEmployeesService());
  66. return (T)presenter;
  67. }
  68. return default(T);
  69. }
  70. #region IUnityContainer Members
  71. public IUnityContainer AddExtension(UnityContainerExtension extension)
  72. {
  73. throw new NotImplementedException();
  74. }
  75. public IUnityContainer AddNewExtension<TExtension>() where TExtension : UnityContainerExtension, new()
  76. {
  77. throw new NotImplementedException();
  78. }
  79. public object BuildUp(Type t, object existing, string name)
  80. {
  81. throw new NotImplementedException();
  82. }
  83. public object BuildUp(Type t, object existing)
  84. {
  85. throw new NotImplementedException();
  86. }
  87. public T BuildUp<T>(T existing, string name)
  88. {
  89. throw new NotImplementedException();
  90. }
  91. public T BuildUp<T>(T existing)
  92. {
  93. throw new NotImplementedException();
  94. }
  95. public object Configure(Type configurationInterface)
  96. {
  97. throw new NotImplementedException();
  98. }
  99. public TConfigurator Configure<TConfigurator>() where TConfigurator : IUnityContainerExtensionConfigurator
  100. {
  101. throw new NotImplementedException();
  102. }
  103. public IUnityContainer CreateChildContainer()
  104. {
  105. throw new NotImplementedException();
  106. }
  107. public IUnityContainer Parent
  108. {
  109. get { throw new NotImplementedException(); }
  110. }
  111. public IUnityContainer RegisterInstance(Type t, string name, object instance, LifetimeManager lifetime)
  112. {
  113. throw new NotImplementedException();
  114. }
  115. public IUnityContainer RegisterInstance(Type t, string name, object instance)
  116. {
  117. throw new NotImplementedException();
  118. }
  119. public IUnityContainer RegisterInstance(Type t, object instance, LifetimeManager lifetimeManager)
  120. {
  121. throw new NotImplementedException();
  122. }
  123. public IUnityContainer RegisterInstance(Type t, object instance)
  124. {
  125. throw new NotImplementedException();
  126. }
  127. public IUnityContainer RegisterInstance<TInterface>(string name, TInterface instance, LifetimeManager lifetimeManager)
  128. {
  129. throw new NotImplementedException();
  130. }
  131. public IUnityContainer RegisterInstance<TInterface>(string name, TInterface instance)
  132. {
  133. throw new NotImplementedException();
  134. }
  135. public IUnityContainer RegisterInstance<TInterface>(TInterface instance, LifetimeManager lifetimeManager)
  136. {
  137. throw new NotImplementedException();
  138. }
  139. public IUnityContainer RegisterType(Type from, Type to, string name, LifetimeManager lifetimeManager)
  140. {
  141. throw new NotImplementedException();
  142. }
  143. public IUnityContainer RegisterType(Type t, string name, LifetimeManager lifetimeManager)
  144. {
  145. throw new NotImplementedException();
  146. }
  147. public IUnityContainer RegisterType(Type t, LifetimeManager lifetimeManager)
  148. {
  149. throw new NotImplementedException();
  150. }
  151. public IUnityContainer RegisterType(Type from, Type to, LifetimeManager lifetimeManager)
  152. {
  153. throw new NotImplementedException();
  154. }
  155. public IUnityContainer RegisterType(Type from, Type to, string name)
  156. {
  157. throw new NotImplementedException();
  158. }
  159. public IUnityContainer RegisterType(Type from, Type to)
  160. {
  161. throw new NotImplementedException();
  162. }
  163. public IUnityContainer RegisterType<T>(string name, LifetimeManager lifetimeManager)
  164. {
  165. throw new NotImplementedException();
  166. }
  167. public IUnityContainer RegisterType<T>(LifetimeManager lifetimeManager)
  168. {
  169. throw new NotImplementedException();
  170. }
  171. public IUnityContainer RegisterType<TFrom, TTo>(string name, LifetimeManager lifetimeManager) where TTo : TFrom
  172. {
  173. throw new NotImplementedException();
  174. }
  175. public IUnityContainer RegisterType<TFrom, TTo>(string name) where TTo : TFrom
  176. {
  177. throw new NotImplementedException();
  178. }
  179. public IUnityContainer RegisterType<TFrom, TTo>(LifetimeManager lifetimeManager) where TTo : TFrom
  180. {
  181. throw new NotImplementedException();
  182. }
  183. public IUnityContainer RemoveAllExtensions()
  184. {
  185. throw new NotImplementedException();
  186. }
  187. public object Resolve(Type t, string name)
  188. {
  189. throw new NotImplementedException();
  190. }
  191. public object Resolve(Type t)
  192. {
  193. throw new NotImplementedException();
  194. }
  195. public T Resolve<T>(string name)
  196. {
  197. throw new NotImplementedException();
  198. }
  199. public IEnumerable<object> ResolveAll(Type t)
  200. {
  201. throw new NotImplementedException();
  202. }
  203. public IEnumerable<T> ResolveAll<T>()
  204. {
  205. throw new NotImplementedException();
  206. }
  207. public void Teardown(object o)
  208. {
  209. throw new NotImplementedException();
  210. }
  211. #endregion
  212. #region IDisposable Members
  213. public void Dispose()
  214. {
  215. throw new NotImplementedException();
  216. }
  217. #endregion
  218. public IUnityContainer RegisterType(Type from, Type to, string name, LifetimeManager lifetimeManager, params InjectionMember[] injectionMembers)
  219. {
  220. throw new NotImplementedException();
  221. }
  222. public IUnityContainer RegisterType(Type t, string name, LifetimeManager lifetimeManager, params InjectionMember[] injectionMembers)
  223. {
  224. throw new NotImplementedException();
  225. }
  226. public IUnityContainer RegisterType(Type t, string name, params InjectionMember[] injectionMembers)
  227. {
  228. throw new NotImplementedException();
  229. }
  230. public IUnityContainer RegisterType(Type t, LifetimeManager lifetimeManager, params InjectionMember[] injectionMembers)
  231. {
  232. throw new NotImplementedException();
  233. }
  234. public IUnityContainer RegisterType(Type from, Type to, LifetimeManager lifetimeManager, params InjectionMember[] injectionMembers)
  235. {
  236. throw new NotImplementedException();
  237. }
  238. public IUnityContainer RegisterType(Type from, Type to, string name, params InjectionMember[] injectionMembers)
  239. {
  240. throw new NotImplementedException();
  241. }
  242. public IUnityContainer RegisterType(Type from, Type to, params InjectionMember[] injectionMembers)
  243. {
  244. throw new NotImplementedException();
  245. }
  246. public IUnityContainer RegisterType(Type t, params InjectionMember[] injectionMembers)
  247. {
  248. throw new NotImplementedException();
  249. }
  250. public IUnityContainer RegisterType<T>(string name, LifetimeManager lifetimeManager, params InjectionMember[] injectionMembers)
  251. {
  252. throw new NotImplementedException();
  253. }
  254. public IUnityContainer RegisterType<T>(string name, params InjectionMember[] injectionMembers)
  255. {
  256. throw new NotImplementedException();
  257. }
  258. public IUnityContainer RegisterType<T>(LifetimeManager lifetimeManager, params InjectionMember[] injectionMembers)
  259. {
  260. throw new NotImplementedException();
  261. }
  262. public IUnityContainer RegisterType<TFrom, TTo>(string name, LifetimeManager lifetimeManager, params InjectionMember[] injectionMembers) where TTo : TFrom
  263. {
  264. throw new NotImplementedException();
  265. }
  266. public IUnityContainer RegisterType<TFrom, TTo>(string name, params InjectionMember[] injectionMembers) where TTo : TFrom
  267. {
  268. throw new NotImplementedException();
  269. }
  270. public IUnityContainer RegisterType<T>(params InjectionMember[] injectionMembers)
  271. {
  272. throw new NotImplementedException();
  273. }
  274. }
  275. }