public static void InitializeLinkGenerators(RouteValuesPreparer routeValuesPreparer, HttpRequestProviderFake httpRequestProviderFake) { var properties = typeof(Website).GetProperties(BindingFlags.Static | BindingFlags.Public); var linkProperties = from p in properties where typeof(SiteAreaBase).IsAssignableFrom(p.PropertyType) select p; foreach (var linkProperty in linkProperties) { // Find available constructors for target property var constructor = (from c in linkProperty.PropertyType.GetConstructors() orderby c.GetParameters().Length select new { Method = c, ParameterCount = c.GetParameters().Length }) .First(); // Invoke shortest constructor with null values var instance = constructor.Method.Invoke(new object[constructor.ParameterCount]) as SiteAreaBase; instance.RouteValuesPreparer = routeValuesPreparer; instance.HttpRequestProvider = httpRequestProviderFake; linkProperty.SetValue(null, instance, null); } }
protected virtual void InitializeStaffLinkGenerator(RouteValuesPreparer routeValuesPreparer, HttpRequestProviderFake httpRequestProviderFake) { Staff = new Staff(fakeClassroomViewProvider, new StubCodeIdProvider(), new StubLocalEducationAgencyContextProvider(), null) { RouteValuesPreparer = routeValuesPreparer, HttpRequestProvider = httpRequestProviderFake }; }
protected virtual void InitializeGeneralLinkGenerator(RouteValuesPreparer routeValuesPreparer, HttpRequestProviderFake httpRequestProviderFake) { General = new General { RouteValuesPreparer = routeValuesPreparer, HttpRequestProvider = httpRequestProviderFake }; }
protected override void InitializeRouteGenerationForTesting(string baseUrl) { RouteTestingExtensions.BaseUrl = baseUrl; var baseUri = new Uri(baseUrl); // Initialize link generators var routeValuesPreparer = new RouteValuesPreparer(new UITestRouteValueProvider().ToArray()); var httpRequestProviderFake = new HttpRequestProviderFake(baseUri.Scheme, baseUri.Host, baseUri.LocalPath); Website.InitializeLinkGenerators(routeValuesPreparer, httpRequestProviderFake); //InitializeLinkGenerators(routeValuesPreparer, httpRequestProviderFake); }
protected virtual void InitializeSearchLinkGenerator(RouteValuesPreparer routeValuesPreparer, HttpRequestProviderFake httpRequestProviderFake) { Search = new Search(); Search.RouteValuesPreparer = routeValuesPreparer; Search.HttpRequestProvider = httpRequestProviderFake; }
protected virtual void InitializeSchoolLinkGenerator(RouteValuesPreparer routeValuesPreparer, HttpRequestProviderFake httpRequestProviderFake) { School = new School(null); School.RouteValuesPreparer = routeValuesPreparer; School.HttpRequestProvider = httpRequestProviderFake; }
protected virtual void InitializeLocalEducationAgencyLinkGenerator(RouteValuesPreparer routeValuesPreparer, HttpRequestProviderFake httpRequestProviderFake) { LocalEducationAgency = new LocalEducationAgency(new LocalEducationAgencyRandomImageLinkProvider(new NullImageLinkProvider())); LocalEducationAgency.RouteValuesPreparer = routeValuesPreparer; LocalEducationAgency.HttpRequestProvider = httpRequestProviderFake; }
protected virtual void InitializeApplicationLinkGenerator(RouteValuesPreparer routeValuesPreparer, HttpRequestProviderFake httpRequestProviderFake) { Application = new ApplicationLinks(); Application.RouteValuesPreparer = routeValuesPreparer; Application.HttpRequestProvider = httpRequestProviderFake; }
protected virtual void InitializeErrorLinkGenerator(RouteValuesPreparer routeValuesPreparer, HttpRequestProviderFake httpRequestProviderFake) { Error = new Error(); Error.RouteValuesPreparer = routeValuesPreparer; Error.HttpRequestProvider = httpRequestProviderFake; }
protected override void ExecuteTest() { var preparer = new RouteValuesPreparer(new[] { firstValueProviderMock.Object, secondValueProviderMock.Object }); preparer.PrepareRouteValues("TestRoute", suppliedRouteValues); }
protected override void ExecuteTest() { var preparer = new RouteValuesPreparer(new[] { leaValueProviderMock.Object, schoolValueProviderMock.Object, metricProviderMock.Object }); preparer.PrepareRouteValues("TestRoute", suppliedRouteValues); }