コード例 #1
0
        public Task <List <FeatureEvidence> > Execute()
        {
            return(projectRunnerTask.ContinueWith(task =>
            {
                BadInputCheckEvidence.Feature = Feature.BadInputCheck;
                BadInputCheckEvidence.HelperMessage = messages.BadInputCheck;

                if (!task.Result.All(evidence => evidence.Passed))
                {
                    BadInputCheckEvidence.SetInconclusive(new SimpleEvidenceBuilder("Project failed to run, unable to perform check."));
                    return new List <FeatureEvidence> {
                        BadInputCheckEvidence
                    };
                }

                var port = portTask.Result;

                if (string.IsNullOrEmpty(port))
                {
                    BadInputCheckEvidence.SetInconclusive(new SimpleEvidenceBuilder(messages.BadPort));
                    return new List <FeatureEvidence> {
                        BadInputCheckEvidence
                    };
                }

                try
                {
                    var fetcher = new HTMLFetcher(port);
                    var htmlCode = fetcher.GetHTMLCodeAsString();

                    actions = BackEndHelperFunctions.GetListOfActions(htmlCode, "value=\"", "\"");

                    badInputs = new Dictionary <string, string>
                    {
                        { "Empty input", " " },
                        { "Blank lines at the start", "\n10" },
                        { "Blank lines at the middle", "10 \n\n 10" },
                        { "Blank lines at the end", "10 \n\n" },
                        { "Not numbers", "Y..@" }
                    };

                    BadInputBoolResults = new List <bool>();

                    var badInputResults = fetcher.GetBadInputs(badInputs, actions[0]);

                    if (BadInputsAreFixed(badInputResults))
                    {
                        BadInputCheckEvidence.SetPassed(new SimpleEvidenceBuilder(badInputResultsOutput.ToString()));
                    }
                    else
                    {
                        BadInputCheckEvidence.SetFailed(new SimpleEvidenceBuilder(badInputResultsOutput.ToString()));
                    }

                    BadInputCheckEvidence.FeatureRating = GetBadInputCheckRating();
                }
                catch (Exception)
                {
                    BadInputCheckEvidence.SetInconclusive(new SimpleEvidenceBuilder(badInputResultsOutput.ToString()));
                }

                return new List <FeatureEvidence> {
                    BadInputCheckEvidence
                };
            }, TaskContinuationOptions.OnlyOnRanToCompletion));
        }
コード例 #2
0
        public Task <List <FeatureEvidence> > Execute()
        {
            return(projectRunnerTask.ContinueWith(task =>
            {
                UnitConverterCheckEvidence.Feature = Feature.UnitConverterCheck;
                UnitConverterCheckEvidence.HelperMessage = messages.UnitConverterCheck;

                if (!task.Result.All(evidence => evidence.Passed))
                {
                    UnitConverterCheckEvidence.SetInconclusive(new SimpleEvidenceBuilder("Project failed to run, unable to perform check."));
                    return new List <FeatureEvidence> {
                        UnitConverterCheckEvidence
                    };
                }

                var port = this.portTask.Result;

                if (string.IsNullOrEmpty(port))
                {
                    UnitConverterCheckEvidence.SetInconclusive(new SimpleEvidenceBuilder(messages.BadPort));
                    return new List <FeatureEvidence> {
                        UnitConverterCheckEvidence
                    };
                }

                try
                {
                    var fetcher = new HTMLFetcher(port);

                    var htmlCode = fetcher.GetHTMLCodeAsString();
                    InitializeDataStructures(htmlCode);
                    actual = fetcher.GetActualValues(texts, actions);

                    if (actions.Count == 0)
                    {
                        UnitConverterCheckEvidence.SetInconclusive(new SimpleEvidenceBuilder("Couldn't execute the unit conversion because of UI changes"));
                    }

                    else
                    {
                        if (OutputsAreEqual())
                        {
                            UnitConverterCheckEvidence.SetPassed(new SimpleEvidenceBuilder(unitConverterResultsOutput.ToString()));
                        }
                        else
                        {
                            UnitConverterCheckEvidence.SetFailed(new SimpleEvidenceBuilder(unitConverterResultsOutput.ToString()));
                        }
                    }
                    UnitConverterCheckEvidence.FeatureRating = GetUnitConverterCheckRating();
                }
                catch (Exception)
                {
                    UnitConverterCheckEvidence.SetInconclusive(new SimpleEvidenceBuilder("Could not check this feature"));
                }

                return new List <FeatureEvidence> {
                    UnitConverterCheckEvidence
                };
            }, TaskContinuationOptions.OnlyOnRanToCompletion));
        }