Exemple #1
0
        public IHttpActionResult GetWriteTestSet(int userId)
        {
            var testCreator = new TestCreator(_repositoryFactory);
            var testSet     = testCreator.WriteTest(userId);

            return(Json(testSet));
        }
Exemple #2
0
 private void OnEnable()
 {
     creator = (TestCreator)target;
     if (creator.path == null)
     {
         creator.CreatePath();
     }
     path = creator.path;
 }
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        TestCreator testCreator = (TestCreator)target;

        if (GUILayout.Button("Generate Test"))
        {
            testCreator.CreateBuildings();
        }
    }
        public void UseParamBinderPasses()
        {
            var creator = new TestCreator();

            var bindInfo = new ModelViewBinder.BindInfo("A", "A", "a")
                           .SetUseParamBinder(new ViewObj.ParamBinder(100));
            var paramBinder = creator.GetParamBinder(bindInfo);

            Assert.AreSame(bindInfo.UseParamBinder, paramBinder);
        }
Exemple #5
0
        public void Setup()
        {
            string filePath = "..\\..\\..\\TwoClasses.cs";

            fileCode = File.ReadAllText(filePath);

            generatedTests = TestCreator.Generate(fileCode).Result;

            classOneRoot = CSharpSyntaxTree.ParseText(generatedTests[0].TestCode).GetRoot();
            classTwoRoot = CSharpSyntaxTree.ParseText(generatedTests[1].TestCode).GetRoot();
        }
 public TestManipulator(UnswerManipalatorI unswerManipalator,
                        GoTestQueryConfiguratorI goTestQueryConfigurator,
                        QuestionManipulatorI questionManipulator)
 {
     testloader = new TestLoader(unswerManipalator,
                                 goTestQueryConfigurator, questionManipulator);
     testUpdater = new TestUpdater(unswerManipalator,
                                   goTestQueryConfigurator, questionManipulator);
     testCreator = new TestCreator(unswerManipalator,
                                   goTestQueryConfigurator, questionManipulator);
 }
        public IHttpActionResult GetPickerTestSet(int userId, string testType)
        {
            var testCreator = new TestCreator(_repositoryFactory);
            IEnumerable <PickerTestModel> testSet;

            if (testType == WordLevelManager.TestType.EnRuTest.ToString())
            {
                testSet = testCreator.EnglishRussianTest(userId).ToList();
            }
            else
            {
                testSet = testCreator.RussianEnglishTest(userId).ToList();
            }

            return(Json(testSet));
        }
        public void GetParamBinderPasses()
        {
            var creator = new TestCreator();

            var viewObjAbindInfo = new ModelViewBinder.BindInfo("A", "A", "a");
            var paramBinderA     = creator.GetParamBinder(viewObjAbindInfo);

            Assert.IsTrue(paramBinderA is ViewObj.ParamBinder);
            Assert.AreEqual(1, (paramBinderA as ViewObj.ParamBinder).Value);

            var viewObjBbindInfo = new ModelViewBinder.BindInfo("A", "A", "b");
            var paramBinderB     = creator.GetParamBinder(viewObjBbindInfo);

            Assert.IsTrue(paramBinderB is ViewObj.ParamBinder);
            Assert.AreEqual(-1, (paramBinderB as ViewObj.ParamBinder).Value);

            Assert.Throws <UnityEngine.Assertions.AssertionException>(() =>
            {
                var bindInfo        = new ModelViewBinder.BindInfo("B", "B", "abc");
                var nullParamBinder = creator.GetParamBinder(bindInfo);
            });
        }
        public void CreateViewObjPasses()
        {
            var creator = new TestCreator();

            var viewObjAbindInfo = new ModelViewBinder.BindInfo("A", "A", "a");
            var viewObjA         = creator.CreateViewObj(viewObjAbindInfo);

            Assert.IsTrue(viewObjA is ViewObj);
            Assert.AreEqual(1, (viewObjA as ViewObj).Value);
            Assert.AreSame(viewObjAbindInfo, viewObjA.UseBindInfo);

            var viewObjBbindInfo = new ModelViewBinder.BindInfo("B", "B", "b");
            var viewObjB         = creator.CreateViewObj(viewObjBbindInfo);

            Assert.IsTrue(viewObjB is ViewObj);
            Assert.AreEqual(-1, (viewObjB as ViewObj).Value);
            Assert.AreSame(viewObjBbindInfo, viewObjB.UseBindInfo);

            Assert.Throws <UnityEngine.Assertions.AssertionException>(() =>
            {
                var bindInfo = new ModelViewBinder.BindInfo("B", "__invalid", "b");
                var nullObj  = creator.CreateViewObj(bindInfo);
            });
        }
Exemple #10
0
        public async Task Execute(List <string> filesPath, string outputPath)
        {
            //Блок чтения из файла
            //path,content
            var readingBlock = new TransformBlock <string, string>(
                async FilePath =>
            {
                Console.WriteLine("File path:  " + FilePath);
                using (StreamReader reader = new StreamReader(FilePath))
                {
                    return(await reader.ReadToEndAsync());
                }
            },
                new ExecutionDataflowBlockOptions {
                MaxDegreeOfParallelism = pipelineConfig.MaxReadingTasks
            }
                );


            //Блок создания теста
            //code,tests
            var generateTestClass = new TransformManyBlock <string, TestStructure>(
                async Code =>
            {
                Console.WriteLine("Generating tests... ");
                return(await TestCreator.Generate(Code));
            },
                new ExecutionDataflowBlockOptions {
                MaxDegreeOfParallelism = pipelineConfig.MaxProcessingTasks
            }
                );


            //Блок записи теста в файл
            //TestStructure
            var writeGeneratedFile = new ActionBlock <TestStructure>(
                async testClass =>
            {
                string fullpath = Path.Combine(outputPath, testClass.TestName);
                Console.WriteLine("Fullpath " + fullpath);
                using (StreamWriter writer = new StreamWriter(fullpath))
                {
                    await writer.WriteAsync(testClass.TestCode);
                }
            },
                new ExecutionDataflowBlockOptions {
                MaxDegreeOfParallelism = pipelineConfig.MaxWritingTasks
            }
                );


            //Successful or unsuccessful completion of one block in the pipeline will
            //cause completion of the next block in the pipeline
            var linkOptions = new DataflowLinkOptions {
                PropagateCompletion = true
            };


            readingBlock.LinkTo(generateTestClass, linkOptions);
            generateTestClass.LinkTo(writeGeneratedFile, linkOptions);


            foreach (string path in filesPath)
            {
                readingBlock.Post(path);
            }

            //Mark the head of the pipeline as complete.
            readingBlock.Complete();

            await writeGeneratedFile.Completion;
        }