예제 #1
0
        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()));
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
        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);
        }
예제 #9
0
        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);
        }
예제 #10
0
        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);
        }
예제 #11
0
        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);
        }
예제 #12
0
        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);
        }
예제 #13
0
        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);
        }
예제 #14
0
        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);
        }
예제 #15
0
        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);
        }
예제 #16
0
 public void Save(AssemblyMetadata model)
 {
     DataRepository.Save(AssemblyModelMapper.MapDown(model, assemblyModel));
 }
예제 #17
0
 public void Save(AssemblyModel model, string path)
 {
     Serializer.ToList().FirstOrDefault()?.Save(AssemblyModelMapper.MapDown(model, AssemblyModel.GetType()), path);
 }