Commit 52f365a
Changed files (5)
product
application
application.tests
product/application/ConsoleArguments.cs
@@ -4,14 +4,14 @@ namespace simple.migrations
{
public class ConsoleArguments
{
- string[] arguments;
+ public string[] arguments { get; set; }
- public static implicit operator ConsoleArguments(string[] arguments)
+ static public implicit operator ConsoleArguments(string[] arguments)
{
return new ConsoleArguments {arguments = arguments};
}
- public static implicit operator string[](ConsoleArguments arguments)
+ static public implicit operator string[](ConsoleArguments arguments)
{
return arguments.arguments;
}
@@ -23,9 +23,11 @@ namespace simple.migrations
public virtual string parse_for(string argument_name)
{
- return
- new Regex(@"^-{0}:\'[A-Za-z0-9\]\'$".format_using(argument_name), RegexOptions.Singleline)
- .Match( arguments[0]).Value;
+ var pattern = @"-{0}:'.+?'".format_using(argument_name);
+ var argument = arguments[0];
+ var match = new Regex(pattern, RegexOptions.Singleline).Match(argument);
+ var replace = match.Value.Replace("-{0}:'".format_using(argument_name), "");
+ return replace.Remove(replace.Length - 1, 1);
}
public bool Equals(ConsoleArguments other)
product/application.tests/Properties/AssemblyInfo.cs
@@ -1,5 +1,4 @@
using System.Reflection;
-using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
product/application.tests/ConsoleArgumentsSpecs.cs
@@ -8,22 +8,35 @@ namespace tests
{
public class concern : observations_for_a_sut_without_a_contract<ConsoleArguments>
{
- after_the_sut_has_been_created a = () => { args = controller.sut; };
+ after_the_sut_has_been_created a = () =>
+ {
+ args = controller.sut;
+ };
- protected static ConsoleArguments args;
+ static protected ConsoleArguments args;
}
public class When_parsing_the_value_for_a_console_argument : concern
{
context c = () =>
- {
- arguments = new[] {"-first_param:'c:\\tmp' -second_param:'Server=(local)'"};
- provide_a_basic_sut_constructor_argument(arguments);
- };
+ {
+ arguments = new[] {"-first_param:'c:\\tmp' -second_param:'Server=(local)'"};
+ };
- because b = () => { result = args.parse_for("second_param"); };
+ after_the_sut_has_been_created a = () =>
+ {
+ args.arguments = arguments;
+ };
- it should_return_the_value_specified = () => { result.should_be_equal_to("Server=(local)"); };
+ because b = () =>
+ {
+ result = args.parse_for("second_param");
+ };
+
+ it should_return_the_value_specified = () =>
+ {
+ result.should_be_equal_to("Server=(local)");
+ };
static string result;
static string[] arguments;
product/application.tests/ConsoleSpecs.cs
@@ -10,24 +10,32 @@ namespace tests
{
public abstract class concern : observations_for_a_sut_with_a_contract<Console, ConsoleApplication>
{
- context c = () => { command_registry = controller.the_dependency<CommandRegistry>(); };
+ context c = () =>
+ {
+ command_registry = controller.the_dependency<CommandRegistry>();
+ };
- protected static CommandRegistry command_registry;
+ static protected CommandRegistry command_registry;
}
public class when_processing_a_new_request : concern
{
context c = () =>
- {
- console_arguments = new[] {""};
- correct_command = controller.an<ParameterizedCommand<ConsoleArguments>>();
- command_registry.Stub(x => x.command_for(console_arguments)).Return(correct_command);
- };
+ {
+ console_arguments = new[] {""};
+ correct_command = controller.an<ParameterizedCommand<ConsoleArguments>>();
+ command_registry.Stub(x => x.command_for(console_arguments)).Return(correct_command);
+ };
- because b = () => { controller.sut.run_against(console_arguments); };
+ because b = () =>
+ {
+ controller.sut.run_against(console_arguments);
+ };
- it should_run_the_command_that_can_handle_the_request =
- () => { correct_command.received(x => x.run_against(console_arguments)); };
+ it should_run_the_command_that_can_handle_the_request = () =>
+ {
+ correct_command.received(x => x.run_against(console_arguments));
+ };
static string[] console_arguments;
static ParameterizedCommand<ConsoleArguments> correct_command;
rakefile.rb
@@ -58,8 +58,7 @@ end
task :test, :category_to_exclude, :needs => [:compile] do |t,args|
puts Project.startup_dir
- args.with_defaults(:category_to_exclude => 'SLOW')
- runner = MbUnitRunner.new :compile_target => COMPILE_TARGET, :category_to_exclude => args.category_to_exclude, :show_report => true, :report_type => "text"
+ runner = MbUnitRunner.new :compile_target => COMPILE_TARGET, :category_to_exclude => 'SLOW', :show_report => true, :report_type => "text"
runner.execute_tests ["#{Project.tests_dir}"]
end