Skip to content

Commit

Permalink
Added Complexity for reflection challenge
Browse files Browse the repository at this point in the history
  • Loading branch information
Massi-Amb committed Feb 12, 2023
1 parent 9431fd6 commit ecc086f
Showing 1 changed file with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,30 @@ public Class Challenge
public int InvokeMethod(int a, int b)
{
}
public int InvokeOverloadMethod(int a, int b, int c)
{
}
public int InvokeProperty(int a)
{
}
}
public class TestClass1
{
public int SumTwoNumbers(int a, int b)
{
public int MyAge {get; set;}
public int TestMethod(int a, int b)
{
return a + b;
}
}
public int TestMethod(int num, int secondNum, int LastNumber)
{
return (num + secondNum) * lastNum;
}
}
}
";
public string? TesttCode { get; set; } = @"
Expand Down Expand Up @@ -57,25 +72,25 @@ public class TestChallenge
string sumResult;
try
{
sumResult = tmp.InvokeMethod(3, 2);
sumResult = tmp.InvokeOverloadMethod(3, 2, 2);
}catch(Exception ex)
{
return (false, ex.ToString() + "" "" + ex.Message);
}
return (sumResult == 5, $""returned: {sumResult} expected: 5"");
return (sumResult == 10, $""returned: {sumResult} expected: 10"");
}
public (bool pass, string message) Test3()
{
var tmp = new Challenge();
string sumResult;
try
{
sumResult = tmp.InvokeMethod(4, 4);
sumResult = tmp.InvokeProperty(21);
}catch(Exception ex)
{
return (false, ex.ToString() + ""/n"" + ex.Message);
}
return (sumResult == 8, $""returned: {sumResult} expected: 8"");
return (sumResult == 21, $""returned: {sumResult} expected: 21"");
}
}
";
Expand All @@ -102,6 +117,6 @@ public class TestChallenge

private Dictionary<string, string> _tags = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) { {"Reflection", "Int"} ,{ "Level", "2" } };
public Dictionary<string, string> Tags { get => _tags; set => _tags = value; }
public bool ShowBlockly { get => true; }
public bool ShowBlockly { get => false; }
}
}

1 comment on commit ecc086f

@Massi-Amb
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added two more methods for calling an overload method and a property using reflection.
Let me know if I am on the right track.

Please sign in to comment.