public void Save(string path, AssemblyMetadata metadata) { BaseAssemblyMetadata Assembly = container.First(); Serializer.Serialize(path, AssemblyModelMapper.MapDown(metadata, Assembly)); //Serializer.Serialize(path, AssemblyModelMapper.MapDown(metadata, Assembly.GetType())); }
public void CheckAmountOfNamespaces() { Reflector reflector = new Reflector(reflectorPath); XMLSerializer xmlSerialization = new XMLSerializer(); xmlSerialization.Save(AssemblyModelMapper.MapDown(reflector.AssemblyModel, assemblyModel.GetType()), path); AssemblyModel model = AssemblyModelMapper.MapUp(xmlSerialization.Read(path)); Assert.AreEqual(3, model.NamespaceModels.Count); }
public void HowManyNamespacesTest() { Reflector reflector = new Reflector(path); DatabaseHandler xmlSerializer = new DatabaseHandler(); xmlSerializer.Serialize(null, AssemblyModelMapper.MapDown(reflector.AssemblyModel, assemblyModel)); AssemblyMetadata model = AssemblyModelMapper.MapUp(xmlSerializer.Deserialize(null)); Assert.AreEqual(2, model.Namespaces.Count); }
public void Setup() { string testDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string solutionDir = testDir.Substring(0, testDir.LastIndexOf("Projekt.JSONSerializer.UnitTest")); string PathToExampleDll = solutionDir + "Projekt.TestDLL\\TPA.ApplicationArchitecture.dll"; AssemblyMetadata assemblyMetadata = new AssemblyMetadata(Assembly.ReflectionOnlyLoadFrom(PathToExampleDll)); JSONAssemblyModel jsonAssemblyModel = new JSONAssemblyModel(); assemblyModel = AssemblyModelMapper.MapDown(assemblyMetadata, jsonAssemblyModel); }
public void CheckAmountOfFieldsInClass() { Reflector reflector = new Reflector(reflectorPath); XMLSerializer xmlSerialization = new XMLSerializer(); xmlSerialization.Save(AssemblyModelMapper.MapDown(reflector.AssemblyModel, assemblyModel.GetType()), path); AssemblyModel model = AssemblyModelMapper.MapUp(xmlSerialization.Read(path)); List <TypeModel> classes = model.NamespaceModels .Find(t => t.Name == "TestLibrary").Types.Where(t => t.Name == "PublicClass").ToList(); Assert.AreEqual(2, classes.First().Fields.Count); }
public void CheckAmountOfPublicClasses() { Reflector reflector = new Reflector(reflectorPath); XMLSerializer xmlSerialization = new XMLSerializer(); xmlSerialization.Save(AssemblyModelMapper.MapDown(reflector.AssemblyModel, assemblyModel.GetType()), path); AssemblyModel model = AssemblyModelMapper.MapUp(xmlSerialization.Read(path)); List <TypeModel> publicClasses = model.NamespaceModels .Find(t => t.Name == "TestLibrary").Types.Where(t => t.Modifiers.AccessLevel == AccessLevel.Public).ToList(); Assert.AreEqual(4, publicClasses.Count); }
public void CheckAmountOfClassesWithNestedTypes() { Reflector reflector = new Reflector(reflectorPath); DatabaseSerializer xmlSerialization = new DatabaseSerializer(); xmlSerialization.Save(AssemblyModelMapper.MapDown(reflector.AssemblyModel, assemblyModel.GetType()), null); AssemblyModel model = AssemblyModelMapper.MapUp(xmlSerialization.Read(null)); List <TypeModel> classesWithNestedTypes = model.NamespaceModels .Find(t => t.Name == "TestLibrary.NamespaceTwo").Types.Where(t => t.NestedTypes.Count > 0).ToList(); Assert.AreEqual(2, classesWithNestedTypes.Count); }
public void CheckAmountOfInterfaces() { Reflector reflector = new Reflector(reflectorPath); XMLSerializer xmlSerialization = new XMLSerializer(); xmlSerialization.Save(AssemblyModelMapper.MapDown(reflector.AssemblyModel, assemblyModel.GetType()), path); AssemblyModel model = AssemblyModelMapper.MapUp(xmlSerialization.Read(path)); List <TypeModel> interfaces = model.NamespaceModels .Find(t => t.Name == "TestLibrary").Types.Where(t => t.Type == TypeEnum.Interface).ToList(); Assert.AreEqual(1, interfaces.Count); }
public void CheckAmountOfClassesWithGenericArguments() { Reflector reflector = new Reflector(reflectorPath); XMLSerializer xmlSerialization = new XMLSerializer(); xmlSerialization.Save(AssemblyModelMapper.MapDown(reflector.AssemblyModel, assemblyModel.GetType()), path); AssemblyModel model = AssemblyModelMapper.MapUp(xmlSerialization.Read(path)); List <TypeModel> genericClasses = model.NamespaceModels .Find(t => t.Name == "TestLibrary.NamespaceTwo").Types.Where(t => t.GenericArguments != null) .ToList(); Assert.AreEqual(1, genericClasses.Count); }
public void HowManyPublicClassesTest() { Reflector reflector = new Reflector(path); DatabaseHandler xmlSerializer = new DatabaseHandler(); xmlSerializer.Serialize(XMLFilePath, AssemblyModelMapper.MapDown(reflector.AssemblyModel, assemblyModel)); AssemblyMetadata model = AssemblyModelMapper.MapUp(xmlSerializer.Deserialize(XMLFilePath)); List <TypeMetadata> publicClasses = reflector.AssemblyModel.Namespaces .Find(t => t.Name == "TPA.ApplicationArchitecture.Data").Types .Where(t => t.Modifiers.AccessLevel == AccessLevel.Public).ToList(); Assert.AreEqual(9, publicClasses.Count); }
public void HowManyClassesWithImplementedInterfacesTest() { Reflector reflector = new Reflector(path); DatabaseHandler xmlSerializer = new DatabaseHandler(); xmlSerializer.Serialize(XMLFilePath, AssemblyModelMapper.MapDown(reflector.AssemblyModel, assemblyModel)); AssemblyMetadata model = AssemblyModelMapper.MapUp(xmlSerializer.Deserialize(XMLFilePath)); List <TypeMetadata> classesWithImplementedInterfaces = reflector.AssemblyModel.Namespaces .Find(t => t.Name == "TPA.ApplicationArchitecture.Data").Types .Where(t => t.ImplementedInterfaces.Count > 0).ToList(); Assert.AreEqual(1, classesWithImplementedInterfaces.Count); }
public void CheckAmountOfAbstractClasses() { Reflector reflector = new Reflector(reflectorPath); DatabaseSerializer xmlSerialization = new DatabaseSerializer(); xmlSerialization.Save(AssemblyModelMapper.MapDown(reflector.AssemblyModel, assemblyModel.GetType()), null); AssemblyModel model = AssemblyModelMapper.MapUp(xmlSerialization.Read(null)); List <TypeModel> abstractClasses = model.NamespaceModels .Find(t => t.Name == "TestLibrary").Types .Where(t => t.Modifiers.AbstractEnum == AbstractEnum.Abstract).ToList(); Assert.AreEqual(2, abstractClasses.Count); }
public void Setup() { assemblyMetadatas = new List <DatabaseAssemblyModel>(); string testDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string solutionDir = testDir.Substring(0, testDir.LastIndexOf("Projekt.Database.UnitTest")); string PathToExampleDll = solutionDir + "Projekt.TestDLL\\TPA.ApplicationArchitecture.dll"; DatabaseService databaseService = new DatabaseService(); AssemblyMetadata assemblyMetadata = new AssemblyMetadata(Assembly.ReflectionOnlyLoadFrom(PathToExampleDll)); DatabaseAssemblyModel databaseAssemblyModel = new DatabaseAssemblyModel(); AssemblyModel model = AssemblyModelMapper.MapDown(assemblyMetadata, databaseAssemblyModel); assemblyMetadatas.Add(databaseAssemblyModel); }
public void CheckAmountOfClasses() { Reflector reflector = new Reflector(reflectorPath); XMLSerializer xmlSerialization = new XMLSerializer(); xmlSerialization.Save(AssemblyModelMapper.MapDown(reflector.AssemblyModel, assemblyModel.GetType()), path); AssemblyModel model = AssemblyModelMapper.MapUp(xmlSerialization.Read(path)); List <TypeModel> testLibraryTypes = model.NamespaceModels.Find(t => t.Name == "TestLibrary").Types; List <TypeModel> namespaceTwoTypes = model.NamespaceModels.Find(t => t.Name == "TestLibrary.NamespaceTwo").Types; List <TypeModel> namespaceWithRecursionTypes = model.NamespaceModels.Find(t => t.Name == "TestLibrary.NamespaceWithRecursion").Types; Assert.AreEqual(6, namespaceTwoTypes.Count); Assert.AreEqual(3, namespaceWithRecursionTypes.Count); Assert.AreEqual(4, testLibraryTypes.Count); }
public void HowManyClassesTest() { Reflector reflector = new Reflector(path); DatabaseHandler xmlSerializer = new DatabaseHandler(); xmlSerializer.Serialize(XMLFilePath, AssemblyModelMapper.MapDown(reflector.AssemblyModel, assemblyModel)); AssemblyMetadata model = AssemblyModelMapper.MapUp(xmlSerializer.Deserialize(XMLFilePath)); List <TypeMetadata> niceNamespaceTypes = reflector.AssemblyModel.Namespaces .Find(t => t.Name == "TPA.ApplicationArchitecture.Data").Types; Assert.AreEqual(9, niceNamespaceTypes.Count); List <TypeMetadata> recursionTypes = reflector.AssemblyModel.Namespaces .Find(t => t.Name == "TPA.ApplicationArchitecture.Data.CircularReference").Types; Assert.AreEqual(2, recursionTypes.Count); }
public void Save(AssemblyMetadata model) { DataRepository.Save(AssemblyModelMapper.MapDown(model, assemblyModel)); }
public void Save(AssemblyModel model, string path) { Serializer.ToList().FirstOrDefault()?.Save(AssemblyModelMapper.MapDown(model, AssemblyModel.GetType()), path); }