private bool IsUserScopedApi(ITypeInfo controller) { var route = controller.GetAttributes(TypeInfo.From <RouteAttribute>()).SingleOrDefault(); var template = (string)route?.AttributeData["Template"]; return(template?.StartsWith("v1/user/{userId}") ?? false); }
private Test TryGetTypeTest(ITypeInfo type, Test assemblyTest) { Test typeTest; if (!typeTests.TryGetValue(type, out typeTest)) { try { foreach (var attribute in type.GetAttributes(null, false)) { if (attribute is ConcordionTestAttribute) { typeTest = CreateTypeTest(new ConcordionTypeInfoAdapter(type)); break; } } } catch (Exception ex) { TestModel.AddAnnotation(new Annotation(AnnotationType.Error, type, "An exception was thrown while exploring an concordion test type.", ex)); } if (typeTest != null) { assemblyTest.AddChild(typeTest); typeTests.Add(type, typeTest); } } return(typeTest); }
private string AppendRoutePrefix(string routeTemplate, ITypeInfo controllerType) { var routeAttribute = controllerType.GetAttributes(TypeInfo.From <RouteAttribute>()).SingleOrDefault(); var fullRoute = (routeAttribute == null ? "" : routeAttribute.AttributeData["Template"] + "/") + routeTemplate; if (IsUserScopedApi(controllerType)) { return(fullRoute.Substring("v1/user/{userId}/".Length)); } return(fullRoute.Substring("v1/".Length)); }
private Test TryGetTypeTest(ITypeInfo type, Test assemblyTest) { Test typeTest; if (!typeTests.TryGetValue(type, out typeTest)) { try { foreach (var attribute in type.GetAttributes(null, false)) { if (attribute is ConcordionTestAttribute) { typeTest = CreateTypeTest(new ConcordionTypeInfoAdapter(type)); break; } } } catch (Exception ex) { TestModel.AddAnnotation(new Annotation(AnnotationType.Error, type, "An exception was thrown while exploring an concordion test type.", ex)); } if (typeTest != null) { assemblyTest.AddChild(typeTest); typeTests.Add(type, typeTest); } } return typeTest; }