public void TestWithMetaClass() { var kernel = new ContainerBuilder(); var builder = kernel.UseDatenMeisterDotNet(new IntegrationSettings { PathToXmiFiles = "Xmi" }); using (var scope = builder.BeginLifetimeScope()) { var dataLayerLogic = scope.Resolve<IDataLayerLogic>(); var dataLayers = scope.Resolve<DataLayers>(); var umlDataLayer = dataLayers.Uml; var uml = dataLayerLogic.Get<_UML>(umlDataLayer); Assert.That(uml, Is.Not.Null); var extent = new XmlUriExtent("dm:///test"); extent.Workspaces = scope.Resolve<IWorkspaceCollection>(); dataLayerLogic.AssignToDataLayer(extent, dataLayers.Types); var factory = scope.Resolve<IFactoryMapper>().FindFactoryFor(scope, extent); var interfaceClass = uml.SimpleClassifiers.__Interface; var element = factory.create(interfaceClass); Assert.That(element, Is.Not.Null); extent.elements().add(element); Assert.That(extent.elements().size(), Is.EqualTo(1)); var retrievedElement = extent.elements().ElementAt(0) as IElement; Assert.That(retrievedElement, Is.Not.Null); Assert.That(retrievedElement.getMetaClass(), Is.Not.Null); Assert.That(retrievedElement.metaclass, Is.Not.Null); var foundMetaClass = retrievedElement.metaclass; Assert.That(foundMetaClass.Equals(interfaceClass), Is.True); } }
public void TestGeneralizedProperties() { var kernel = new ContainerBuilder(); kernel.RegisterSource(new AnyConcreteTypeNotAlreadyRegisteredSource()); var builder = kernel.UseDatenMeisterDotNet(new IntegrationSettings { PathToXmiFiles = "Xmi" }); using (var scope = builder.BeginLifetimeScope()) { var classifierMethods = scope.Resolve<ClassifierMethods>(); classifierMethods.Legacy = false; var dataLayers = scope.Resolve<DataLayers>(); var dataLayerLogic = scope.Resolve<DataLayerLogic>(); // Gets the logic var uml = dataLayerLogic.Get<_UML>(dataLayers.Uml); var feature = uml.Classification.__Feature; var properties = classifierMethods.GetPropertiesOfClassifier(feature).ToList(); Assert.That(properties.Contains(_UML._Classification._Feature.isStatic), Is.True, "isStatic"); Assert.That(properties.Contains(_UML._Classification._RedefinableElement.isLeaf), Is.True, "isLeaf (Parent)"); Assert.That(properties.Contains(_UML._CommonStructure._NamedElement.name), Is.True, "name (Parent of Parent)"); } }
public void TestFactoryMappingByAttributeForExtentLoaders() { var kernel = new ContainerBuilder(); var builder = kernel.UseDatenMeisterDotNet(new IntegrationSettings {PathToXmiFiles = "Xmi"}); using (var scope = builder.BeginLifetimeScope()) { var mapper = new ManualConfigurationToExtentStorageMapper(); mapper.PerformMappingForConfigurationOfExtentLoaders(); Assert.That(mapper.HasMappingFor(typeof(CSVStorageConfiguration)), Is.True); Assert.That(mapper.HasMappingFor(typeof(CSVDataProvider)), Is.False); } }
public void TestCreatabeTypes() { var kernel = new ContainerBuilder(); var builder = kernel.UseDatenMeisterDotNet(new IntegrationSettings {PathToXmiFiles = "Xmi"}); using (var scope = builder.BeginLifetimeScope()) { // Apply for zipcodes var integrateZipCodes = scope.Resolve<Integrate>(); integrateZipCodes.Into(scope.Resolve<IWorkspaceCollection>().FindExtent("dm:///types")); var extentFunctions = scope.Resolve<ExtentFunctions>(); var dataLayers = scope.Resolve<DataLayers>(); var dataExtent = new MofUriExtent("dm:///test"); var creatableTypes = extentFunctions.GetCreatableTypes(dataExtent); Assert.That(creatableTypes, Is.Not.Null); Assert.That(creatableTypes.MetaLayer, Is.EqualTo(dataLayers.Types)); Assert.That(creatableTypes.CreatableTypes.Count, Is.EqualTo(1)); } }
public void TestXmlExtentStorage() { var kernel = new ContainerBuilder(); var builder = kernel.UseDatenMeisterDotNet(new IntegrationSettings { PathToXmiFiles = "Xmi" }); using (var scope = builder.BeginLifetimeScope()) { var path = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), $"testing{new Random().Next(0, 100000)}.xml"); if (File.Exists(path)) { File.Delete(path); } var storageConfiguration = new XmiStorageConfiguration { ExtentUri = "dm:///test", Path = path, Workspace = "Data" }; // Creates the extent var loader = scope.Resolve<IExtentStorageLoader>(); var loadedExtent = loader.LoadExtent(storageConfiguration, true); Assert.That(loadedExtent, Is.TypeOf<XmlUriExtent>()); // Includes some data var factory = scope.Resolve<IFactoryMapper>().FindFactoryFor(scope, loadedExtent); var createdElement = factory.create(null); Assert.That(createdElement, Is.TypeOf<XmlElement>()); loadedExtent.elements().add(createdElement); createdElement.set("test", "Test"); Assert.That(createdElement.get("test"), Is.EqualTo("Test")); // Stores the extent loader.StoreExtent(loadedExtent); // Detaches it loader.DetachExtent(loadedExtent); // Reloads it storageConfiguration.ExtentUri = "dm:///test_new"; var newExtent = loader.LoadExtent(storageConfiguration, false); Assert.That(newExtent.elements().size(), Is.EqualTo(1)); Assert.That((newExtent.elements().ElementAt(0) as IElement).get("test"), Is.EqualTo("Test")); } }
private IContainer CreateKernel(IAppBuilder app) { var settings = new IntegrationSettings { PathToXmiFiles = "App_Data/Xmi", EstablishDataEnvironment = true }; var kernel = new ContainerBuilder(); var container = kernel.UseDatenMeisterDotNet(settings); // Defines the shutdown var properties = new AppProperties(app.Properties); var token = properties.OnAppDisposing; token.Register(() => { _lifetimeScope.UnuseDatenMeister(); }); return container; }