Exemple #1
0
        async Task <IReadOnlyList <ChallengeResult> > IChallengeSet.GetResults(CompileRunner t)
        {
            var reses = await t.Func(this.Challenges.Select(a => a.Args).ToArray());

            var challRes = reses.Zip(this.Challenges, ValueTuple.Create);

            return(challRes.Select(
                       challenge =>
            {
                var errors = challenge.Item1.Match(
                    success =>
                {
                    var res = success;
                    if (!AreEqual(challenge.Item2.ExpectedResult, res))
                    {
                        return
                        $"Return value incorrect. Expected: {GenericPresentationHelpers.WrapIfArray(challenge.Item2.ExpectedResult, typeof(T))}, Found: {GenericPresentationHelpers.WrapIfArray(res, typeof(T))}";
                    }

                    return null;
                },
                    s => s);
                return new ChallengeResult(errors, challenge.Item2);
            }).ToList());
        }
Exemple #2
0
        async Task <IReadOnlyList <ChallengeResult> > IChallengeSet.GetResults(CompileRunner t)
        {
            var reses = await t.Func(this.Challenges.Select(a => a.Args).ToArray());

            var challRes = reses.Zip(this.Challenges, ValueTuple.Create);

            return(challRes.Select(
                       challenge =>
            {
                var errors = challenge.Item1.Match(
                    success =>
                {
                    if (!EqualityComparer.Equal(challenge.Item2.ExpectedResult, success))
                    {
                        return new Error(
                            "Return value incorrect.", GenericPresentationHelpers.WrapIfArray(success, typeof(T)));
                    }

                    return null;
                },
                    s => new Error(s));
                return new ChallengeResult(errors);
            }).ToList());
        }