Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
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);
        }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
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);
        }
Ejemplo n.º 11
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);
        }
Ejemplo n.º 12
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);
        }
Ejemplo n.º 13
0
 public AssemblyMetadata Read()
 {
     return(AssemblyModelMapper.MapUp(DataRepository.Read()));
 }
Ejemplo n.º 14
0
 public AssemblyModel Load(string path)
 {
     return(AssemblyModelMapper.MapUp(Serializer.ToList().FirstOrDefault()?.Read(path)));
 }
Ejemplo n.º 15
0
 public AssemblyMetadata Load(string path)
 {
     //Serializer = containerser.First();
     return(AssemblyModelMapper.MapUp(Serializer.Deserialize(path)));
 }