Dispose() 공개 메소드

public Dispose ( ) : void
리턴 void
예제 #1
0
        public void ShouldTestBasicFeaturesWithoutCache()
        {
            var dataBaseManager = new DataBaseManager();

            #region CREATE_SERVICES

            var serviceManager = dataBaseManager.ServiceType;

            var serviceGit = serviceManager.Create("Git", "System Version Control (decentralized)", new[] { "r", "rw" });

            var serviceSvn = serviceManager.Create("Svn", "System Version Control (Centralized)", new[] { "r", "rw" });

            var serviceTrac = serviceManager.Create("Trac", "WIKI system", new[] { "TRAC_ADMIN" });

            #endregion

            dataBaseManager.Dispose();
            dataBaseManager = new DataBaseManager();

            #region CREATE_USERS

            var userManager = dataBaseManager.User;

            var userFaustino = userManager.Create("FaustinoLeiras", "FaustinoLeiras12345", "*****@*****.**");

            var userSamir = userManager.Create("SamirHafez", "SamirHafez12345", "*****@*****.**");

            var userRicardo = userManager.Create("Ricardo", "Ricardo12345", "*****@*****.**");

            var userGeada = userManager.Create("Gueada", "Gueada12345", "*****@*****.**");

            var userFelix = userManager.Create("Felix", "Felix12345", "*****@*****.**");

            var userGuedes = userManager.Create("Guedes", "Guedes12345", "*****@*****.**");

            #endregion

            dataBaseManager.Dispose();
            dataBaseManager = new DataBaseManager();

            #region CREATE_STRUCTURE

            var structureManager = dataBaseManager.Structure;

            var structure = structureManager.Create("AcademicStructure", "My Academic Structure :)", true, userFaustino.Name);

            #endregion

            dataBaseManager.Dispose();
            dataBaseManager = new DataBaseManager();

            #region CREATE_WORKSPACE_TYPE

            var workspaceType = dataBaseManager.WorkSpaceType;

            var workspacePublic = workspaceType.Create(structure.Id, "public", new[] { serviceGit.Name, serviceSvn.Name, serviceTrac.Name });

            var workspacePrivate = workspaceType.Create(structure.Id, "private", new[] { serviceGit.Name, serviceSvn.Name, serviceTrac.Name });

            #endregion

            dataBaseManager.Dispose();
            dataBaseManager = new DataBaseManager();

            #region CREATE_CONTAINER_PROTOTYPE

            var containerPrototype = dataBaseManager.ContainerType;

            var prototypeGraduation = containerPrototype.Create(structure.Id, "Graduation", null);

            var prototypeCourse = containerPrototype.Create(structure.Id, "Course", prototypeGraduation.Name);

            var prototypeClass = containerPrototype.Create(structure.Id, "Class", prototypeCourse.Name);

            var prototypeGroup = containerPrototype.Create(structure.Id, "Group", prototypeClass.Name);

            #endregion

            dataBaseManager.Dispose();
            dataBaseManager = new DataBaseManager();

            #region ADD_WORKSPACE_TYPES_INTO_CONTAINER_PROTOTYPE

            containerPrototype.AddWorkSpaceType(structure.Id, prototypeGraduation.Name, workspacePublic.Name);

            containerPrototype.AddWorkSpaceType(structure.Id, prototypeCourse.Name, workspacePublic.Name);

            containerPrototype.AddWorkSpaceType(structure.Id, prototypeClass.Name, workspacePublic.Name);
            containerPrototype.AddWorkSpaceType(structure.Id, prototypeClass.Name, workspacePrivate.Name);

            containerPrototype.AddWorkSpaceType(structure.Id, prototypeGroup.Name, workspacePublic.Name);

            #endregion

            dataBaseManager.Dispose();
            dataBaseManager = new DataBaseManager();

            #region CREATE_ROLETYPE

            var roleType = dataBaseManager.RoleType;

            var roleTypeTeacher = roleType.Create(structure.Id, "teacher");

            var roleTypeDirector = roleType.Create(structure.Id, "director");

            var roleTypeStudant = roleType.Create(structure.Id, "studant");

            #endregion

            dataBaseManager.Dispose();
            dataBaseManager = new DataBaseManager();

            #region CREATE_RULE

            var rule = dataBaseManager.Rule;

            var ruleReaders = rule.Create(structure.Id, "readers", new[]
                                                           {
                                                               new KeyValuePair<string, string>(serviceGit.Name, "r"),
                                                               new KeyValuePair<string, string>(serviceSvn.Name, "r"),
                                                               new KeyValuePair<string, string>(serviceTrac.Name, "TRAC_ADMIN")
                                                           });

            var ruleReadersAndWriters = rule.Create(structure.Id, "ReadersAndWriters", new[]
                                                                     {
                                                                         new KeyValuePair<string, string>(
                                                                             serviceGit.Name,
                                                                             "rw"),
                                                                         new KeyValuePair<string, string>(
                                                                             serviceSvn.Name,
                                                                             "rw"),
                                                                         new KeyValuePair<string, string>(
                                                                             serviceTrac.Name,
                                                                             "TRAC_ADMIN")
                                                                     });

            #endregion

            dataBaseManager.Dispose();
            dataBaseManager = new DataBaseManager();

            #region CREATE_ROLE

            var role = dataBaseManager.Role;

            #region ADD_ROLES_GRADUATION_WORKSPACE_PUBLIC

            role.Create(
                structure.Id,
                prototypeGraduation.Name,
                workspacePublic.Name,
                roleTypeDirector.Name,
                new[] { ruleReadersAndWriters.Name }
                );

            #endregion

            #region ADD_ROLES_COURSE_WORKSPACE_PUBLIC

            role.Create(
                structure.Id,
                prototypeCourse.Name,
                workspacePublic.Name,
                roleTypeDirector.Name,
                new[] { ruleReadersAndWriters.Name }
                );

            role.Create(
                structure.Id,
                prototypeCourse.Name,
                workspacePublic.Name,
                roleTypeTeacher.Name,
                new[] { ruleReaders.Name }
                );

            role.Create(
                structure.Id,
                prototypeCourse.Name,
                workspacePublic.Name,
                roleTypeStudant.Name,
                new[] { ruleReaders.Name }
                );

            #endregion

            #region ADD_ROLES_CLASS_WORKSPACE_PUBLIC

            role.Create(
                structure.Id,
                prototypeClass.Name,
                workspacePublic.Name,
                roleTypeDirector.Name,
                new[] { ruleReaders.Name }
                );

            role.Create(
                structure.Id,
                prototypeClass.Name,
                workspacePublic.Name,
                roleTypeTeacher.Name,
                new[] { ruleReadersAndWriters.Name }
                );

            role.Create(
                structure.Id,
                prototypeClass.Name,
                workspacePublic.Name,
                roleTypeStudant.Name,
                new[] { ruleReaders.Name }
                );

            #endregion

            #region ADD_ROLES_CLASS_WORKSPACE_PRIVATE

            role.Create(
                structure.Id,
                prototypeClass.Name,
                workspacePrivate.Name,
                roleTypeDirector.Name,
                new[] { ruleReaders.Name }
                );

            role.Create(
                structure.Id,
                prototypeClass.Name,
                workspacePrivate.Name,
                roleTypeTeacher.Name,
                new[] { ruleReadersAndWriters.Name }
                );

            #endregion

            #region ADD_ROLES_GROUP_WORKSPACE_PUBLIC

            role.Create(
                structure.Id,
                prototypeGroup.Name,
                workspacePublic.Name,
                roleTypeDirector.Name,
                new[] { ruleReaders.Name }
                );

            role.Create(
                structure.Id,
                prototypeGroup.Name,
                workspacePublic.Name,
                roleTypeTeacher.Name,
                new[] { ruleReadersAndWriters.Name }
                );

            role.Create(
                structure.Id,
                prototypeGroup.Name,
                workspacePublic.Name,
                roleTypeStudant.Name,
                new[] { ruleReadersAndWriters.Name }
                );

            #endregion

            #endregion

            dataBaseManager.Dispose();
            dataBaseManager = new DataBaseManager();

            #region CREATE_CONTAINERS

            var container = dataBaseManager.Container;

            var containerLeic = container.Create(structure.Id, "LEIC", "Licencitura Egenharia informatica e de computadores", null);

            #region CREATE_COURSE_MPD

            var containerMpd = container.Create(structure.Id, "MPD", "Modelo de padoes de desenho", containerLeic.Id);

            var containerMpdLi31D = container.Create(structure.Id, "LI31D", "Turma 1 de terceiro semestre diurno", containerMpd.Id);

            var containerMpdG1 = container.Create(structure.Id, "Grupo1", "Grupo 1 de MPD", containerMpdLi31D.Id);

            var containerMpdG2 = container.Create(structure.Id, "Grupo2", "Grupo 2 de MPD", containerMpdLi31D.Id);

            #endregion

            #region CREATE_COURSE_SD

            var containerSd = container.Create(structure.Id, "SD", "Sistemas distribuidos", containerLeic.Id);

            var containerSdLi31D = container.Create(structure.Id, "LI31D", "Turma 1 de terceiro semestre diurno", containerSd.Id);

            var containerSdG1 = container.Create(structure.Id, "Grupo1", "Grupo 1 de SD", containerSdLi31D.Id);

            var containerSdG2 = container.Create(structure.Id, "Grupo2", "Grupo 2 de SD", containerSdLi31D.Id);

            #endregion

            #endregion

            dataBaseManager.Dispose();
            dataBaseManager = new DataBaseManager();

            #region ENROLL_USER

            userManager.Enroll(userFelix.Name, structure.Id, containerLeic.Id, roleTypeDirector.Name);

            userManager.Enroll(userFelix.Name, structure.Id, containerMpd.Id, roleTypeDirector.Name);
            userManager.Enroll(userGuedes.Name, structure.Id, containerSd.Id, roleTypeDirector.Name);

            userManager.Enroll(userFelix.Name, structure.Id, containerSdLi31D.Id, roleTypeTeacher.Name);
            userManager.Enroll(userGuedes.Name, structure.Id, containerMpdLi31D.Id, roleTypeTeacher.Name);

            userManager.Enroll(userFaustino.Name, structure.Id, containerMpdG1.Id, roleTypeStudant.Name);
            userManager.Enroll(userSamir.Name, structure.Id, containerMpdG1.Id, roleTypeStudant.Name);

            userManager.Enroll(userRicardo.Name, structure.Id, containerMpdG2.Id, roleTypeStudant.Name);
            userManager.Enroll(userGeada.Name, structure.Id, containerMpdG2.Id, roleTypeStudant.Name);

            userManager.Enroll(userFaustino.Name, structure.Id, containerSdG1.Id, roleTypeStudant.Name);
            userManager.Enroll(userRicardo.Name, structure.Id, containerSdG1.Id, roleTypeStudant.Name);

            userManager.Enroll(userGeada.Name, structure.Id, containerSdG2.Id, roleTypeStudant.Name);
            userManager.Enroll(userSamir.Name, structure.Id, containerSdG2.Id, roleTypeStudant.Name);

            #endregion

            dataBaseManager.Dispose();
            //using (dataBaseManager = new DataBaseManager())
            //{
            //    AuthorizationTestes aut = new AuthorizationTestes();
            //    AuthorizationManager authorizationManager = new AuthorizationManager(dataBaseManager);

            //    authorizationManager.CreateServiceAuthorizationStruct(aut, serviceSvn.Name);
            //}
        }
