Skip to content

Instantly share code, notes, and snippets.

@jmarnold
Last active December 19, 2015 22:59
Show Gist options
  • Save jmarnold/6031346 to your computer and use it in GitHub Desktop.
Save jmarnold/6031346 to your computer and use it in GitHub Desktop.
Reflection Kata 1

Reflection Kata 1

  • Level: Beginner
  • Target time: 5 minutes

Setup

Begin by creating a new Console application in Visual Studio called: ReflectionKata1. You will need to create two files:

  1. ReflectionTarget.cs
  2. ReflectionTests.cs

Simply copy the contents of all files (including Program.cs) from their respective companions supplied in this gist.

Beginning form

Replace the body of all methods found in the ReflectionTests class so that the methods perform the instructions described by their name. Use Console.WriteLine() to "print" information as instructed.

Final form

Replace the body of the InvokeAllMethodsOnReflectionTestsClass() method found in the Program class. Once complete, run the application.

public class Program
{
public static void Main(params string[] args)
{
InvokeAllMethodsOnReflectionTestsClass();
Console.WriteLine("Press any key to continue....");
Console.ReadKey();
}
public static void InvokeAllMethodsOnReflectionTestsClass()
{
throw new NotImplementedException();
}
}
public class ReflectionTarget
{
private static int Counter = 0;
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
public void Method1(string a, string b, string c)
{
}
public string Method2(string input)
{
Counter++;
return string.Format("{0} ({1})", input, Counter);
}
private static void reset()
{
Counter = 0;
}
public override string ToString()
{
return string.Format("Name: {0} {1}; Email: {2}", FirstName, LastName, Email);
}
}
public class ReflectionTests
{
public void print_the_name_of_reflection_target()
{
throw new NotImplementedException();
}
public void print_the_full_name_of_reflection_target()
{
throw new NotImplementedException();
}
public void print_the_assembly_qualified_name_of_reflection_target()
{
throw new NotImplementedException();
}
public void print_the_name_of_the_assembly()
{
throw new NotImplementedException();
}
public void print_the_name_of_method1()
{
throw new NotImplementedException();
}
public void print_the_parameter_names_of_method1()
{
throw new NotImplementedException();
}
public void print_the_return_type_of_method1()
{
throw new NotImplementedException();
}
public void invoke_method2_twice_printing_the_return_value_each_time()
{
throw new NotImplementedException();
}
public void reset_the_counter_and_print_the_return_value_of_method2()
{
throw new NotImplementedException();
}
public void print_the_name_and_type_of_each_property()
{
throw new NotImplementedException();
}
public void set_the_value_of_each_property_then_print_the_to_string_value()
{
throw new NotImplementedException();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment