예제 #1
0
        /// <summary>
        /// the main processing method.
        /// </summary>
        /// <param name="sysSettings"></param>
        /// <param name="assignmentSettings"></param>
        /// <param name="submitSettings"></param>
        /// <returns></returns>
        public SubmitResult Process(SystemSettings sysSettings, AssignmentSettings assignmentSettings, SubmitSettings submitSettings)
        {
            SubmitResult submitResult = new SubmitResult();

            BatchFileCreator batchfileCreator = new BatchFileCreator(sysSettings, submitSettings, _fileSystem);
            string           buildFilePath    = batchfileCreator.CreateBuildFile();
            string           testFilePath     = batchfileCreator.CreateTestFile();


            submitResult = CompileAssembly(buildFilePath, batchfileCreator.OutputLogPath);
            //in case of an error, directly return
            if (submitResult.Status == SubmitStatusCode.CompilationError)
            {
                return(submitResult);
            }

            //check businessrules
            submitResult = CheckBusinessRules(batchfileCreator.OutputDllPath, assignmentSettings);
            if (submitResult.Status == SubmitStatusCode.ValidationError)
            {
                return(submitResult);
            }

            submitResult = TestAssembly(batchfileCreator.BatchfileTestPath, batchfileCreator.TestLogPath);

            if (submitResult.Status == SubmitStatusCode.TestError)
            {
                return(submitResult);
            }

            submitResult.Status = SubmitStatusCode.Success;

            return(submitResult);
        }
예제 #2
0
        /// <summary>
        /// the main processing method. 
        /// </summary>
        /// <param name="sysSettings"></param>
        /// <param name="assignmentSettings"></param>
        /// <param name="submitSettings"></param>
        /// <returns></returns>
        public SubmitResult Process(SystemSettings sysSettings, AssignmentSettings assignmentSettings, SubmitSettings submitSettings)
        {
            SubmitResult submitResult = new SubmitResult();

            BatchFileCreator batchfileCreator = new BatchFileCreator(sysSettings, submitSettings, _fileSystem);
            string buildFilePath = batchfileCreator.CreateBuildFile();
            string testFilePath = batchfileCreator.CreateTestFile();

            submitResult = CompileAssembly(buildFilePath, batchfileCreator.OutputLogPath);
            //in case of an error, directly return
            if (submitResult.Status == SubmitStatusCode.CompilationError)
            {
                return submitResult;
            }

            //check businessrules
            submitResult = CheckBusinessRules(batchfileCreator.OutputDllPath, assignmentSettings);
            if (submitResult.Status == SubmitStatusCode.ValidationError)
            {
                return submitResult;
            }

            submitResult = TestAssembly(batchfileCreator.BatchfileTestPath, batchfileCreator.TestLogPath);

            if (submitResult.Status == SubmitStatusCode.TestError)
            {
                return submitResult;
            }

            submitResult.Status = SubmitStatusCode.Success;

            return submitResult;
        }
예제 #3
0
 public static AssignmentSettings CreateAssignmentSettings(Assignment assignment, string assignmentName)
 {
     AssignmentSettings assignmentSettings = new AssignmentSettings();
     assignmentSettings.AssignmentId = assignmentName;
     assignmentSettings.ClassnameToImplement = assignment.ClassNameToImplement;
     assignmentSettings.InterfaceNameToImplement = assignment.InterfaceNameToImplement;
     return assignmentSettings;
 }
예제 #4
0
        private ValidationResult CheckBusinessRules(string outputDllPath, AssignmentSettings assignmentSettings)
        {
            ValidationResult submitResult = new ValidationResult();

            //Compilation is successfull. Now check businessrules.
            //check if the assembly is found;
            Type implementedClass = null;

            if (_fileSystem.FileExists(outputDllPath))
            {
                Assembly assembly = _fileSystem.LoadAssembly(outputDllPath);
                //loop through the types in the assembly
                foreach (Type type in assembly.GetTypes())
                {
                    //try to find the class that was implemented
                    if (type.Name.Equals(assignmentSettings.ClassnameToImplement))
                    {
                        implementedClass = type;
                        break;
                    }
                }
            }

            //if the classToImplement cannot be found, return with an error
            if (implementedClass == null)
            {
                submitResult.Status = SubmitStatusCode.ValidationError;
                submitResult.Messages.Add(string.Format("The class to implement ({0}) is not found", assignmentSettings.ClassnameToImplement));
                return(submitResult);
            }

            //check to see if it implements the required interface...
            Type requiredInterface = implementedClass.GetInterface(assignmentSettings.InterfaceNameToImplement);

            if (requiredInterface == null)
            {
                string message = string.Format("The class to implement ({0}) does not implement the required interface {1}", assignmentSettings.ClassnameToImplement, assignmentSettings.InterfaceNameToImplement);
                submitResult.Status = SubmitStatusCode.ValidationError;
                submitResult.Messages.Add(message);
                return(submitResult);
            }

            return(submitResult);
        }
예제 #5
0
        private SubmitResult CheckBusinessRules(string outputDllPath, AssignmentSettings assignmentSettings)
        {
            SubmitResult submitResult = new SubmitResult();

            //Compilation is successfull. Now check businessrules.
            //check if the assembly is found;
            Type implementedClass = null;

            if (_fileSystem.FileExists(outputDllPath))
            {
                Assembly assembly = _fileSystem.LoadAssembly(outputDllPath);
                //loop through the types in the assembly
                foreach (Type type in assembly.GetTypes())
                {
                    //try to find the class that was implemented
                    if (type.Name.Equals(assignmentSettings.ClassnameToImplement))
                    {
                        implementedClass = type;
                        break;
                    }
                }
            }

            //if the classToImplement cannot be found, return with an error
            if (implementedClass == null)
            {
                submitResult.Status = SubmitStatusCode.ValidationError;
                submitResult.Messages.Add(string.Format("The class to implement ({0}) is not found", assignmentSettings.ClassnameToImplement));
                return submitResult;
            }

            //check to see if it implements the required interface...
            Type requiredInterface = implementedClass.GetInterface(assignmentSettings.InterfaceNameToImplement);
            if (requiredInterface == null)
            {
                string message = string.Format("The class to implement ({0}) does not implement the required interface {1}", assignmentSettings.ClassnameToImplement, assignmentSettings.InterfaceNameToImplement);
                submitResult.Status = SubmitStatusCode.ValidationError;
                submitResult.Messages.Add(message);
                return submitResult;
            }

            return submitResult;
        }