Commit d594e15
Changed files (4)
product
application
application.tests
product/application/ConsoleArguments.cs
@@ -1,17 +1,14 @@
+using System;
+
namespace simple.migrations
{
public class ConsoleArguments
{
- readonly string[] arguments;
-
- ConsoleArguments(string[] arguments)
- {
- this.arguments = arguments;
- }
+ string[] arguments;
public static implicit operator ConsoleArguments(string[] arguments)
{
- return new ConsoleArguments(arguments);
+ return new ConsoleArguments {arguments = arguments};
}
public static implicit operator string[](ConsoleArguments arguments)
@@ -19,9 +16,14 @@ namespace simple.migrations
return arguments.arguments;
}
- public bool contains(string key)
+ public virtual bool contains(string key)
{
return arguments[0].Contains(key);
}
+
+ public virtual string parse_for(string argument_name)
+ {
+ throw new NotImplementedException();
+ }
}
}
\ No newline at end of file
product/application.tests/application.tests.csproj
@@ -70,6 +70,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="CommandRegistrySpecs.cs" />
+ <Compile Include="ConsoleArgumentsSpecs.cs" />
<Compile Include="ConsoleSpecs.cs" />
<Compile Include="EmptyTestFixture.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
product/application.tests/ConsoleArgumentsSpecs.cs
@@ -0,0 +1,32 @@
+using developwithpassion.bdd.contexts;
+using developwithpassion.bdd.harnesses.mbunit;
+using simple.migrations;
+
+namespace tests
+{
+ public class ConsoleArgumentsSpecs
+ {
+ public class concern : observations_for_a_sut_without_a_contract<ConsoleArguments>
+ {
+ after_the_sut_has_been_created a = () => { args = controller.sut; };
+
+ protected static 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);
+ };
+
+ 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;
+ }
+ }
+}
\ No newline at end of file
product/application.tests/RunMigrationsCommandSpecs.cs
@@ -6,8 +6,11 @@ namespace tests
{
public class RunMigrationsCommandSpecs
{
- public class when_checking_if_the_proper_console_arguments_are_specified_to_run_the_migrations :
- observations_for_a_sut_with_a_contract<ConsoleCommand, RunMigrationsCommand>
+ public class concern : observations_for_a_sut_with_a_contract<ConsoleCommand, RunMigrationsCommand>
+ {
+ }
+
+ public class when_the_proper_arguments_are_specified_to_run_the_database_migrations : concern
{
context c = () =>
{
@@ -16,15 +19,27 @@ namespace tests
{
"-migrations_dir:'c:\\tmp' -connection_string:'Server=(local);Database=test;Integrated Security=True;' -data_provider:'System.Data.SqlClient'"
};
- unknown_arguments = new[] {""};
};
- it should_return_true_when_they_are = () => { sut.can_handle(proper_arguments).should_be_true(); };
+ because b = () => { result = sut.can_handle(proper_arguments); };
- it should_return_false_when_they_are_not = () => { sut.can_handle(unknown_arguments).should_be_false(); };
+ it should_recognize_the_arguments = () => result.should_be_true();
static ConsoleArguments proper_arguments;
+ static bool result;
+ }
+
+ public class when_unknown_arguments_are_specified : concern
+ {
+ context c = () => { unknown_arguments = new[] {""}; };
+
+ because b = () => { result = sut.can_handle(unknown_arguments); };
+
+ it should_not_recognize_the_arguments_to_run_the_database_migrations = () => result.should_be_false();
+
static ConsoleArguments unknown_arguments;
+
+ static bool result;
}
}
}
\ No newline at end of file