private bool Parse(Scanner scanner) { var parser = new Parser(scanner); var result = parser.Parse(); Errors = scanner.Errors; ErrorLocations = scanner.ErrorLocations; SchemaInstance = parser.Model; return result; }
public void SchemaCreation() { var model = new SchemaModel {Schema = {Name = "Sample Schema", Identification = "SAMPLE_TEST"}}; var definedType = model.New((DefinedType t) => { t.Name = "Identifier"; t.Domain = model.PredefinedSimpleTypes.StringType; }); var entity = model.New((EntityDefinition e) => { e.Name = "Model"; }); entity.AddAttribute(model.New((ExplicitAttribute a) => { a.Name = "Name"; a.Domain = definedType; })); entity.AddAttribute(model.New((ExplicitAttribute a) => { a.Name = "Description"; a.Domain = model.PredefinedSimpleTypes.StringType; })); }
private static string Schema(SchemaModel model) { return(string.Join(", ", model.Get <SchemaDefinition>().Select(s => s.Name))); }
public virtual void Visit(SchemaModel model) { }
int IEntityOperator.Delete(SchemaModel.Column keyColumn, SchemaModel.Table table, params int[] ids) { if (ids.Length <= 0) return 0; var deleteSql = "DELETE FROM {0} WHERE [{1}] IN ({2})"; var tableName = _sqlBuilder.GetTableName(table); deleteSql = string.Format(deleteSql, tableName, keyColumn.Name, string.Join(",", ids)); return _sqlExecutor.ExecuteNonQuery(deleteSql, new Dictionary<string, object>()); }
public override string GetTableName(SchemaModel.Table table) { var tableName = string.Empty; if (!string.IsNullOrWhiteSpace(table.DataBase)) { tableName = string.Format("[{0}].DBO.", table.DataBase); } tableName = string.Format("{0}[{1}]", tableName, table.Name); return tableName; }
public static ExampleOperationViewModel CreateDefaultExampleOperationViewModel(SchemaModel schemaModel, Pt position) { var exampleOperationModel = new ExampleOperationModel(schemaModel); var exampleOperationViewModel = new ExampleOperationViewModel(exampleOperationModel); exampleOperationViewModel.Position = position; addAttachmentViewModels(exampleOperationViewModel); createBottomExampleMenu(exampleOperationViewModel); createRightExampleMenu(exampleOperationViewModel); createLeftExampleMenu(exampleOperationViewModel); return(exampleOperationViewModel); }
/// <summary>Initialize event adapter service for config snapshot. </summary> /// <param name="eventAdapterService">is events adapter</param> /// <param name="configSnapshot">is the config snapshot</param> internal static void Init(EventAdapterService eventAdapterService, ConfigurationInformation configSnapshot) { // Extract legacy event type definitions for each event type name, if supplied. // // We supply this information as setup information to the event adapter service // to allow discovery of superclasses and interfaces during event type construction for bean events, // such that superclasses and interfaces can use the legacy type definitions. IDictionary <String, ConfigurationEventTypeLegacy> classLegacyInfo = new Dictionary <String, ConfigurationEventTypeLegacy>(); foreach (KeyValuePair <String, String> entry in configSnapshot.EventTypeNames) { String typeName = entry.Key; String className = entry.Value; ConfigurationEventTypeLegacy legacyDef = configSnapshot.EventTypesLegacy.Get(typeName); if (legacyDef != null) { classLegacyInfo.Put(className, legacyDef); } } eventAdapterService.TypeLegacyConfigs = classLegacyInfo; eventAdapterService.DefaultPropertyResolutionStyle = configSnapshot.EngineDefaults.EventMetaConfig.ClassPropertyResolutionStyle; eventAdapterService.DefaultAccessorStyle = configSnapshot.EngineDefaults.EventMetaConfig.DefaultAccessorStyle; foreach (String typeNamespace in configSnapshot.EventTypeAutoNamePackages) { eventAdapterService.AddAutoNamePackage(typeNamespace); } // Add from the configuration the event class names IDictionary <String, String> typeNames = configSnapshot.EventTypeNames; foreach (KeyValuePair <String, String> entry in typeNames) { // Add class try { String typeName = entry.Key; eventAdapterService.AddBeanType(typeName, entry.Value, false, true, true, true); } catch (EventAdapterException ex) { throw new ConfigurationException("Error configuring engine: " + ex.Message, ex); } } // Add from the configuration the XML DOM names and type def IDictionary <String, ConfigurationEventTypeXMLDOM> xmlDOMNames = configSnapshot.EventTypesXMLDOM; foreach (KeyValuePair <String, ConfigurationEventTypeXMLDOM> entry in xmlDOMNames) { SchemaModel schemaModel = null; if ((entry.Value.SchemaResource != null) || (entry.Value.SchemaText != null)) { try { schemaModel = XSDSchemaMapper.LoadAndMap(entry.Value.SchemaResource, entry.Value.SchemaText); } catch (Exception ex) { throw new ConfigurationException(ex.Message, ex); } } // Add XML DOM type try { eventAdapterService.AddXMLDOMType(entry.Key, entry.Value, schemaModel, true); } catch (EventAdapterException ex) { throw new ConfigurationException("Error configuring engine: " + ex.Message, ex); } } // Add maps in dependency order such that supertypes are added before subtypes ICollection <String> dependentMapOrder; try { var typesReferences = ToTypesReferences(configSnapshot.MapTypeConfigurations); dependentMapOrder = GraphUtil.GetTopDownOrder(typesReferences); } catch (GraphCircularDependencyException e) { throw new ConfigurationException("Error configuring engine, dependency graph between map type names is circular: " + e.Message, e); } IDictionary <String, Properties> mapNames = configSnapshot.EventTypesMapEvents; IDictionary <String, IDictionary <String, Object> > nestableMapNames = configSnapshot.EventTypesNestableMapEvents; dependentMapOrder.AddAll(mapNames.Keys); dependentMapOrder.AddAll(nestableMapNames.Keys); try { foreach (String mapName in dependentMapOrder) { ConfigurationEventTypeMap mapConfig = configSnapshot.MapTypeConfigurations.Get(mapName); Properties propertiesUnnested = mapNames.Get(mapName); if (propertiesUnnested != null) { IDictionary <String, Object> propertyTypes = CreatePropertyTypes(propertiesUnnested); IDictionary <String, Object> propertyTypesCompiled = EventTypeUtility.CompileMapTypeProperties(propertyTypes, eventAdapterService); eventAdapterService.AddNestableMapType(mapName, propertyTypesCompiled, mapConfig, true, true, true, false, false); } IDictionary <String, Object> propertiesNestable = nestableMapNames.Get(mapName); if (propertiesNestable != null) { IDictionary <String, Object> propertiesNestableCompiled = EventTypeUtility.CompileMapTypeProperties(propertiesNestable, eventAdapterService); eventAdapterService.AddNestableMapType(mapName, propertiesNestableCompiled, mapConfig, true, true, true, false, false); } } } catch (EventAdapterException ex) { throw new ConfigurationException("Error configuring engine: " + ex.Message, ex); } // Add object-array in dependency order such that supertypes are added before subtypes ICollection <string> dependentObjectArrayOrder; try { var typesReferences = ToTypesReferences(configSnapshot.ObjectArrayTypeConfigurations); dependentObjectArrayOrder = GraphUtil.GetTopDownOrder(typesReferences); } catch (GraphCircularDependencyException e) { throw new ConfigurationException( "Error configuring engine, dependency graph between object array type names is circular: " + e.Message, e); } var nestableObjectArrayNames = configSnapshot.EventTypesNestableObjectArrayEvents; dependentObjectArrayOrder.AddAll(nestableObjectArrayNames.Keys); try { foreach (string objectArrayName in dependentObjectArrayOrder) { var objectArrayConfig = configSnapshot.ObjectArrayTypeConfigurations.Get(objectArrayName); var propertyTypes = nestableObjectArrayNames.Get(objectArrayName); propertyTypes = ResolveClassesForStringPropertyTypes(propertyTypes); var propertyTypesCompiled = EventTypeUtility.CompileMapTypeProperties(propertyTypes, eventAdapterService); eventAdapterService.AddNestableObjectArrayType(objectArrayName, propertyTypesCompiled, objectArrayConfig, true, true, true, false, false, false, null); } } catch (EventAdapterException ex) { throw new ConfigurationException("Error configuring engine: " + ex.Message, ex); } // Add plug-in event representations var plugInReps = configSnapshot.PlugInEventRepresentation; foreach (var entry in plugInReps) { String className = entry.Value.EventRepresentationTypeName; Type eventRepClass; try { eventRepClass = TypeHelper.ResolveType(className); } catch (TypeLoadException ex) { throw new ConfigurationException("Failed to load plug-in event representation class '" + className + "'", ex); } Object pluginEventRepObj; try { pluginEventRepObj = Activator.CreateInstance(eventRepClass); } catch (TypeInstantiationException ex) { throw new ConfigurationException("Failed to instantiate plug-in event representation class '" + className + "' via default constructor", ex); } catch (TargetInvocationException ex) { throw new ConfigurationException("Failed to instantiate plug-in event representation class '" + className + "' via default constructor", ex); } catch (MethodAccessException ex) { throw new ConfigurationException("Illegal access to instantiate plug-in event representation class '" + className + "' via default constructor", ex); } catch (MemberAccessException ex) { throw new ConfigurationException("Illegal access to instantiate plug-in event representation class '" + className + "' via default constructor", ex); } if (!(pluginEventRepObj is PlugInEventRepresentation)) { throw new ConfigurationException("Plug-in event representation class '" + className + "' does not implement the required interface " + typeof(PlugInEventRepresentation).FullName); } var eventRepURI = entry.Key; var pluginEventRep = (PlugInEventRepresentation)pluginEventRepObj; var initializer = entry.Value.Initializer; var context = new PlugInEventRepresentationContext(eventAdapterService, eventRepURI, initializer); try { pluginEventRep.Init(context); eventAdapterService.AddEventRepresentation(eventRepURI, pluginEventRep); } catch (Exception e) { throw new ConfigurationException("Plug-in event representation class '" + className + "' and URI '" + eventRepURI + "' did not initialize correctly : " + e.Message, e); } } // Add plug-in event type names IDictionary <String, ConfigurationPlugInEventType> plugInNames = configSnapshot.PlugInEventTypes; foreach (KeyValuePair <String, ConfigurationPlugInEventType> entry in plugInNames) { String name = entry.Key; ConfigurationPlugInEventType config = entry.Value; eventAdapterService.AddPlugInEventType(name, config.EventRepresentationResolutionURIs, config.Initializer); } }
public static IEnumerable <SchemaModel> ReadSchemas(DataContextModel owner, DBConnector database) { if (database == null) { throw new ArgumentNullException("database"); } List <SchemaModel> tables = new List <SchemaModel>(); List <Action> postColumnActions = new List <Action>(); Func <string, string, SchemaModel> Table = (schema, name) => //First look for a new table from SQL Server, then for an existing one. String.IsNullOrEmpty(name) ? null : tables.SingleOrDefault(t => t.SqlSchemaName == schema && t.SqlName == name) ?? owner.Schemas.SingleOrDefault(t => t.SqlSchemaName == schema && t.SqlName == name); using (var connection = database.OpenConnection()) { #region Read Tables using (var reader = database.ExecuteReader(TablesSql)) { while (reader.Read()) { var table = new SchemaModel(owner) { Name = (string)reader["TableName"], SqlName = (string)reader["TableName"], SqlSchemaName = reader["SchemaName"] as string }; if (Table(table.SqlSchemaName, table.SqlName) != null) { continue; //TODO: Import column } string keyName = reader["PrimaryKeyName"] as string; if (!String.IsNullOrEmpty(keyName)) { postColumnActions.Add( () => table.PrimaryKey = table.Columns.Single(c => c.SqlName == keyName) ); } tables.Add(table); } } #endregion using (var reader = database.ExecuteReader(ColumnsSql)) { while (reader.Read()) { var table = Table((string)reader["SchemaName"], (string)reader["TableName"]); if (table == null) { continue; //Skip tables without RowVersion columns } var name = (string)reader["ColumnName"]; if (table.Columns.Any(c => c.SqlName == name)) { continue; //Don't add duplicate columns to existing tables. } table.Columns.Add(new ColumnModel(table) { Name = name, SqlName = name, DataType = SqlTypes[(string)reader["DataType"]], AllowNulls = 1 == (int)reader["AllowNulls"], IsUnique = 1 == (int)reader["IsUnique"], ForeignSchema = Table(reader["ForeignSchema"] as string, reader["ForeignTable"] as string) }); } } } postColumnActions.ForEach(a => a()); return(tables); }
public StatisticalComparisonOperationModel(SchemaModel schemaModel) : base(schemaModel) { _statisticallyComparableOperationModels.CollectionChanged += _statisticallyComparableOperationModels_CollectionChanged; }
public StatisticalComparisonDecisionOperationModel(SchemaModel schemaModel) : base(schemaModel) { }
public IEnumerable <SchemaModel> Delete([FromBody] SchemaModel schema) { return(_repo.Delete(schema)); }
public IEnumerable <SchemaModel> Put([FromBody] SchemaModel schema) { return(_repo.Update(schema)); }
public IEnumerable <SchemaModel> Post([FromBody] SchemaModel schema) { return(_repo.Create(schema)); }
private static void Compare(SchemaModel modelA, SchemaModel modelB) { Console.WriteLine(@"Schemas to compare: {0}, {1}", modelA.FirstSchema.Source, modelB.FirstSchema.Source); var models = new [] { modelA, modelB }; var schemaComparers = new ISchemaComparer[] { new AddedEntitiesComparer(), new AddedSelectsComparer(), new AddedTypesComparer(), new AddedEnumerationsComparer(), new RemovedEntitiesComparer(), new RemovedSelectsComparer(), new RemovedTypesComparer(), new RemovedEnumerationsComparer(), new ChangedEntitiesComparer(), new ChangedSelectsComparer(), new ChangedEnumerationsComparer() }; foreach (var comparer in schemaComparers) { comparer.Compare(modelA, modelB); } var w = new StringWriter(); w.WriteLine("Number of entities:"); foreach (var model in models) { w.WriteLine("{0}: {1}", Schema(model), model.Get <EntityDefinition>().Count()); } w.WriteLine(); w.WriteLine("Number of non-abstract entities:"); foreach (var model in models) { w.WriteLine("{0}: {1}", Schema(model), model.Get <EntityDefinition>().Count(e => e.Instantiable)); } w.WriteLine(); w.WriteLine("Number of types:"); foreach (var model in models) { w.WriteLine("{0}: {1}", Schema(model), model.Get <DefinedType>().Count()); } w.WriteLine(); w.WriteLine("Number of enumerations:"); foreach (var model in models) { w.WriteLine("{0}: {1}", Schema(model), model.Get <EnumerationType>().Count()); } w.WriteLine(); w.WriteLine("Number of select types:"); foreach (var model in models) { w.WriteLine("{0}: {1}", Schema(model), model.Get <SelectType>().Count()); } w.WriteLine(); w.WriteLine("Number of global rules:"); foreach (var model in models) { w.WriteLine("{0}: {1}", Schema(model), model.Get <GlobalRule>().Count()); } w.WriteLine(); foreach (var cmp in schemaComparers) { //filter only to specified entities var results = cmp.Results.ToList();//.Where(r => EntitiesToCheck.Contains(r.OldObjectName)).ToList(); w.WriteLine("{0} ({1}):", cmp.Name, results.Count); Console.WriteLine(@"{0} ({1}):", cmp.Name, results.Count); foreach (var result in results) { w.WriteLine(result.Message); } w.WriteLine(); } var log = w.ToString(); var logName = String.Format("{0}_{1}.txt", modelA.FirstSchema.Source, modelB.FirstSchema.Source); using (var file = File.CreateText(logName)) { file.Write(log); file.Close(); } Console.WriteLine(@"Comparison saved fo file: " + Path.Combine(Environment.CurrentDirectory, logName)); Console.WriteLine(); }
public void VisitSchema(SchemaModel item) { }
private UserSchemaValidation(SchemaModel model, bool isCreate) : this() { Localize(isCreate); propgrid.SelectedObject = model; }
public static HistogramOperationViewModel CreateDefaultHistogramOperationViewModel(SchemaModel schemaModel, AttributeModel attributeModel, Pt position) { var histogramOperationModel = new HistogramOperationModel(schemaModel); var histogramOperationViewModel = new HistogramOperationViewModel(histogramOperationModel); histogramOperationViewModel.Position = position; addAttachmentViewModels(histogramOperationViewModel); // axis attachment view models createAxisMenu(histogramOperationViewModel, AttachmentOrientation.Bottom, AttributeUsage.X, new Vec(200, 50), 0, true, false); createAxisMenu(histogramOperationViewModel, AttachmentOrientation.Left, AttributeUsage.Y, new Vec(50, 200), 270, false, true); createRightHistogramMenu(histogramOperationViewModel); createTopHistogramMenu(histogramOperationViewModel); if ((attributeModel != null) && attributeModel is AttributeFieldModel) { var inputFieldModel = attributeModel as AttributeFieldModel; if (inputFieldModel.InputVisualizationType == InputVisualizationTypeConstants.ENUM) { histogramOperationModel.VisualizationType = VisualizationType.plot; var x = new AttributeTransformationModel(inputFieldModel); x.AggregateFunction = AggregateFunction.None; var value = new AttributeTransformationModel(inputFieldModel); value.AggregateFunction = AggregateFunction.Count; var y = new AttributeTransformationModel(inputFieldModel); y.AggregateFunction = AggregateFunction.Count; if (attributeModel.VisualizationHints.Contains(VisualizationHint.DefaultFlipAxis)) { histogramOperationModel.AddAttributeUsageTransformationModel(AttributeUsage.X, y); histogramOperationModel.AddAttributeUsageTransformationModel(AttributeUsage.Y, x); } else { histogramOperationModel.AddAttributeUsageTransformationModel(AttributeUsage.X, x); histogramOperationModel.AddAttributeUsageTransformationModel(AttributeUsage.Y, y); } histogramOperationModel.AddAttributeUsageTransformationModel(AttributeUsage.DefaultValue, value); } else if (inputFieldModel.InputVisualizationType == InputVisualizationTypeConstants.NUMERIC) { histogramOperationModel.VisualizationType = VisualizationType.plot; var x = new AttributeTransformationModel(inputFieldModel); x.AggregateFunction = AggregateFunction.None; var value = new AttributeTransformationModel(inputFieldModel); value.AggregateFunction = AggregateFunction.Count; var y = new AttributeTransformationModel(inputFieldModel); y.AggregateFunction = AggregateFunction.Count; if (attributeModel.VisualizationHints.Contains(VisualizationHint.DefaultFlipAxis)) { histogramOperationModel.AddAttributeUsageTransformationModel(AttributeUsage.X, y); histogramOperationModel.AddAttributeUsageTransformationModel(AttributeUsage.Y, x); } else { histogramOperationModel.AddAttributeUsageTransformationModel(AttributeUsage.X, x); histogramOperationModel.AddAttributeUsageTransformationModel(AttributeUsage.Y, y); } histogramOperationModel.AddAttributeUsageTransformationModel(AttributeUsage.DefaultValue, value); } else if (inputFieldModel.InputVisualizationType == InputVisualizationTypeConstants.GEOGRAPHY) { } else { histogramOperationModel.VisualizationType = VisualizationType.table; var x = new AttributeTransformationModel(inputFieldModel); histogramOperationModel.AddAttributeUsageTransformationModel(AttributeUsage.X, x); } } else { histogramOperationModel.VisualizationType = VisualizationType.plot; } return(histogramOperationViewModel); }
public static DialogResult Launch(SchemaModel model, bool isCreate) => new UserSchemaValidation(model, isCreate).ShowDialog(new ParentHwnd(Useful.Hwnd));
/// <summary> /// 将给定的表结构信息转换成完整表名 /// </summary> /// <param name="table"></param> /// <returns></returns> public static string GetTableName(SchemaModel.Table table) { var tableName = string.Empty; tableName = string.Format("{0}[{1}]", tableName, table.Name); return tableName; }
public OperationModel(SchemaModel schemaModel) { _schemaModel = schemaModel; _id = _nextId++; }
int IEntityOperator.UpdateValues(SchemaModel.Column keyColumn, SchemaModel.Table table, Dictionary<string, object> values) { var keyValue = values.Get(keyColumn.Name); if (keyValue == null) { throw new InvalidOperationException("字典未传入主键"); } var updateSql = "UPDATE {0} SET {1} WHERE {2}"; var tableName = _sqlBuilder.GetTableName(table); var sqlParameters = new Dictionary<string, object>(); var setts = new List<string>(); var alias = string.Empty; foreach (var key in values.Keys) { if (key == keyColumn.Name) { continue; } alias = ParserUtils.GenerateAlias(key); var set = string.Format("[{0}] = @{1}", key, alias); sqlParameters.Add(alias, values.Get(key)); setts.Add(set); } alias = ParserUtils.GenerateAlias(keyColumn.Name); var condition = string.Format("[{0}] = @{1}", keyColumn.Name, alias); sqlParameters.Add(alias, keyValue); updateSql = string.Format(updateSql, tableName, string.Join(",", setts), condition); return _sqlExecutor.ExecuteNonQuery(updateSql, sqlParameters); }
public static IEnumerable <EntityDefinitionMatch> GetMatches(SchemaModel a, SchemaModel b) { return(a.Get <EntityDefinition>().Select(entityDefinition => new EntityDefinitionMatch(entityDefinition, b))); }
private EntityDefinition TryHandleBuildingElementMatch(EntityDefinition source, SchemaModel targetSchema) { if (string.Equals(source.Name, "IfcBuildingElement", StringComparison.OrdinalIgnoreCase)) { return(targetSchema.Get <EntityDefinition>(e => string.Equals(e.Name, "IfcBuiltElement", StringComparison.OrdinalIgnoreCase)) .FirstOrDefault()); } if (string.Equals(source.Name, "IfcBuildingElementType", StringComparison.OrdinalIgnoreCase)) { return(targetSchema.Get <EntityDefinition>(e => string.Equals(e.Name, "IfcBuiltElementType", StringComparison.OrdinalIgnoreCase)) .FirstOrDefault()); } if (string.Equals(source.Name, "IfcBuiltElement", StringComparison.OrdinalIgnoreCase)) { return(targetSchema.Get <EntityDefinition>(e => string.Equals(e.Name, "IfcBuildingElement", StringComparison.OrdinalIgnoreCase)) .FirstOrDefault()); } if (string.Equals(source.Name, "IfcBuiltElementType", StringComparison.OrdinalIgnoreCase)) { return(targetSchema.Get <EntityDefinition>(e => string.Equals(e.Name, "IfcBuildingElementType", StringComparison.OrdinalIgnoreCase)) .FirstOrDefault()); } return(null); }
public void Init() { schemaModel = new SchemaModel { DataSchemaID = 1, Description = "Blah blah", Name = "Name", Status = TemplateStatus.Draft, Version = 1 }; dSchemaDraft = new DataSchema { ID = 1, Name = "Draft", CreatedBy = 1, CreatedAt = today, Status = (int)TemplateStatus.Draft }; dSchemaPublished = new DataSchema { ID = 2, Name = "Published", CreatedAt = today, CreatedBy = 1, PublishedAt = today }; dSchemaRetracted = new DataSchema { ID = 3, Name = "Retracted", CreatedAt = today, Status = (int)TemplateStatus.Retracted }; schemaFile = new SchemaFile { DataSchemaID = dSchemaDraft.ID, CreatedBy = 1, FileFormat = ".xml", ID = 1 }; consumerOrganization = new Organization { ID = 1 }; providerOrganization = new Organization { ID = 2 }; providerApplication = new Application { ID = 1, OrganizationID = providerOrganization.ID }; consumerApplication = new Application { ID = 2, OrganizationID = consumerOrganization.ID }; providerLicense = new OrganizationLicense { ID = 1, ApplicationID = providerApplication.ID }; consumerLicense = new OrganizationLicense { ID = 2, ApplicationID = consumerApplication.ID }; licenseMatch = new LicenseMatch { ID = 1, ConsumerLicenseID = consumerLicense.ID, ProviderLicenseID = providerLicense.ID }; endpoint = new ProviderEndpoint { ApplicationId = providerApplication.ID, DataSchemaID = dSchemaPublished.ID, IsActive = true }; var file = new Mock <HttpPostedFileBase>(); file.Setup(i => i.InputStream).Returns(new MemoryStream()); file.Setup(i => i.FileName).Returns("file.xml"); schemaModel.UploadFile = file.Object; var mock = new Mock <UrlHelper>(); // Setup file var fileMock = new Mock <HttpPostedFileBase>(); fileMock.Setup(x => x.FileName).Returns("file1.xml"); var context = new Mock <ControllerContext>(); context.Setup(m => m.HttpContext.Request.Files.Count).Returns(1); context.Setup(m => m.HttpContext.Request.Files[0]).Returns(fileMock.Object); context.Setup(m => m.HttpContext.Request.Url).Returns(new Uri("http://test.com")); sysAdmin = new User { ID = 1, IsActive = true, Email = "*****@*****.**", IsSysAdmin = true }; // Setup Services metaDataService = new Mock <IDataSchemaService>(); fileService = new Mock <ISchemaFileService>(); organizationService = new Mock <IOrganizationService>(); userService = new Mock <IUserService>(); notificationService = new Mock <INotificationService>(); endpointService = new Mock <IProviderEndpointService>(); applicationService = new Mock <IApplicationsService>(); configurationService = new Mock <IConfigurationService>(); organizationLicenseService = new Mock <IOrganizationLicenseService>(); userService.Setup(u => u.Get(sysAdmin.ID)).Returns(sysAdmin); configurationService.SetupProperty(p => p.ManageSchemasPageSize, 5); // Setup organization service organizationService.Setup(m => m.Get(consumerOrganization.ID)).Returns(consumerOrganization); organizationService.Setup(m => m.Get(providerOrganization.ID)).Returns(providerOrganization); // Setup application service applicationService.Setup(m => m.Get(providerApplication.ID)).Returns(providerApplication); applicationService.Setup(m => m.Get(consumerApplication.ID)).Returns(consumerApplication); // Setup endpoint service endpointService.Setup(m => m.Get(endpoint.ID)).Returns(endpoint); // Setup organization licenses organizationLicenseService.Setup(i => i.Get(It.IsAny <Expression <Func <OrganizationLicense, bool> > >())) .Returns(new List <OrganizationLicense>()); organizationLicenseService.Setup(m => m.GetAllProviderLicensesForMonth(It.IsAny <DateTime>())) .Returns(new List <OrganizationLicense> { providerLicense }); organizationLicenseService.Setup(m => m.Get(consumerLicense.ID)).Returns(consumerLicense); // Schema file service fileService.Setup(m => m.Add(It.IsAny <SchemaFile>())).Returns(true); fileService.Setup(m => m.Update(It.IsAny <SchemaFile>())).Returns(true); fileService.Setup(m => m.Get(schemaFile.ID)).Returns(schemaFile); fileService.Setup(m => m.Get(It.IsAny <Expression <Func <SchemaFile, bool> > >())) .Returns(new List <SchemaFile> { schemaFile }); // Dataschema service metaDataService.Setup(m => m.GetAllSchemas(1, false)).Returns(new List <DataSchema> { dSchemaDraft }); metaDataService.Setup(m => m.Add(It.IsAny <DataSchema>())).Returns(true); metaDataService.Setup(m => m.Update(It.IsAny <DataSchema>())).Returns(true); metaDataService.Setup(m => m.Get(dSchemaDraft.ID)).Returns(dSchemaDraft); metaDataService.Setup(m => m.Get(dSchemaPublished.ID)).Returns(dSchemaPublished); metaDataService.Setup(m => m.Get(dSchemaRetracted.ID)).Returns(dSchemaRetracted); // License matches var mService = new MockService <LicenseMatch>(); matchesService = new LicenseMatchesService(mService); matchesService.Add(licenseMatch); // Setup controller controller = new SchemasController(metaDataService.Object, fileService.Object, userService.Object, organizationService.Object, endpointService.Object, applicationService.Object, notificationService.Object, organizationLicenseService.Object, matchesService, configurationService.Object) { ControllerContext = context.Object, LoggedInUser = new LoggedInUserDetails(sysAdmin), Url = mock.Object }; }
public abstract string GetTableName(SchemaModel.Table table);
private void UdpatedSchemaModel(SchemaModel schemaModelModel) { }