Commit f8c6aae
Changed files (3)
product
application
data
application.tests
product/application/data/SqlFile.cs
@@ -1,4 +1,6 @@
using System;
+using System.Globalization;
+using System.IO;
namespace simple.migrations.Data
{
@@ -6,20 +8,17 @@ namespace simple.migrations.Data
{
public virtual string path { get; set; }
- public virtual int version()
+ public virtual bool is_greater_than(int version)
{
- throw new NotImplementedException();
+ return this.version() > version;
}
- public virtual string name()
+ int version()
{
- throw new NotImplementedException();
+ var info = new FileInfo(path);
+ return (int) Convert.ChangeType(info.Name.Substring(0, info.Name.IndexOf("_")), typeof (int), CultureInfo.InvariantCulture);
}
- public virtual bool is_greater_than(int version)
- {
- throw new NotImplementedException();
- }
static public implicit operator SqlFile(string file_path)
{
product/application.tests/data/SqlFileSpecs.cs
@@ -0,0 +1,32 @@
+using developwithpassion.bdd.contexts;
+using developwithpassion.bdd.harnesses.mbunit;
+using developwithpassion.bdddoc.core;
+using simple.migrations.Data;
+
+namespace tests.data
+{
+ public class SqlFileSpecs
+ {
+ public abstract class concern : observations_for_a_sut_without_a_contract<SqlFile>
+ {
+ after_the_sut_has_been_created a = () =>
+ {
+ sut.path = @"c:\\tmp\scripts\0099_the_gretzky_script.sql";
+ };
+ }
+
+ [Concern(typeof (SqlFile))]
+ public class when_checking_if_a_migration_script_is_greater_than_a_specific_version : concern
+ {
+ it should_return_true_when_it_is = () =>
+ {
+ sut.is_greater_than(98).should_be_true();
+ };
+
+ it should_return_false_when_it_is_not = () =>
+ {
+ sut.is_greater_than(99).should_be_false();
+ };
+ }
+ }
+}
\ No newline at end of file
product/application.tests/application.tests.csproj
@@ -72,6 +72,7 @@
<Compile Include="CommandRegistrySpecs.cs" />
<Compile Include="ConsoleArgumentsSpecs.cs" />
<Compile Include="ConsoleSpecs.cs" />
+ <Compile Include="data\SqlFileSpecs.cs" />
<Compile Include="data\SqlServerDatabaseGatewaySpecs.cs" />
<Compile Include="EmptyTestFixture.cs" />
<Compile Include="helpers\RhinoStubbingExtensions.cs" />