public void CreateDocument(RouteConfig routeConfig, string path) { DataSet data = new DataSet(); data.Tables.Add(routeConfig.Operations.ToDataTable()); data.Tables.Add(routeConfig.RouteResources.ToDataTable()); data.Tables.Add(routeConfig.Routes.ToDataTable()); data.Tables.Add(routeConfig.ServiceConfigurationRoutes.ToDataTable()); data.Tables.Add(routeConfig.RouteParameters.ToDataTable()); data.ExportToExcel(path); }
public RouteDOMEngine RUN() { if (_RouteEngineArgs.Data != null && _RouteEngineArgs.Data.Any()) { _RouteConfig = new RouteConfig(); _RouteConfig.MetaData = _RouteEngineArgs.Data; _RouteEngineArgs.Data.ForEach(m => { var newOperation = new Operation(_RouteEngineArgs.Assembly, m.Operation); _RouteConfig.Operations.Add(newOperation); var newRouteResource = _RouteConfig.RouteResources.Find(r => r.Uri.Equals(m.Uri)); if (newRouteResource == null) { newRouteResource = new RouteResource(_RouteEngineArgs.ModelId, m.Uri); _RouteConfig.RouteResources.Add(newRouteResource); } var newRoute = new Route(newOperation.OperationId, newRouteResource.RouteResourceId, _RouteEngineArgs.Queue, m.Type, m.Description, m.Operation, m.Name); _RouteConfig.Routes.Add(newRoute); _RouteConfig.ServiceConfigurationRoutes.Add(new ServiceConfigurationRoute(_RouteEngineArgs.ServiceConfigurationId, newRoute.RouteId)); _RouteConfig.RouteParameters.AddRange(new RouteParameter().GetRouteParameters(newRoute.RouteId, m.Uri)); var appResource = new ApplicationResource(); _RouteConfig.ApplicationResources.Add(appResource); _RouteConfig.ApplicationResourceRoutes.Add(new ApplicationResourceRoute(appResource.ApplicationResourceId, newRoute.RouteId)); var appResourceAccess = new ApplicationResourceAccess(appResource.ApplicationResourceId); _RouteConfig.ApplicationResourceAccess.Add(appResourceAccess); _RouteConfig.RouteClassifications.Add(new RouteClassification(newRoute.RouteId, _RouteEngineArgs.RouteGroupClassificationId)); _RouteEngineArgs.RoleIds.ForEach(roleId => { _RouteConfig.RoleApplicationAccess.Add(new RoleApplicationAccess(roleId, appResourceAccess.ApplicationResourceAccessId)); }); }); } return this; }
public RouteDOMEngine(RouteEngineArgs args) { _RouteConfig = new RouteConfig(); _RouteEngineArgs = args; }
public RouteDOMEngine() { _RouteConfig = new RouteConfig(); }
public string CreateMochaDocument(RouteConfig _RouteConfig, string target) { StringBuilder content = new StringBuilder(); content.Append(String.Format("var testWrapper = require('../../node_modules/TestWrapper/TestWrapper');{0}var should = require('../../node_modules/should');{0}var assert = require('../../node_modules/assert');{0}var objectComparison = require('../../node_modules/objectcompare');{0}", Environment.NewLine)); content.Append(String.Format("{1}var new{0}Id=null;{1}", target, Environment.NewLine)); content.Append(String.Format("var organizationId = '99E62AD8-D585-48CE-9D97-A315BEA2760C'; //Baxter physician group {0}", Environment.NewLine)); content.Append(String.Format("var new{0}={{ {1}", target, Environment.NewLine)); var data = new InformationSchema(target); data.MetaData.ForEach(m => { if (!m.Name.Equals(target + "Id")) content.Append(String.Format("'{0}':'{1}',{2}", m.Name, GetDefaultDataValue(m), Environment.NewLine)); }); content.Append(String.Format("}};{0}", Environment.NewLine)); string eFunctionName = String.Format("evaluateCreate{0}Response", target); content.Append(string.Format( @"//Custom response evaluator for {0} POST test function evaluateCreate{0}Response(actual, expected, testCompletionCallback) {{ var keysToIgnore = ['{0}Id', 'SessionKey', 'Success']; var transportMessage = JSON.parse(actual); var expectedMessage = JSON.parse(expected); var actual{0} = testWrapper.ElementsToIgnore(JSON.stringify(transportMessage.response), keysToIgnore); var expected{0} = testWrapper.ElementsToIgnore(JSON.stringify(expectedMessage), keysToIgnore); try {{ if (transportMessage.response != undefined && transportMessage.response[0] != undefined && transportMessage.response[0].{0}Id != undefined) {{ new{0}Id = transportMessage.response[0].{0}Id; }} testCompletionCallback(); }} catch (e) {{ }} }}", target)); //var typesOrder = new List<String> { "POST", "PUT", "GET", "DELETE" }; //typesOrder.ForEach(type => //{.Where(m => m.Type.ToUpper() == type) _RouteConfig.MetaData.OrderBy(m => m.OrdinalPosition).ToList().ForEach(r => { if (r.MochaScript == null) { var rx = _RouteConfig.MetaData.Where(mx => mx.Type == r.Type).FirstOrDefault(); r.MochaScript = rx.MochaScript ?? string.Empty; } content.Append(r.MochaScript.Replace("$SYS_DESCR$", r.Description) .Replace("$SYS_URI$", r.Uri) .Replace("$SYS_NAME$", r.Name) .Replace("$SYS_TARGET$", target) .Replace("$SYS_NEW_OBJECT$", "new" + target) .Replace("$SYS_EVAL_FUNC_NAME$", eFunctionName) .Replace("$SYS_EXEC_URI$", formatURI(r.Uri))); content.Append(Environment.NewLine); }); //}); return content.ToString().FormatWhiteSpaces(); }