public void ExpectThreeTimesFasterObjectInitialiingWithHelperInitializerClass() { Stopwatch timer = new Stopwatch(); timer.Start(); const int TestsCount = 1000000; for (int i = 0; i < TestsCount; i++) { Activator.CreateInstance <Film>(); Activator.CreateInstance <Planet>(); } timer.Stop(); var activatorTimer = timer.Elapsed; timer.Restart(); for (int i = 0; i < TestsCount; i++) { HelperInitializer <Film> .Instance(); HelperInitializer <Planet> .Instance(); } timer.Stop(); var helperTimer = timer.Elapsed; long expectedTimesDifference = 3; Assert.IsTrue( expectedTimesDifference <= (activatorTimer.Ticks / helperTimer.Ticks), "Difference : " + (activatorTimer.Ticks / helperTimer.Ticks)); }
/// <summary> /// Initializes a new instance of the <see cref="Repository{T}"/> class. /// </summary> /// <param name="dataService">The data service to get entities.</param> /// <param name="url">The URL for consuming. It will be used in the service. Examples: http://mySite.com, http://mySite.com/ .</param> /// <example>Data service getting data from JSON document, other database etc.</example> public ExtendedRepository(IDataService dataService, string url) { this.entity = HelperInitializer <T> .Instance(); this.dataService = dataService; if (!url.EndsWith(this.urlEndCharacter)) { url += this.urlEndCharacter; } this.urlData = url; }