Beispiel #1
0
        public void ExecuteTests()
        {
            IMCollection <Action> testMethods = Tests();

            if (Predefined.IsEmpty(testMethods))
            {
                _logger.Log("[IGNORED] " + this + " There are no tests to be executed here...");
                return;
            }

            if (IgnoreSuite())
            {
                _logger.Log("[IGNORED] " + this + " This suite is marked to be ignored");
                return;
            }

            testMethods.ForEach(testMethod => {
                try
                {
                    SetUp();
                    testMethod();
                    OnSucceedTest(testMethod);
                }
                catch (Exception e)
                {
                    OnFailedTest(testMethod);
                    _logger.Error(e.Message);
                }
                CleanUp();
            });
        }
Beispiel #2
0
 private void  Log <T>(string message)
 {
     _loggers.ForEach(
         logType => logType is T,
         logType => logType.Log(this,
                                _sourceClass + ": " + message)
         );
 }
        public void ExecuteSuites()
        {
            IMCollection <ITestSuite> suites = GetTestSuites();

            PrepareSuite(statisticsService => {
                suites.ForEach(suite => {
                    RunSuite(suite, statisticsService);
                });
            });
        }
Beispiel #4
0
        public IMCollection <Group> Insert(IMCollection <Group> groups)
        {
            IMCollection <Group> insertedPermissions = new MCollection <Group>();

            groups.ForEach(group =>
            {
                int groupId = Insert(group);
                insertedPermissions.Add(new Group()
                {
                    Id = groupId, Description = group.Description, Permissions = group.Permissions
                });
            });
            return(insertedPermissions);
        }
Beispiel #5
0
        public IMCollection <Permission> Insert(IMCollection <Permission> permissions)
        {
            IMCollection <Permission> insertedPermissions = new MCollection <Permission>();

            permissions.ForEach(permission =>
            {
                int permissionId = Insert(permission);
                insertedPermissions.Add(new Permission
                {
                    Id = permissionId, Description = permission.Description
                });
            });
            return(insertedPermissions);
        }
        public IMCollection <ITestSuite> GetTestsByConfiguration()
        {
            IMCollection <ITestSuite> suites = new MCollection <ITestSuite>();

            _configuration.ForEach(suiteName => {
                try {
                    Type type = Type.GetType(suiteName);
                    suites.Add((ITestSuite)Activator.CreateInstance(type));
                } catch {
                    _logger.Error("TestSuite [" + suiteName + "] Not found");
                }
            });
            return(suites);
        }
Beispiel #7
0
        private void InsertPermissionsRelationship(IMCollection <Permission> permissions, int groupId)
        {
            permissions.ForEach(permission =>
            {
                const string queryGroupPermission = "INSERT INTO group_permission (group_id, permission_id) " +
                                                    "VALUES (@GROUP_ID, @PERMISSION_ID)";

                Database.ExecuteSimpleInsert(queryGroupPermission, (command, newParameter) =>
                {
                    command.Parameters.Add(newParameter("@GROUP_ID", DbType.Int32));
                    command.Parameters["@GROUP_ID"].Value = groupId;
                    command.Parameters.Add(newParameter("@PERMISSION_ID", DbType.Int32));
                    command.Parameters["@PERMISSION_ID"].Value = permission.Id;
                });
            }
                                );
        }
Beispiel #8
0
        private void InsertGroupsRelationship(IMCollection <Group> groups, int userId)
        {
            groups.ForEach(group =>
            {
                const string queryGroupPermission = "INSERT INTO user_group (user_id, group_id) " +
                                                    "VALUES (@USER_ID, @GROUP_ID)";

                Database.ExecuteSimpleInsert(queryGroupPermission, (command, newParameter) =>
                {
                    command.Parameters.Add(newParameter("@USER_ID", DbType.Int32));
                    command.Parameters["@USER_ID"].Value = userId;
                    command.Parameters.Add(newParameter("@GROUP_ID", DbType.Int32));
                    command.Parameters["@GROUP_ID"].Value = group.Id;
                });
            }
                           );
        }
Beispiel #9
0
        public IMCollection <TEntity> Transform()
        {
            IMCollection <TEntity> resultObjects = new MCollection <TEntity>();

            _dbRows.ForEach(row =>
            {
                TEntity entity = new TEntity();

                row.Columns.ForEach(column =>
                {
                    string columnName = column.Name?.ToLower();

                    if (column.Value == DBNull.Value)
                    {
                        return;
                    }

                    if (Predefined.Like(columnName, "%_id"))
                    {
                        //Getting relationship instance
                        PropertyInfo entityRelationshipInfo = GetPrivatePropertyInfo(typeof(TEntity), columnName?.Split("_id")[0]);
                        object entityRelationshipInstance   = entityRelationshipInfo.GetValue(entity);

                        //Setting up relationship id
                        PropertyInfo entityRelationshipIdInfo = GetPrivatePropertyInfo(entityRelationshipInstance.GetType(), "id");
                        entityRelationshipIdInfo?.SetValue(entityRelationshipInstance, Convert.ChangeType(column.Value, column.Type));
                    }
                    else
                    {
                        columnName = columnName?.Replace("_", "");
                        PropertyInfo propertyInfo = GetPrivatePropertyInfo(typeof(TEntity), columnName);
                        propertyInfo?.SetValue(entity, Convert.ChangeType(column.Value, column.Type));
                    }
                });

                resultObjects.Add(entity);
            });

            return(resultObjects);
        }
Beispiel #10
0
 public void Log(string message)
 {
     _printers.ForEach(printer => printer.Print(message));
 }