Exemple #1
0
        /// <summary>
        /// Loads test cases.
        /// </summary>
        public async Task LoadAsync(ITfsProjectWorkItemCollection projectworkItemCollection)
        {
            TestCases.Clear();
            var progress = new Progress <ITestCaseViewModel>(testCase => TestCases.Add(testCase));

            await QueryTestCases(projectworkItemCollection, progress);
        }
 protected virtual void OnToggelUnlock()
 {
     if (IsLocked)
     {
         var output = ProblemSpecification.GetCorrectOutput(Password);
         if (output == null)
         {
             StateText = "Failed to unlock!";
             State     = ProblemState.FailedToSolve;
         }
         else
         {
             StateText = "Problem unlocked!";
             State     = ProblemState.Solved;
             TestCases.Clear();
             for (int i = 0; i < ProblemSpecification.TestInput.Length; i++)
             {
                 var tc = new TestCaseViewModel();
                 tc.Input  = ProblemSpecification.TestInput[i];
                 tc.Output = output[i];
                 TestCases.Add(tc);
             }
         }
     }
     else
     {
         StateText = "Problem locked!";
         TestCases.Clear();
         Password = "";
         State    = ProblemState.NotTested;
         IsNew    = false;
     }
 }
            /// <summary>
            /// The init.
            /// </summary>
            /// <param name="currentcontext">
            /// The current context.
            /// </param>
            /// <param name="target">
            /// The target.
            /// </param>
            public override void Init(IContext currentcontext, ITarget target)
            {
                base.Init(currentcontext, target);

                TestCases.Clear();

                TestCases.Add(
                    new TestCase
                {
                    TestName        = TimingTestCase,
                    InjectionString =
                        new[]
                    {
                        "%20and%201%20in%20(select%20SLEEP(10))"
                    },
                    FilterResponseContentType = new[] { "text/html" }
                });

                TestCases.Add(
                    new TestCase
                {
                    TestName        = SqlErrorTestCase,
                    InjectionString =
                        new[]
                    {
                        "%20or%201%20=%201"
                    },
                    FilterResponseContentType = new[] { "text/html" }
                });
            }
        public void SetSolution(TestResult result)
        {
            switch (result.Result)
            {
            case TestResultType.AC:
                string password = ProblemSpecification.GetPassword(result.Output);
                if (password == null)
                {
                    StateText = string.Format("Error in problem file or the probelem have no test cases. Must Be accepted. Time:{0} Memory:{1}", result.ResourceUsage.TimeUsage, result.ResourceUsage.MemoryUsage);
                    State     = ProblemState.FailedToSolve;
                }
                else
                {
                    TestCases.Clear();
                    for (int i = 0; i < ProblemSpecification.TestInput.Length; i++)
                    {
                        var tc = new TestCaseViewModel();
                        tc.Input  = ProblemSpecification.TestInput[i];
                        tc.Output = result.Output[i];
                        TestCases.Add(tc);
                    }
                    Password  = password;
                    State     = ProblemState.Solved;
                    StateText = string.Format("Accepted!! Time:{0} Memory:{1}", result.ResourceUsage.TimeUsage, result.ResourceUsage.MemoryUsage);
                }
                break;

            case TestResultType.WA:
                State     = ProblemState.FailedToSolve;
                StateText = string.Format("Wrong answer on testcase {0}!! Time:{1} Memory:{2}", result.Output.Length, result.ResourceUsage.TimeUsage, result.ResourceUsage.MemoryUsage);
                break;

            case TestResultType.CTE:
                State     = ProblemState.FailedToSolve;
                StateText = string.Format("Compile time error!! compiler output:{0}", result.CompilerOutput);
                break;

            case TestResultType.RTE:
                State     = ProblemState.FailedToSolve;
                StateText = string.Format("Run-time error on testcase {0}!! Time:{1} Memory:{2}", result.Output.Length, result.ResourceUsage.TimeUsage, result.ResourceUsage.MemoryUsage);
                break;

            case TestResultType.TLE:
                State     = ProblemState.FailedToSolve;
                StateText = string.Format("Time limit ecceded on testcase {0}!! Time:{1} Memory:{2}", result.Output.Length, result.ResourceUsage.TimeUsage, result.ResourceUsage.MemoryUsage);
                break;

            case TestResultType.MLE:
                State     = ProblemState.FailedToSolve;
                StateText = string.Format("Memory limit ecceded on testcase {0}!! Time:{1} Memory:{2}", result.Output.Length, result.ResourceUsage.TimeUsage, result.ResourceUsage.MemoryUsage);
                break;

            default:
                break;
            }
        }
Exemple #5
0
        private void Client_UploadValuesCompleted(object sender, UploadValuesCompletedEventArgs e)
        {
            IsSearching = false;
            TestCases.Clear();
            try
            {
                Result = Encoding.UTF8.GetString(e.Result);
            }
            catch (Exception)
            {
                this.ShowMessageEvent?.Invoke(this, "AI engine is not working now! Please try again later.");
                return;
            }

            var testCase = JsonConvert.DeserializeObject <TestCase>(Result);

            TestCases.Add(testCase);
        }