예제 #2
0
        public void ShouldTestBasicFeaturesWithoutCache()
        {
            DataBaseManager.DropAndCreate();

            DataBaseManager dataBaseManager;
            dataBaseManager = new DataBaseManager();

            #region CREATE_SERVICES

            var serviceManager = new ServiceManager(dataBaseManager);

            var serviceGit = new ServiceView()
                                 {
                                     Name = "Git",
                                     Description = "System Version Control (decentralized)"
                                 };

            serviceManager.Create(serviceGit, new[] {"r", "rw"});

            var serviceSvn = new ServiceView()
                                 {
                                     Name = "SVN",
                                     Description = "System Version Control (Centralized)"
                                 };

            serviceManager.Create(serviceSvn, new[] {"r", "rw"});

            #endregion

            dataBaseManager.Dispose();
            dataBaseManager = new DataBaseManager();

            #region CREATE_USERS

            var userManager = new UserManager(dataBaseManager);

            var userFaustino = new UserView()
                                   {
                                       Name = "FaustinoLeiras",
                                       Email = "*****@*****.**",
                                       Password = AuthenticationManager.EncryptPassword("12345678Ab")
                                   };

            userManager.Create(userFaustino);

            var userSamir = new UserView()
                                {
                                    Name = "SamirHafez",
                                    Email = "*****@*****.**",
                                    Password = AuthenticationManager.EncryptPassword("12345678Ab")
                                };

            userManager.Create(userSamir);

            var userRicardo = new UserView()
                                  {
                                      Name = "Ricardo",
                                      Email = "*****@*****.**",
                                      Password = AuthenticationManager.EncryptPassword("12345678Ab")
                                  };

            userManager.Create(userRicardo);

            var userGeada = new UserView()
                                {
                                    Name = "Gueada",
                                    Email = "*****@*****.**",
                                    Password = AuthenticationManager.EncryptPassword("12345678Ab")
                                };

            userManager.Create(userGeada);

            var userFelix = new UserView()
                                {
                                    Name = "Felix",
                                    Email = "*****@*****.**",
                                    Password = AuthenticationManager.EncryptPassword("12345678Ab")
                                };

            userManager.Create(userFelix);

            var userGuedes = new UserView()
                                 {
                                     Name = "Guedes",
                                     Email = "*****@*****.**",
                                     Password = AuthenticationManager.EncryptPassword("12345678Ab")
                                 };

            userManager.Create(userGuedes);

            #endregion

            dataBaseManager.Dispose();
            dataBaseManager = new DataBaseManager();

            #region CREATE_STRUCTURE

            var structureManager = new StructureManager(dataBaseManager);

            var structure = new StructureView()
                                {
                                    Name = "AcademicStructure",
                                    Description = "My Academic Structure :)"
                                };

            structureManager.Create(structure, userFelix.Name);

            #endregion

            dataBaseManager.Dispose();
            dataBaseManager = new DataBaseManager();

            #region CREATE_WORKSPACE_TYPE

            var workspaceType = new WorkSpaceTypeManager(dataBaseManager);

            var workspacePublic = new WorkSpaceTypeView()
                                      {
                                          Name = "public"
                                      };

            workspaceType.Create(workspacePublic, structure.Id, new[] {serviceGit.Name, serviceSvn.Name});

            var workspacePrivate = new WorkSpaceTypeView()
                                       {
                                           Name = "private"
                                       };

            workspaceType.Create(workspacePrivate, structure.Id, new[] {serviceGit.Name, serviceSvn.Name});

            #endregion

            dataBaseManager.Dispose();
            dataBaseManager = new DataBaseManager();

            #region CREATE_CONTAINER_PROTOTYPE

            var containerPrototype = new ContainerPrototypeManager(dataBaseManager);

            var prototypeCourse = new ContainerPrototypeView()
                                      {
                                          Name = "Course"
                                      };

            containerPrototype.Create(prototypeCourse, structure.Id);

            var prototypeClass = new ContainerPrototypeView()
                                     {
                                         Name = "Class"
                                     };

            containerPrototype.Create(prototypeClass, structure.Id, prototypeCourse.Name);

            var prototypeGroup = new ContainerPrototypeView()
                                     {
                                         Name = "Group"
                                     };

            containerPrototype.Create(prototypeGroup, structure.Id, prototypeClass.Name);

            #endregion

            dataBaseManager.Dispose();
            dataBaseManager = new DataBaseManager();

            #region ADD_WORKSPACE_TYPES_INTO_CONTAINER_PROTOTYPE

            containerPrototype = new ContainerPrototypeManager(dataBaseManager);

            containerPrototype.AddWorkSpaceType(structure.Id, prototypeCourse.Name, workspacePublic.Name);

            containerPrototype.AddWorkSpaceType(structure.Id, prototypeClass.Name, workspacePublic.Name);
            containerPrototype.AddWorkSpaceType(structure.Id, prototypeClass.Name, workspacePrivate.Name);

            containerPrototype.AddWorkSpaceType(structure.Id, prototypeGroup.Name, workspacePublic.Name);

            #endregion

            dataBaseManager.Dispose();
            dataBaseManager = new DataBaseManager();

            #region CREATE_ROLETYPE

            var roleType = new RoleTypeManager(dataBaseManager);

            var roleTypeTeacher = new RoleTypeView()
                                      {
                                          Name = "teacher"
                                      };

            roleType.Create(roleTypeTeacher, structure.Id);

            var roleTypeDirector = new RoleTypeView()
                                       {
                                           Name = "director"
                                       };

            roleType.Create(roleTypeDirector, structure.Id);

            var roleTypeStudant = new RoleTypeView()
                                      {
                                          Name = "studant"
                                      };

            roleType.Create(roleTypeStudant, structure.Id);

            #endregion

            dataBaseManager.Dispose();
            dataBaseManager = new DataBaseManager();

            #region CREATE_RULE

            var rule = new RuleManager(dataBaseManager);

            var ruleReaders = new RuleView()
                                  {
                                      Name = "readers"
                                  };

            rule.Create(ruleReaders, structure.Id, new[]
                                                       {
                                                           new KeyValuePair<string, string>(serviceGit.Name, "r"),
                                                           new KeyValuePair<string, string>(serviceSvn.Name, "r")
                                                       });

            var ruleReadersAndWriters = new RuleView()
                                            {
                                                Name = "ReadersAndWriters"
                                            };

            rule.Create(ruleReadersAndWriters, structure.Id, new[]
                                                                 {
                                                                     new KeyValuePair<string, string>(
                                                                         serviceGit.Name,
                                                                         "rw"),
                                                                     new KeyValuePair<string, string>(
                                                                         serviceSvn.Name,
                                                                         "rw")
                                                                 });

            #endregion

            dataBaseManager.Dispose();
            dataBaseManager = new DataBaseManager();

            #region CREATE_ROLE

            var role = new RoleManager(dataBaseManager);

            #region ADD_ROLES_COURSE_WORKSPACE_PUBLIC

            role.Create(
                structure.Id,
                prototypeCourse.Name,
                workspacePublic.Name,
                roleTypeDirector.Name,
                ruleReadersAndWriters.Name
                );

            role.Create(
                structure.Id,
                prototypeCourse.Name,
                workspacePublic.Name,
                roleTypeTeacher.Name,
                ruleReaders.Name
                );

            role.Create(
                structure.Id,
                prototypeCourse.Name,
                workspacePublic.Name,
                roleTypeStudant.Name,
                ruleReaders.Name
                );

            #endregion

            #region ADD_ROLES_CLASS_WORKSPACE_PUBLIC

            role.Create(
                structure.Id,
                prototypeClass.Name,
                workspacePublic.Name,
                roleTypeDirector.Name,
                ruleReaders.Name
                );

            role.Create(
                structure.Id,
                prototypeClass.Name,
                workspacePublic.Name,
                roleTypeTeacher.Name,
                ruleReadersAndWriters.Name
                );

            role.Create(
                structure.Id,
                prototypeClass.Name,
                workspacePublic.Name,
                roleTypeStudant.Name,
                ruleReaders.Name
                );

            #endregion

            #region ADD_ROLES_CLASS_WORKSPACE_PRIVATE

            role.Create(
                structure.Id,
                prototypeClass.Name,
                workspacePrivate.Name,
                roleTypeDirector.Name,
                ruleReaders.Name
                );

            role.Create(
                structure.Id,
                prototypeClass.Name,
                workspacePrivate.Name,
                roleTypeTeacher.Name,
                ruleReadersAndWriters.Name
                );

            #endregion

            #region ADD_ROLES_GROUP_WORKSPACE_PUBLIC

            role.Create(
                structure.Id,
                prototypeGroup.Name,
                workspacePublic.Name,
                roleTypeDirector.Name,
                ruleReaders.Name
                );

            role.Create(
                structure.Id,
                prototypeGroup.Name,
                workspacePublic.Name,
                roleTypeTeacher.Name,
                ruleReadersAndWriters.Name
                );

            role.Create(
                structure.Id,
                prototypeGroup.Name,
                workspacePublic.Name,
                roleTypeStudant.Name,
                ruleReadersAndWriters.Name
                );

            #endregion

            #endregion

            dataBaseManager.Dispose();
            dataBaseManager = new DataBaseManager();

            #region CREATE_CONTAINERS

            var container = new ContainerManager(dataBaseManager);

            #region CREATE_COURSE_MPD

            var containerMpd = new ContainerView()
                                   {
                                       Name = "MPD",
                                       Description = "Modelo de padoes de desenho"
                                   };

            container.Create(containerMpd, structure.Id, prototypeCourse.Name);

            var containerMpdLi31D = new ContainerView()
                                        {
                                            Name = "LI31D",
                                            Description = "Turma 1 de terceiro semestre diurno"
                                        };

            container.Create(containerMpdLi31D, structure.Id, prototypeClass.Name, containerMpd.Id);

            var containerMpdG1 = new ContainerView()
                                     {
                                         Name = "Grupo1",
                                         Description = "Grupo de MPD"
                                     };

            container.Create(containerMpdG1, structure.Id, prototypeGroup.Name, containerMpdLi31D.Id);

            var containerMpdG2 = new ContainerView()
                                     {
                                         Name = "Grupo2",
                                         Description = "Grupo de MPD"
                                     };

            container.Create(containerMpdG2, structure.Id, prototypeGroup.Name, containerMpdLi31D.Id);

            #endregion

            #region CREATE_COURSE_SD

            var containerSd = new ContainerView()
                                  {
                                      Name = "SD",
                                      Description = "Sistemas distribuidos"
                                  };

            container.Create(containerSd, structure.Id, prototypeCourse.Name);

            var containerSdLi31D = new ContainerView()
                                       {
                                           Name = "LI31D",
                                           Description = "Turma 1 de terceiro semestre diurno"
                                       };

            container.Create(containerSdLi31D, structure.Id, prototypeClass.Name, containerSd.Id);

            var containerSdG1 = new ContainerView()
                                    {
                                        Name = "Grupo1",
                                        Description = "Grupo de SD"
                                    };

            container.Create(containerSdG1, structure.Id, prototypeGroup.Name, containerSdLi31D.Id);

            var containerSdG2 = new ContainerView()
                                    {
                                        Name = "Grupo2",
                                        Description = "Grupo de SD"
                                    };

            container.Create(containerSdG2, structure.Id, prototypeGroup.Name, containerSdLi31D.Id);

            #endregion

            #endregion

            dataBaseManager.Dispose();
            dataBaseManager = new DataBaseManager();

            #region ENROLL_USER

            userManager = new UserManager(dataBaseManager);

            userManager.Enroll(userFelix.Name, structure.Id, containerMpd.Id, roleTypeDirector.Name);
            userManager.Enroll(userGuedes.Name, structure.Id, containerSd.Id, roleTypeDirector.Name);

            userManager.Enroll(userFelix.Name, structure.Id, containerSdLi31D.Id, roleTypeTeacher.Name);
            userManager.Enroll(userGuedes.Name, structure.Id, containerMpdLi31D.Id, roleTypeTeacher.Name);

            userManager.Enroll(userFaustino.Name, structure.Id, containerMpdG1.Id, roleTypeStudant.Name);
            userManager.Enroll(userSamir.Name, structure.Id, containerMpdG1.Id, roleTypeStudant.Name);

            userManager.Enroll(userRicardo.Name, structure.Id, containerMpdG2.Id, roleTypeStudant.Name);
            userManager.Enroll(userGeada.Name, structure.Id, containerMpdG2.Id, roleTypeStudant.Name);

            userManager.Enroll(userFaustino.Name, structure.Id, containerSdG1.Id, roleTypeStudant.Name);
            userManager.Enroll(userRicardo.Name, structure.Id, containerSdG1.Id, roleTypeStudant.Name);

            userManager.Enroll(userGeada.Name, structure.Id, containerSdG2.Id, roleTypeStudant.Name);
            userManager.Enroll(userSamir.Name, structure.Id, containerSdG2.Id, roleTypeStudant.Name);

            #endregion

            dataBaseManager.Dispose();
            using (dataBaseManager = new DataBaseManager())
            {
                AuthorizationTestes aut = new AuthorizationTestes();
                AuthorizationManager authorizationManager = new AuthorizationManager(dataBaseManager);

                authorizationManager.CreateServiceAuthorizationStruct(aut, serviceSvn.Name);
            }
        }