public void PerfTest() { var type = typeof(TestView); var defFactory = new DefaultViewActivator(); var fastFactory = new FastViewActivator(); var activator = defFactory.Register(type); var fastActivator = fastFactory.Register(type); var iterations = 1000000; Stopwatch sw = new Stopwatch(); sw.Start(); for (int i = 0; i < iterations; i++) { var view = activator.Activate(type); } sw.Stop(); Console.WriteLine("Default took: {0}ms", sw.Elapsed.TotalMilliseconds); sw.Reset(); sw.Start(); for (int i = 0; i < iterations; i++) { var view = fastActivator.Activate(type); } sw.Stop(); Console.WriteLine("Fast took: {0}ms", sw.Elapsed.TotalMilliseconds); }
public void CreateViewInstance() { var type = typeof(TestView); var factory = new DefaultViewActivator(); var activator = factory.Register(type); var view = activator.Activate(type); Assert.IsNotNull(view); Assert.IsAssignableFrom(typeof(TestView), view); }