コード例 #1
0
        public void GetFunctionTemplateWithParams()
        {
            var r = GenericPresentationHelpers.GetFuncTemplate(
                new ChallengeSet <string[]>(
                    Guid.NewGuid(), "a", "b", this.intAndString, new Challenge <string[]>[] { }));

            r.Should().BeEquivalentTo("string[] Main(int i, string s) { return ... ; }");
        }
コード例 #2
0
        public void GetFunctionTemplateNoParams()
        {
            var r = GenericPresentationHelpers.GetFuncTemplate(
                new ChallengeSet <string[]>(
                    Guid.NewGuid(), "a", "b", Array.Empty <ParamDescription>(), new Challenge <string[]>[] { }));

            r.Should().BeEquivalentTo("string[] Main() { return ... ; }");
        }
コード例 #3
0
        public void DealWithStringArrayResponses()
        {
            var r = GenericPresentationHelpers.DisplayFunction(
                new Challenge <string[]>(new object[] { 1, "a" }, new[] { "a", "b" }),
                this.intAndString,
                typeof(string[]));

            r.Should().BeEquivalentTo("(1, \"a\") => [\"a\", \"b\"]");
        }
コード例 #4
0
        public void DealWithIntArrayNullResponses()
        {
            var r = GenericPresentationHelpers.DisplayFunction(
                new Challenge <int[]>(new object[] { 1, "a" }, null),
                this.intAndString,
                typeof(int[]));

            r.Should().BeEquivalentTo("(1, \"a\") => null");
        }
コード例 #5
0
        public void DealWithBasicExample()
        {
            var r = GenericPresentationHelpers.DisplayFunction(
                new Challenge <string>(new object[] { 1, "a" }, "hello"),
                this.intAndString,
                typeof(string));

            r.Should().BeEquivalentTo("(1, \"a\") => \"hello\"");
        }
コード例 #6
0
 public ChallengeSetDto Map(IChallengeSet cs)
 {
     return(new ChallengeSetDto(
                cs.Id,
                cs.Title,
                cs.Description,
                GenericPresentationHelpers.GetAlias(cs.ReturnType),
                cs.Params.Select(
                    a => new ParamsDescriptionDto(GenericPresentationHelpers.GetAlias(a.Type), a.SuggestedName))
                .ToArray(),
                cs.Challenges.Select(
                    a => new ChallengeDto(
                        a.Args.Select(b => b.ToString()).ToArray(),
                        GenericPresentationHelpers.WrapIfArray(a.ExpectedResult, cs.ReturnType))).ToArray()));
 }