public async Task <ActionResult <ProblemMetadata> > Create([FromBody] ProblemData data) { IProblemProvider res = await _workspace.Problems.Create(data.Metadata); await res.SetDescription(data.Description); if (data.Samples != null) { foreach (TestCaseData v in data.Samples) { ITestCaseProvider item = await res.Samples.Create(v.Metadata); await UpdateIOData(v, item); } } if (data.Tests != null) { foreach (TestCaseData v in data.Tests) { ITestCaseProvider item = await res.Tests.Create(v.Metadata); await UpdateIOData(v, item); } } return(Created($"problems/{res.Id}", await res.GetMetadata())); }
public async Task <ActionResult <ProblemMetadata> > Import([FromBody] ProblemPackage data) { IProblemProvider res = await _workspace.Problems.Create(data.Metadata); await res.SetDescription(data.Description); if (data.Samples != null) { foreach (ProblemPackage.TestCasePackage v in data.Samples) { ITestCaseProvider item = await res.Samples.Create(v.Metadata); await UpdateIOData(new TestCaseData { Input = v.Input, Output = v.Output }, item); } } if (data.Tests != null) { foreach (ProblemPackage.TestCasePackage v in data.Tests) { ITestCaseProvider item = await res.Tests.Create(v.Metadata); await UpdateIOData(new TestCaseData { Input = v.Input, Output = v.Output }, item); } } return(Created($"problems/{res.Id}", await res.GetMetadata())); }
public new Test BuildFrom(MethodInfo method, Test parentSuite) { ITestCaseProvider testCaseProvider = Host.GetExtensionPoint("TestCaseProviders") as ITestCaseProvider; return(testCaseProvider.HasTestCasesFor(method) ? BuildParameterizedMethodSuite(method, parentSuite) : BuildSingleTestMethod(method, parentSuite, null, this.screenCapture, null)); }
public async Task <ActionResult <TestCaseMetadata> > CreateTest(string id, [FromBody] TestCaseData data) { IProblemProvider res = await _workspace.Problems.Get(id); if (res == null) { return(NotFound()); } ITestCaseProvider item = await res.Tests.Create(data.Metadata); await UpdateIOData(data, item); return(Created($"problems/{res.Id}/tests/{item.Id}", await item.GetMetadata())); }
public async Task <ActionResult> GetTestOutput(string id, string tid) { IProblemProvider res = await _workspace.Problems.Get(id); if (res == null) { return(NotFound()); } ITestCaseProvider item = await res.Tests.Get(tid); if (item == null) { return(NotFound()); } return(File(await item.GetOutput(), "text/plain", $"{tid}.out")); }
public async Task <ActionResult <DataPreview> > GetTestOutputPreview(string id, string tid, int num) { IProblemProvider res = await _workspace.Problems.Get(id); if (res == null) { return(NotFound()); } ITestCaseProvider item = await res.Tests.Get(tid); if (item == null) { return(NotFound()); } return(Ok(await item.GetOutputPreview(num))); }
public TestCaseProviderAutoMoqDataFilterWrapper(ITestCaseProvider testCaseProvider) { if (testCaseProvider == null) { throw new ArgumentNullException("testCaseProvider"); } if (!(testCaseProvider is TestCaseParameterProvider || testCaseProvider is TestCaseSourceProvider)) { throw new ArgumentException( string.Format("Argument must be an instance of {0} or {1}", typeof(TestCaseParameterProvider).FullName, typeof(TestCaseSourceProvider).FullName), "testCaseProvider"); } this._testCaseProvider = testCaseProvider; }
public async Task <ActionResult <TestCaseMetadata> > UpdateTest(string id, string tid, [FromBody] TestCaseData data) { IProblemProvider res = await _workspace.Problems.Get(id); if (res == null) { return(NotFound()); } ITestCaseProvider item = await res.Tests.Get(tid); if (item == null) { return(NotFound()); } await item.SetMetadata(data.Metadata); await UpdateIOData(data, item); return(Accepted()); }
private static async Task UpdateIOData(TestCaseData data, ITestCaseProvider item) { if (data.InputFile != null) { using (Stream s = data.InputFile.OpenReadStream()) await item.SetInput(s); } else { using (Stream ms = TextIO.ToStream(data.Input)) await item.SetInput(ms); } if (data.OutputFile != null) { using (Stream s = data.OutputFile.OpenReadStream()) await item.SetOutput(s); } else { using (Stream ms = TextIO.ToStream(data.Output)) await item.SetOutput(ms); } }
protected BaseDataSourceAttribute(ITestCaseProvider testCaseProvider) { Factory = new TestCaseProviderFactory(testCaseProvider); }
public TestCaseProviderFactory(ITestCaseProvider testCaseProvider) { TestCaseProvider = testCaseProvider; }