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 ... ; }"); }
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 ... ; }"); }
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\"]"); }
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"); }
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\""); }
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())); }