PageRenderTime 53ms CodeModel.GetById 10ms app.highlight 36ms RepoModel.GetById 1ms app.codeStats 1ms

/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//===================================================================================
 17using System;
 18using System.Collections.Generic;
 19using Microsoft.Practices.Unity;
 20using UIComposition.Modules.Project;
 21
 22namespace UIComposition.Modules.Employee.Tests.Mocks
 23{
 24    public class MockUnityContainer : IUnityContainer
 25    {
 26        public Dictionary<Type, Type> Types = new Dictionary<Type, Type>();
 27        private Dictionary<Type, object> Instances = new Dictionary<Type, object>();
 28
 29        public IUnityContainer RegisterType<TFrom, TTo>() where TTo : TFrom
 30        {
 31            return RegisterType<TFrom, TTo>(new InjectionMember[0]);
 32        }
 33
 34        public IUnityContainer RegisterType<TFrom, TTo>(params InjectionMember[] injectionMembers) where TTo : TFrom
 35        {
 36            Types.Add(typeof(TFrom), typeof(TTo));
 37            return this;
 38        }
 39
 40        public IUnityContainer RegisterType<TFrom, TTo>(LifetimeManager lifetimeManager, params InjectionMember[] injectionMembers) where TTo : TFrom
 41        {
 42            return RegisterType<TFrom, TTo>(new InjectionMember[0]);
 43        }
 44
 45        public IUnityContainer RegisterInstance<TInterface>(TInterface instance)
 46        {
 47            Instances.Add(typeof(TInterface), instance);
 48            return this;
 49        }
 50
 51        public T Resolve<T>()
 52        {
 53
 54            if (typeof(T) == typeof(EmployeesPresenter))
 55            {
 56                object presenter = new EmployeesPresenter(new MockEmployeesView()
 57                                            , new MockEmployeesController());
 58
 59                return (T)presenter;
 60            }
 61            else if (typeof(T) == typeof(IEmployeesDetailsPresenter))
 62            {
 63                object presenter = new MockEmployeesDetailsPresenter();
 64                return (T)presenter;
 65            }
 66            else if (typeof(T) == typeof(IProjectsListPresenter))
 67            {
 68                object presenter = new MockProjectsListPresenter();
 69
 70                return (T)presenter;
 71            }
 72            else if (typeof(T) == typeof(EmployeesListPresenter))
 73            {
 74                object presenter = new EmployeesListPresenter(new MockEmployeesListView(), new MockEmployeesService());
 75
 76                return (T)presenter;
 77            }
 78
 79            return default(T);
 80        }
 81
 82        #region IUnityContainer Members
 83
 84        public IUnityContainer AddExtension(UnityContainerExtension extension)
 85        {
 86            throw new NotImplementedException();
 87        }
 88
 89        public IUnityContainer AddNewExtension<TExtension>() where TExtension : UnityContainerExtension, new()
 90        {
 91            throw new NotImplementedException();
 92        }
 93
 94        public object BuildUp(Type t, object existing, string name)
 95        {
 96            throw new NotImplementedException();
 97        }
 98
 99        public object BuildUp(Type t, object existing)
100        {
101            throw new NotImplementedException();
102        }
103
104        public T BuildUp<T>(T existing, string name)
105        {
106            throw new NotImplementedException();
107        }
108
109        public T BuildUp<T>(T existing)
110        {
111            throw new NotImplementedException();
112        }
113
114        public object Configure(Type configurationInterface)
115        {
116            throw new NotImplementedException();
117        }
118
119        public TConfigurator Configure<TConfigurator>() where TConfigurator : IUnityContainerExtensionConfigurator
120        {
121            throw new NotImplementedException();
122        }
123
124        public IUnityContainer CreateChildContainer()
125        {
126            throw new NotImplementedException();
127        }
128
129        public IUnityContainer Parent
130        {
131            get { throw new NotImplementedException(); }
132        }
133
134        public IUnityContainer RegisterInstance(Type t, string name, object instance, LifetimeManager lifetime)
135        {
136            throw new NotImplementedException();
137        }
138
139        public IUnityContainer RegisterInstance(Type t, string name, object instance)
140        {
141            throw new NotImplementedException();
142        }
143
144        public IUnityContainer RegisterInstance(Type t, object instance, LifetimeManager lifetimeManager)
145        {
146            throw new NotImplementedException();
147        }
148
149        public IUnityContainer RegisterInstance(Type t, object instance)
150        {
151            throw new NotImplementedException();
152        }
153
154        public IUnityContainer RegisterInstance<TInterface>(string name, TInterface instance, LifetimeManager lifetimeManager)
155        {
156            throw new NotImplementedException();
157        }
158
159        public IUnityContainer RegisterInstance<TInterface>(string name, TInterface instance)
160        {
161            throw new NotImplementedException();
162        }
163
164        public IUnityContainer RegisterInstance<TInterface>(TInterface instance, LifetimeManager lifetimeManager)
165        {
166            throw new NotImplementedException();
167        }
168
169        public IUnityContainer RegisterType(Type from, Type to, string name, LifetimeManager lifetimeManager)
170        {
171            throw new NotImplementedException();
172        }
173
174        public IUnityContainer RegisterType(Type t, string name, LifetimeManager lifetimeManager)
175        {
176            throw new NotImplementedException();
177        }
178
179        public IUnityContainer RegisterType(Type t, LifetimeManager lifetimeManager)
180        {
181            throw new NotImplementedException();
182        }
183
184        public IUnityContainer RegisterType(Type from, Type to, LifetimeManager lifetimeManager)
185        {
186            throw new NotImplementedException();
187        }
188
189        public IUnityContainer RegisterType(Type from, Type to, string name)
190        {
191            throw new NotImplementedException();
192        }
193
194        public IUnityContainer RegisterType(Type from, Type to)
195        {
196            throw new NotImplementedException();
197        }
198
199        public IUnityContainer RegisterType<T>(string name, LifetimeManager lifetimeManager)
200        {
201            throw new NotImplementedException();
202        }
203
204        public IUnityContainer RegisterType<T>(LifetimeManager lifetimeManager)
205        {
206            throw new NotImplementedException();
207        }
208
209        public IUnityContainer RegisterType<TFrom, TTo>(string name, LifetimeManager lifetimeManager) where TTo : TFrom
210        {
211            throw new NotImplementedException();
212        }
213
214        public IUnityContainer RegisterType<TFrom, TTo>(string name) where TTo : TFrom
215        {
216            throw new NotImplementedException();
217        }
218
219        public IUnityContainer RegisterType<TFrom, TTo>(LifetimeManager lifetimeManager) where TTo : TFrom
220        {
221            throw new NotImplementedException();
222        }
223
224        public IUnityContainer RemoveAllExtensions()
225        {
226            throw new NotImplementedException();
227        }
228
229        public object Resolve(Type t, string name)
230        {
231            throw new NotImplementedException();
232        }
233
234        public object Resolve(Type t)
235        {
236            throw new NotImplementedException();
237        }
238
239        public T Resolve<T>(string name)
240        {
241            throw new NotImplementedException();
242        }
243
244        public IEnumerable<object> ResolveAll(Type t)
245        {
246            throw new NotImplementedException();
247        }
248
249        public IEnumerable<T> ResolveAll<T>()
250        {
251            throw new NotImplementedException();
252        }
253
254        public void Teardown(object o)
255        {
256            throw new NotImplementedException();
257        }
258
259        #endregion
260
261        #region IDisposable Members
262
263        public void Dispose()
264        {
265            throw new NotImplementedException();
266        }
267
268        #endregion
269
270
271        public IUnityContainer RegisterType(Type from, Type to, string name, LifetimeManager lifetimeManager, params InjectionMember[] injectionMembers)
272        {
273            throw new NotImplementedException();
274        }
275
276        public IUnityContainer RegisterType(Type t, string name, LifetimeManager lifetimeManager, params InjectionMember[] injectionMembers)
277        {
278            throw new NotImplementedException();
279        }
280
281        public IUnityContainer RegisterType(Type t, string name, params InjectionMember[] injectionMembers)
282        {
283            throw new NotImplementedException();
284        }
285
286        public IUnityContainer RegisterType(Type t, LifetimeManager lifetimeManager, params InjectionMember[] injectionMembers)
287        {
288            throw new NotImplementedException();
289        }
290
291        public IUnityContainer RegisterType(Type from, Type to, LifetimeManager lifetimeManager, params InjectionMember[] injectionMembers)
292        {
293            throw new NotImplementedException();
294        }
295
296        public IUnityContainer RegisterType(Type from, Type to, string name, params InjectionMember[] injectionMembers)
297        {
298            throw new NotImplementedException();
299        }
300
301        public IUnityContainer RegisterType(Type from, Type to, params InjectionMember[] injectionMembers)
302        {
303            throw new NotImplementedException();
304        }
305
306        public IUnityContainer RegisterType(Type t, params InjectionMember[] injectionMembers)
307        {
308            throw new NotImplementedException();
309        }
310
311        public IUnityContainer RegisterType<T>(string name, LifetimeManager lifetimeManager, params InjectionMember[] injectionMembers)
312        {
313            throw new NotImplementedException();
314        }
315
316        public IUnityContainer RegisterType<T>(string name, params InjectionMember[] injectionMembers)
317        {
318            throw new NotImplementedException();
319        }
320
321        public IUnityContainer RegisterType<T>(LifetimeManager lifetimeManager, params InjectionMember[] injectionMembers)
322        {
323            throw new NotImplementedException();
324        }
325
326        public IUnityContainer RegisterType<TFrom, TTo>(string name, LifetimeManager lifetimeManager, params InjectionMember[] injectionMembers) where TTo : TFrom
327        {
328            throw new NotImplementedException();
329        }
330
331        public IUnityContainer RegisterType<TFrom, TTo>(string name, params InjectionMember[] injectionMembers) where TTo : TFrom
332        {
333            throw new NotImplementedException();
334        }
335
336        public IUnityContainer RegisterType<T>(params InjectionMember[] injectionMembers)
337        {
338            throw new NotImplementedException();
339        }
340    }
341}