Merge lp:~donaldw/dbversion/verify-feature into lp:dbversion

Proposed by Donald Walker
Status: Merged
Merged at revision: 54
Proposed branch: lp:~donaldw/dbversion/verify-feature
Merge into: lp:dbversion
Diff against target: 913 lines (+607/-183)
8 files modified
src/DatabaseVersion.Console.Tests/Command/Create/CreateCommandTests.cs (+5/-5)
src/DatabaseVersion.Console.Tests/Command/Verify/VerifyCommandTests.cs (+373/-0)
src/DatabaseVersion.Console.Tests/dbversion.Console.Tests.csproj (+65/-70)
src/DatabaseVersion.Console/Command/Create/CreateCommand.cs (+9/-1)
src/DatabaseVersion.Console/Command/Verify/VerifyCommand.cs (+42/-0)
src/DatabaseVersion.Console/dbversion.Console.csproj (+97/-100)
src/DatabaseVersion/DatabaseCreator.cs (+15/-6)
src/DatabaseVersion/IDatabaseCreator.cs (+1/-1)
To merge this branch: bzr merge lp:~donaldw/dbversion/verify-feature
Reviewer Review Type Date Requested Status
Adam Connelly Pending
Review via email: mp+156968@code.launchpad.net

Description of the change

Changes for bug #1163901

To post a comment you must log in.
Revision history for this message
Adam Connelly (adam-rpconnelly) wrote :

Hey Donald, did you forget to commit some files like the new command? Can't seem to see them.

lp:~donaldw/dbversion/verify-feature updated
52. By Donald Walker

fix spacing typo

53. By Donald Walker

Add verify command

54. By Donald Walker

Add tests

Revision history for this message
Donald Walker (donaldw) wrote :

> Hey Donald, did you forget to commit some files like the new command? Can't
> seem to see them.

Sorry yes... I've never used bazaar before. I think they're all in now.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/DatabaseVersion.Console.Tests/Command/Create/CreateCommandTests.cs'
2--- src/DatabaseVersion.Console.Tests/Command/Create/CreateCommandTests.cs 2012-08-29 08:38:36 +0000
3+++ src/DatabaseVersion.Console.Tests/Command/Create/CreateCommandTests.cs 2013-04-03 21:06:20 +0000
4@@ -53,7 +53,7 @@
5 command.Execute(new[] { "-a", "myArchive", "-v", "12345" });
6
7 // Assert
8- creator.Verify(c => c.Create(archive.Object, "12345", It.Is<ITaskExecuter>(t => t.GetType() == typeof(ConsoleTaskExecuter))));
9+ creator.Verify(c => c.Create(archive.Object, "12345", It.Is<ITaskExecuter>(t => t.GetType() == typeof(ConsoleTaskExecuter)), It.Is<bool>(t => t)));
10 }
11
12 [Fact]
13@@ -288,7 +288,7 @@
14 var exception = new VersionNotFoundException("12345");
15
16 this.creator.Setup(
17- c => c.Create(It.IsAny<IDatabaseArchive>(), It.IsAny<string>(), It.IsAny<ITaskExecuter>()))
18+ c => c.Create(It.IsAny<IDatabaseArchive>(), It.IsAny<string>(), It.IsAny<ITaskExecuter>(), It.Is<bool>(t => t)))
19 .Throws(exception);
20
21 // Act
22@@ -306,7 +306,7 @@
23 var exception = new VersionNotFoundException("12345");
24
25 this.creator.Setup(
26- c => c.Create(It.IsAny<IDatabaseArchive>(), It.IsAny<string>(), It.IsAny<ITaskExecuter>()))
27+ c => c.Create(It.IsAny<IDatabaseArchive>(), It.IsAny<string>(), It.IsAny<ITaskExecuter>(), It.Is<bool>(t => t)))
28 .Throws(exception);
29
30 // Act
31@@ -324,7 +324,7 @@
32 var exception = new TaskExecutionException("The task failed to execute");
33
34 this.creator.Setup(
35- c => c.Create(It.IsAny<IDatabaseArchive>(), It.IsAny<string>(), It.IsAny<ITaskExecuter>()))
36+ c => c.Create(It.IsAny<IDatabaseArchive>(), It.IsAny<string>(), It.IsAny<ITaskExecuter>(), It.Is<bool>(t => t)))
37 .Throws(exception);
38
39 // Act
40@@ -342,7 +342,7 @@
41 var exception = new TaskExecutionException("The task failed to execute");
42
43 this.creator.Setup(
44- c => c.Create(It.IsAny<IDatabaseArchive>(), It.IsAny<string>(), It.IsAny<ITaskExecuter>()))
45+ c => c.Create(It.IsAny<IDatabaseArchive>(), It.IsAny<string>(), It.IsAny<ITaskExecuter>(), It.Is<bool>(t => t)))
46 .Throws(exception);
47
48 // Act
49
50=== added directory 'src/DatabaseVersion.Console.Tests/Command/Verify'
51=== added file 'src/DatabaseVersion.Console.Tests/Command/Verify/VerifyCommandTests.cs'
52--- src/DatabaseVersion.Console.Tests/Command/Verify/VerifyCommandTests.cs 1970-01-01 00:00:00 +0000
53+++ src/DatabaseVersion.Console.Tests/Command/Verify/VerifyCommandTests.cs 2013-04-03 21:06:20 +0000
54@@ -0,0 +1,373 @@
55+using dbversion.Console.Command.Verify;
56+
57+namespace dbversion.Console.Tests.Command.Create
58+{
59+ using System.Collections.Generic;
60+
61+ using dbversion;
62+ using dbversion.Archives;
63+ using dbversion.Connections;
64+ using dbversion.Console.Command.Create;
65+ using dbversion.Property;
66+ using dbversion.Session;
67+ using dbversion.Settings;
68+ using dbversion.Tasks;
69+ using dbversion.Version;
70+
71+ using Moq;
72+
73+ using Xunit;
74+
75+ public class VerifyCommandTests
76+ {
77+ #region Fields
78+
79+ private readonly Mock<IMessageService> messageService = new Mock<IMessageService>();
80+ private readonly Mock<IPropertyService> propertyService = new Mock<IPropertyService>();
81+ private readonly Mock<IDatabaseCreator> creator = new Mock<IDatabaseCreator>();
82+ private readonly Mock<IDatabaseArchive> archive = new Mock<IDatabaseArchive>();
83+ private readonly Mock<IDatabaseArchiveFactory> archiveFactory = new Mock<IDatabaseArchiveFactory>();
84+ private readonly Mock<ISettingsService> settingsService = new Mock<ISettingsService>();
85+ private readonly Mock<ISavedConnectionService> savedConnectionService = new Mock<ISavedConnectionService>();
86+
87+ #endregion
88+
89+ [Fact]
90+ public void ShouldHaveCorrectCommandName()
91+ {
92+ // Arrange
93+ var command = new VerifyCommand();
94+
95+ // Act
96+ string name = command.Name;
97+
98+ // Assert
99+ Assert.Equal("verify", name);
100+ }
101+
102+ [Fact]
103+ public void ShouldUseDatabaseCreatorToCreateDatabase2()
104+ {
105+ // Arrange
106+ var command = this.VerifyCommand();
107+
108+ // Act
109+ command.Execute(new[] { "-a", "myArchive", "-v", "12345" });
110+
111+ // Assert
112+ creator.Verify(c => c.Create(archive.Object, "12345", It.Is<ITaskExecuter>(t => t.GetType() == typeof(ConsoleTaskExecuter)), It.Is<bool>(t => !t)));
113+ }
114+
115+ [Fact]
116+ public void ShouldPrintMessageIfArchiveIsNotSpecified()
117+ {
118+ // Arrange
119+ var command = this.VerifyCommand();
120+
121+ // Act
122+ command.Execute(new string[] { });
123+
124+ // Assert
125+ messageService.Verify(m => m.WriteLine("Please specify an archive using the -a switch"));
126+ }
127+
128+ [Fact]
129+ public void ShouldPrintMessageIfArchiveIsEmptyString()
130+ {
131+ // Arrange
132+ var command = this.VerifyCommand();
133+
134+ // Act
135+ command.Execute(new[] { "-a", string.Empty });
136+
137+ // Assert
138+ messageService.Verify(m => m.WriteLine("Please specify an archive using the -a switch"));
139+ }
140+
141+ [Fact]
142+ public void ShouldPrintMessageIfArchiveIsNotSupported()
143+ {
144+ // Arrange
145+ var command = this.VerifyCommand();
146+ command.ArchiveFactories = new[] { this.archiveFactory.Object };
147+ this.archiveFactory.Setup(f => f.Create(It.IsAny<string>())).Returns((IDatabaseArchive)null);
148+
149+ // Act
150+ command.Execute(new[] { "-a", "myArchive" });
151+
152+ // Assert
153+ messageService.Verify(m => m.WriteLine("The specified archive is not supported"));
154+ }
155+
156+ #region Connection String Property
157+
158+ [Fact]
159+ public void ShouldSetConnectionStringProperty()
160+ {
161+ // Arrange
162+ var command = this.VerifyCommand();
163+
164+ // Act
165+ command.Execute(new[] { "-a", "myArchive", "-c", "connectionString" });
166+
167+ // Assert
168+ this.propertyService.Verify(
169+ p => p.Add(
170+ new Property { Key = SessionFactoryProvider.ConnectionStringProperty, Value = "connectionString" }));
171+ }
172+
173+ [Fact]
174+ public void ShouldNotSetConnectionStringPropertyIfItIsNullOrEmpty()
175+ {
176+ // Arrange
177+ var command = this.VerifyCommand();
178+
179+ // Act
180+ command.Execute(new[] { "-a", "myArchive" });
181+ command.Execute(new[] { "-a", "myArchive", "-c", string.Empty });
182+
183+ // Assert
184+ this.propertyService.Verify(
185+ p => p.Add(It.Is<Property>(pr => pr.Key == SessionFactoryProvider.ConnectionStringProperty)), Times.Never());
186+ }
187+
188+ #endregion
189+
190+ #region Provider Property
191+
192+ [Fact]
193+ public void ShouldSetProviderProperty()
194+ {
195+ // Arrange
196+ var command = this.VerifyCommand();
197+
198+ // Act
199+ command.Execute(new[] { "-a", "myArchive", "-p", "provider" });
200+
201+ // Assert
202+ this.propertyService.Verify(
203+ p => p.Add(
204+ new Property { Key = SessionFactoryProvider.ProviderProperty, Value = "provider" }));
205+ }
206+
207+ [Fact]
208+ public void ShouldNotSetProviderPropertyIfItIsNullOrEmpty()
209+ {
210+ // Arrange
211+ var command = this.VerifyCommand();
212+
213+ // Act
214+ command.Execute(new[] { "-a", "myArchive" });
215+ command.Execute(new[] { "-a", "myArchive", "-p", string.Empty });
216+
217+ // Assert
218+ this.propertyService.Verify(
219+ p => p.Add(It.Is<Property>(pr => pr.Key == SessionFactoryProvider.ProviderProperty)), Times.Never());
220+ }
221+
222+ #endregion
223+
224+ #region Driver Class Property
225+
226+ [Fact]
227+ public void ShouldSetDriverClassProperty()
228+ {
229+ // Arrange
230+ var command = this.VerifyCommand();
231+
232+ // Act
233+ command.Execute(new[] { "-a", "myArchive", "-d", "driverClass" });
234+
235+ // Assert
236+ this.propertyService.Verify(
237+ p => p.Add(
238+ new Property { Key = SessionFactoryProvider.DriverClassProperty, Value = "driverClass" }));
239+ }
240+
241+ [Fact]
242+ public void ShouldNotSetDriverClassPropertyIfItIsNullOrEmpty()
243+ {
244+ // Arrange
245+ var command = this.VerifyCommand();
246+
247+ // Act
248+ command.Execute(new[] { "-a", "myArchive" });
249+ command.Execute(new[] { "-a", "myArchive", "-d", string.Empty });
250+
251+ // Assert
252+ this.propertyService.Verify(
253+ p => p.Add(It.Is<Property>(pr => pr.Key == SessionFactoryProvider.DriverClassProperty)), Times.Never());
254+ }
255+
256+ #endregion
257+
258+ #region Dialect Property
259+
260+ [Fact]
261+ public void ShouldSetDialectProperty()
262+ {
263+ // Arrange
264+ var command = this.VerifyCommand();
265+
266+ // Act
267+ command.Execute(new[] { "-a", "myArchive", "-l", "dialect" });
268+
269+ // Assert
270+ this.propertyService.Verify(
271+ p => p.Add(
272+ new Property { Key = SessionFactoryProvider.DialectProperty, Value = "dialect" }));
273+ }
274+
275+ [Fact]
276+ public void ShouldNotSetDialectPropertyIfItIsNullOrEmpty()
277+ {
278+ // Arrange
279+ var command = this.VerifyCommand();
280+
281+ // Act
282+ command.Execute(new[] { "-a", "myArchive" });
283+ command.Execute(new[] { "-a", "myArchive", "-l", string.Empty });
284+
285+ // Assert
286+ this.propertyService.Verify(
287+ p => p.Add(It.Is<Property>(pr => pr.Key == SessionFactoryProvider.DialectProperty)), Times.Never());
288+ }
289+
290+ #endregion
291+
292+ [Fact]
293+ public void ShouldSetDefaultPropertyValues()
294+ {
295+ // Arrange
296+ var command = this.VerifyCommand();
297+
298+ // Act
299+ command.Execute(new[] { "-a", "myArchive" });
300+
301+ // Assert
302+ this.propertyService.Verify(p => p.SetDefaultProperties());
303+ }
304+
305+ [Fact]
306+ public void ShouldMergeArchiveProperties()
307+ {
308+ // Arrange
309+ var command = this.VerifyCommand();
310+
311+ var properties = new[] { new Property { Key = "key", Value = "value" }};
312+ archive.Setup(a => a.Properties).Returns(properties);
313+
314+ // Act
315+ command.Execute(new[] { "-a", "myArchive" });
316+
317+ // Assert
318+ this.propertyService.Verify(p => p.Merge(properties));
319+ }
320+
321+ [Fact]
322+ public void ShouldMergePropertiesFromSettings()
323+ {
324+ // Arrange
325+ var command = this.VerifyCommand();
326+
327+ var propertyCollection = new PropertyCollection();
328+ propertyCollection.Properties.Add(new Property { Key = "key", Value = "value" });
329+
330+ settingsService.Setup(s => s.DeSerialize<PropertyCollection>(It.IsAny<string>())).Returns(propertyCollection);
331+
332+ // Act
333+ command.Execute(new[] { "-a", "myArchive" });
334+
335+ // Assert
336+ this.propertyService.Verify(p => p.Merge(propertyCollection.Properties));
337+ }
338+
339+ [Fact]
340+ public void ShouldPrintExceptionMessageIfVersionNotFoundExceptionIsThrownByCreator()
341+ {
342+ // Arrange
343+ var command = this.VerifyCommand();
344+ var exception = new VersionNotFoundException("12345");
345+
346+ this.creator.Setup(
347+ c => c.Create(It.IsAny<IDatabaseArchive>(), It.IsAny<string>(), It.IsAny<ITaskExecuter>(), It.Is<bool>(t => t)))
348+ .Throws(exception);
349+
350+ // Act
351+ command.Execute(new[] { "-a", "myArchive" });
352+
353+ // Assert
354+ this.messageService.Verify(m => m.WriteLine(exception.Message));
355+ }
356+
357+ [Fact]
358+ public void ShouldReturnFalseIfVersionNotFoundExceptionIsThrownByCreator()
359+ {
360+ // Arrange
361+ var command = this.VerifyCommand();
362+ var exception = new VersionNotFoundException("12345");
363+
364+ this.creator.Setup(
365+ c => c.Create(It.IsAny<IDatabaseArchive>(), It.IsAny<string>(), It.IsAny<ITaskExecuter>(), It.Is<bool>(t => t)))
366+ .Throws(exception);
367+
368+ // Act
369+ var result = command.Execute(new[] { "-a", "myArchive" });
370+
371+ // Assert
372+ Assert.False(result);
373+ }
374+
375+ [Fact]
376+ public void ShouldPrintExceptionMessageIfTaskExecutionExceptionIsThrownByCreator()
377+ {
378+ // Arrange
379+ var command = this.VerifyCommand();
380+ var exception = new TaskExecutionException("The task failed to execute");
381+
382+ this.creator.Setup(
383+ c => c.Create(It.IsAny<IDatabaseArchive>(), It.IsAny<string>(), It.IsAny<ITaskExecuter>(), It.Is<bool>(t => t)))
384+ .Throws(exception);
385+
386+ // Act
387+ command.Execute(new[] { "-a", "myArchive" });
388+
389+ // Assert
390+ this.messageService.Verify(m => m.WriteLine(exception.Message));
391+ }
392+
393+ [Fact]
394+ public void ShouldReturnFalseIfTaskExecutionExceptionIsThrownByCreator()
395+ {
396+ // Arrange
397+ var command = this.VerifyCommand();
398+ var exception = new TaskExecutionException("The task failed to execute");
399+
400+ this.creator.Setup(
401+ c => c.Create(It.IsAny<IDatabaseArchive>(), It.IsAny<string>(), It.IsAny<ITaskExecuter>(), It.Is<bool>(t => t)))
402+ .Throws(exception);
403+
404+ // Act
405+ var result = command.Execute(new[] { "-a", "myArchive" });
406+
407+ // Assert
408+ Assert.False(result);
409+ }
410+
411+ private CreateCommand VerifyCommand()
412+ {
413+ var command = new VerifyCommand();
414+ command.Creator = this.creator.Object;
415+ command.ArchiveFactories = new[] { this.archiveFactory.Object };
416+ command.SettingsService = this.settingsService.Object;
417+ command.PropertyService = this.propertyService.Object;
418+ command.MessageService = this.messageService.Object;
419+ command.SavedConnectionService = this.savedConnectionService.Object;
420+
421+ archiveFactory.Setup(f => f.CanCreate("myArchive")).Returns(true);
422+ archiveFactory.Setup(f => f.Create("myArchive")).Returns(archive.Object);
423+
424+ return command;
425+ }
426+ }
427+}
428
429=== modified file 'src/DatabaseVersion.Console.Tests/dbversion.Console.Tests.csproj'
430--- src/DatabaseVersion.Console.Tests/dbversion.Console.Tests.csproj 2011-11-15 21:59:12 +0000
431+++ src/DatabaseVersion.Console.Tests/dbversion.Console.Tests.csproj 2013-04-03 21:06:20 +0000
432@@ -1,71 +1,66 @@
433-<?xml version="1.0" encoding="utf-8"?>
434-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
435- <PropertyGroup>
436- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
437- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
438- <ProductVersion>10.0.0</ProductVersion>
439- <SchemaVersion>2.0</SchemaVersion>
440- <ProjectGuid>{51EE1287-6887-4FE1-B61F-49D40B7940EE}</ProjectGuid>
441- <OutputType>Library</OutputType>
442- <RootNamespace>dbversion.Console.Tests</RootNamespace>
443- <AssemblyName>DatabaseVersion.Console.Tests</AssemblyName>
444- </PropertyGroup>
445- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
446- <DebugSymbols>true</DebugSymbols>
447- <DebugType>full</DebugType>
448- <Optimize>false</Optimize>
449- <OutputPath>bin\Debug</OutputPath>
450- <DefineConstants>DEBUG</DefineConstants>
451- <ErrorReport>prompt</ErrorReport>
452- <WarningLevel>4</WarningLevel>
453- <ConsolePause>false</ConsolePause>
454- </PropertyGroup>
455- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
456- <DebugType>none</DebugType>
457- <Optimize>false</Optimize>
458- <OutputPath>bin\Release</OutputPath>
459- <ErrorReport>prompt</ErrorReport>
460- <WarningLevel>4</WarningLevel>
461- <ConsolePause>false</ConsolePause>
462- </PropertyGroup>
463- <ItemGroup>
464- <Reference Include="System" />
465- <Reference Include="xunit">
466- <HintPath>..\..\tools\xUnit.net\xunit.dll</HintPath>
467- </Reference>
468- <Reference Include="Moq">
469- <HintPath>..\..\tools\Moq\NET40\Moq.dll</HintPath>
470- </Reference>
471- <Reference Include="NHibernate">
472- <HintPath>..\..\lib\FluentNHibernate\NHibernate.dll</HintPath>
473- </Reference>
474- </ItemGroup>
475- <ItemGroup>
476- <Compile Include="AssemblyInfo.cs" />
477- <Compile Include="Command\CommandManagerTests.cs" />
478- <Compile Include="Command\Create\CreateCommandTests.cs" />
479- <Compile Include="Command\Version\DisplayVersionCommandTests.cs" />
480- <Compile Include="Command\Help\HelpCommandTests.cs" />
481- <Compile Include="MessageServiceMock.cs" />
482- <Compile Include="Command\History\HistoryCommandTests.cs" />
483- <Compile Include="Command\SavedConnection\SavedConnectionCommandTests.cs" />
484- </ItemGroup>
485- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
486- <ItemGroup>
487- <Folder Include="Command\" />
488- <Folder Include="Command\Create\" />
489- <Folder Include="Command\Version\" />
490- <Folder Include="Command\Help\" />
491- <Folder Include="Command\History\" />
492- </ItemGroup>
493- <ItemGroup>
494- <ProjectReference Include="..\DatabaseVersion.Console\dbversion.Console.csproj">
495- <Project>{18389508-A214-446A-A166-CFE7DD83DF23}</Project>
496- <Name>dbversion.Console</Name>
497- </ProjectReference>
498- <ProjectReference Include="..\DatabaseVersion\dbversion.csproj">
499- <Project>{694D9BDF-DCE8-4FC6-A416-CE4573F2F00C}</Project>
500- <Name>dbversion</Name>
501- </ProjectReference>
502- </ItemGroup>
503+<?xml version="1.0" encoding="utf-8"?>
504+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
505+ <PropertyGroup>
506+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
507+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
508+ <ProductVersion>10.0.0</ProductVersion>
509+ <SchemaVersion>2.0</SchemaVersion>
510+ <ProjectGuid>{51EE1287-6887-4FE1-B61F-49D40B7940EE}</ProjectGuid>
511+ <OutputType>Library</OutputType>
512+ <RootNamespace>dbversion.Console.Tests</RootNamespace>
513+ <AssemblyName>DatabaseVersion.Console.Tests</AssemblyName>
514+ </PropertyGroup>
515+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
516+ <DebugSymbols>true</DebugSymbols>
517+ <DebugType>full</DebugType>
518+ <Optimize>false</Optimize>
519+ <OutputPath>bin\Debug</OutputPath>
520+ <DefineConstants>DEBUG</DefineConstants>
521+ <ErrorReport>prompt</ErrorReport>
522+ <WarningLevel>4</WarningLevel>
523+ <ConsolePause>false</ConsolePause>
524+ </PropertyGroup>
525+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
526+ <DebugType>none</DebugType>
527+ <Optimize>false</Optimize>
528+ <OutputPath>bin\Release</OutputPath>
529+ <ErrorReport>prompt</ErrorReport>
530+ <WarningLevel>4</WarningLevel>
531+ <ConsolePause>false</ConsolePause>
532+ </PropertyGroup>
533+ <ItemGroup>
534+ <Reference Include="System" />
535+ <Reference Include="xunit">
536+ <HintPath>..\..\tools\xUnit.net\xunit.dll</HintPath>
537+ </Reference>
538+ <Reference Include="Moq">
539+ <HintPath>..\..\tools\Moq\NET40\Moq.dll</HintPath>
540+ </Reference>
541+ <Reference Include="NHibernate">
542+ <HintPath>..\..\lib\FluentNHibernate\NHibernate.dll</HintPath>
543+ </Reference>
544+ </ItemGroup>
545+ <ItemGroup>
546+ <Compile Include="AssemblyInfo.cs" />
547+ <Compile Include="Command\CommandManagerTests.cs" />
548+ <Compile Include="Command\Create\CreateCommandTests.cs" />
549+ <Compile Include="Command\Verify\VerifyCommandTests.cs" />
550+ <Compile Include="Command\Version\DisplayVersionCommandTests.cs" />
551+ <Compile Include="Command\Help\HelpCommandTests.cs" />
552+ <Compile Include="MessageServiceMock.cs" />
553+ <Compile Include="Command\History\HistoryCommandTests.cs" />
554+ <Compile Include="Command\SavedConnection\SavedConnectionCommandTests.cs" />
555+ </ItemGroup>
556+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
557+ <ItemGroup />
558+ <ItemGroup>
559+ <ProjectReference Include="..\DatabaseVersion.Console\dbversion.Console.csproj">
560+ <Project>{18389508-A214-446A-A166-CFE7DD83DF23}</Project>
561+ <Name>dbversion.Console</Name>
562+ </ProjectReference>
563+ <ProjectReference Include="..\DatabaseVersion\dbversion.csproj">
564+ <Project>{694D9BDF-DCE8-4FC6-A416-CE4573F2F00C}</Project>
565+ <Name>dbversion</Name>
566+ </ProjectReference>
567+ </ItemGroup>
568 </Project>
569\ No newline at end of file
570
571=== modified file 'src/DatabaseVersion.Console/Command/Create/CreateCommand.cs'
572--- src/DatabaseVersion.Console/Command/Create/CreateCommand.cs 2012-08-22 09:20:49 +0000
573+++ src/DatabaseVersion.Console/Command/Create/CreateCommand.cs 2013-04-03 21:06:20 +0000
574@@ -56,6 +56,14 @@
575 {
576 get;
577 set;
578+ }
579+
580+ /// <summary>
581+ /// If true, commit the overall transaction. By returning false, the effect of the upgrade can be 'tested'
582+ /// </summary>
583+ protected virtual bool Commit()
584+ {
585+ return true;
586 }
587
588 /// <summary>
589@@ -81,7 +89,7 @@
590
591 try
592 {
593- return this.Creator.Create(archive, arguments.Version, new ConsoleTaskExecuter(MessageService));
594+ return this.Creator.Create(archive, arguments.Version, new ConsoleTaskExecuter(MessageService), Commit());
595 }
596 catch (VersionNotFoundException v)
597 {
598
599=== added directory 'src/DatabaseVersion.Console/Command/Verify'
600=== added file 'src/DatabaseVersion.Console/Command/Verify/VerifyCommand.cs'
601--- src/DatabaseVersion.Console/Command/Verify/VerifyCommand.cs 1970-01-01 00:00:00 +0000
602+++ src/DatabaseVersion.Console/Command/Verify/VerifyCommand.cs 2013-04-03 21:06:20 +0000
603@@ -0,0 +1,42 @@
604+using System;
605+using System.Collections.Generic;
606+using System.ComponentModel.Composition;
607+using System.Linq;
608+using System.Text;
609+using dbversion.Console.Command.Create;
610+
611+namespace dbversion.Console.Command.Verify
612+{
613+ [Export(typeof(IConsoleCommand))]
614+ public class VerifyCommand: CreateCommand
615+ {
616+ public override string Name
617+ {
618+ get
619+ {
620+ return "verify";
621+ }
622+ }
623+
624+ public override string Description
625+ {
626+ get
627+ {
628+ return "Verify a database creation or upgrade using the specified archive.";
629+ }
630+ }
631+
632+ public override string Usage
633+ {
634+ get
635+ {
636+ return "dbversion " + this.Name + " [options]";
637+ }
638+ }
639+
640+ protected override bool Commit()
641+ {
642+ return false;
643+ }
644+ }
645+}
646
647=== modified file 'src/DatabaseVersion.Console/dbversion.Console.csproj'
648--- src/DatabaseVersion.Console/dbversion.Console.csproj 2011-11-15 21:59:12 +0000
649+++ src/DatabaseVersion.Console/dbversion.Console.csproj 2013-04-03 21:06:20 +0000
650@@ -1,106 +1,103 @@
651-<?xml version="1.0" encoding="utf-8"?>
652-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
653- <PropertyGroup>
654- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
655- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
656- <ProductVersion>8.0.30703</ProductVersion>
657- <SchemaVersion>2.0</SchemaVersion>
658- <ProjectGuid>{18389508-A214-446A-A166-CFE7DD83DF23}</ProjectGuid>
659- <OutputType>Exe</OutputType>
660- <AppDesignerFolder>Properties</AppDesignerFolder>
661- <RootNamespace>dbversion.Console</RootNamespace>
662- <AssemblyName>dbversion</AssemblyName>
663- <FileAlignment>512</FileAlignment>
664- </PropertyGroup>
665- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
666- <PlatformTarget>AnyCPU</PlatformTarget>
667- <DebugSymbols>true</DebugSymbols>
668- <DebugType>full</DebugType>
669- <Optimize>false</Optimize>
670- <OutputPath>bin\Debug\</OutputPath>
671- <DefineConstants>DEBUG;TRACE</DefineConstants>
672- <ErrorReport>prompt</ErrorReport>
673- <WarningLevel>4</WarningLevel>
674- <Commandlineparameters>create -a "/Users/adamconnelly/bzr/dbversion/saved-connection/samples/classic-sample"</Commandlineparameters>
675- </PropertyGroup>
676- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
677- <PlatformTarget>AnyCPU</PlatformTarget>
678- <DebugType>pdbonly</DebugType>
679- <Optimize>true</Optimize>
680- <OutputPath>bin\Release\</OutputPath>
681- <DefineConstants>TRACE</DefineConstants>
682- <ErrorReport>prompt</ErrorReport>
683- <WarningLevel>4</WarningLevel>
684- </PropertyGroup>
685- <ItemGroup>
686- <Reference Include="System" />
687- <Reference Include="System.ComponentModel.Composition" />
688- <Reference Include="System.Core" />
689- <Reference Include="System.Xml.Linq" />
690- <Reference Include="Microsoft.CSharp" />
691- <Reference Include="System.Xml" />
692- <Reference Include="CommandLine, Version=1.8.0.0, Culture=neutral, PublicKeyToken=null">
693- <HintPath>..\..\lib\CommandLine\libcmdline\bin\Release\CommandLine.dll</HintPath>
694- </Reference>
695- <Reference Include="System.Data" />
696- <Reference Include="Castle.Core">
697- <HintPath>..\..\lib\FluentNHibernate\Castle.Core.dll</HintPath>
698- </Reference>
699- <Reference Include="NHibernate.ByteCode.Castle">
700- <HintPath>..\..\lib\FluentNHibernate\NHibernate.ByteCode.Castle.dll</HintPath>
701- </Reference>
702- <Reference Include="NHibernate">
703- <HintPath>..\..\lib\FluentNHibernate\NHibernate.dll</HintPath>
704- </Reference>
705- </ItemGroup>
706- <ItemGroup>
707- <Compile Include="ConsoleTaskExecuter.cs" />
708- <Compile Include="Program.cs" />
709- <Compile Include="Properties\AssemblyInfo.cs" />
710- <Compile Include="Command\IConsoleCommand.cs" />
711- <Compile Include="Command\CommandManager.cs" />
712- <Compile Include="Command\Create\CreateCommand.cs" />
713- <Compile Include="Command\ICommandManager.cs" />
714- <Compile Include="..\CommonAssemblyInfo.cs">
715- <Link>Properties\CommonAssemblyInfo.cs</Link>
716- </Compile>
717- <Compile Include="Command\Version\DisplayVersionCommand.cs" />
718- <Compile Include="Command\Help\HelpCommand.cs" />
719- <Compile Include="Command\CommandParameter.cs" />
720- <Compile Include="Command\History\HistoryCommand.cs" />
721- <Compile Include="Command\History\HistoryArguments.cs" />
722- <Compile Include="Command\History\HistoryOrder.cs" />
723- <Compile Include="Command\SavedConnection\SavedConnectionCommand.cs" />
724- <Compile Include="Command\SavedConnection\SavedConnectionArguments.cs" />
725- <Compile Include="Command\ConnectionArguments.cs" />
726- <Compile Include="Command\ConnectionCommandBase.cs" />
727- <Compile Include="Command\Create\CreateArguments.cs" />
728- </ItemGroup>
729- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
730+<?xml version="1.0" encoding="utf-8"?>
731+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
732+ <PropertyGroup>
733+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
734+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
735+ <ProductVersion>8.0.30703</ProductVersion>
736+ <SchemaVersion>2.0</SchemaVersion>
737+ <ProjectGuid>{18389508-A214-446A-A166-CFE7DD83DF23}</ProjectGuid>
738+ <OutputType>Exe</OutputType>
739+ <AppDesignerFolder>Properties</AppDesignerFolder>
740+ <RootNamespace>dbversion.Console</RootNamespace>
741+ <AssemblyName>dbversion</AssemblyName>
742+ <FileAlignment>512</FileAlignment>
743+ </PropertyGroup>
744+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
745+ <PlatformTarget>AnyCPU</PlatformTarget>
746+ <DebugSymbols>true</DebugSymbols>
747+ <DebugType>full</DebugType>
748+ <Optimize>false</Optimize>
749+ <OutputPath>bin\Debug\</OutputPath>
750+ <DefineConstants>DEBUG;TRACE</DefineConstants>
751+ <ErrorReport>prompt</ErrorReport>
752+ <WarningLevel>4</WarningLevel>
753+ <Commandlineparameters>create -a "/Users/adamconnelly/bzr/dbversion/saved-connection/samples/classic-sample"</Commandlineparameters>
754+ </PropertyGroup>
755+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
756+ <PlatformTarget>AnyCPU</PlatformTarget>
757+ <DebugType>pdbonly</DebugType>
758+ <Optimize>true</Optimize>
759+ <OutputPath>bin\Release\</OutputPath>
760+ <DefineConstants>TRACE</DefineConstants>
761+ <ErrorReport>prompt</ErrorReport>
762+ <WarningLevel>4</WarningLevel>
763+ </PropertyGroup>
764+ <ItemGroup>
765+ <Reference Include="System" />
766+ <Reference Include="System.ComponentModel.Composition" />
767+ <Reference Include="System.Core" />
768+ <Reference Include="System.Xml.Linq" />
769+ <Reference Include="Microsoft.CSharp" />
770+ <Reference Include="System.Xml" />
771+ <Reference Include="CommandLine, Version=1.8.0.0, Culture=neutral, PublicKeyToken=null">
772+ <HintPath>..\..\lib\CommandLine\libcmdline\bin\Release\CommandLine.dll</HintPath>
773+ </Reference>
774+ <Reference Include="System.Data" />
775+ <Reference Include="Castle.Core">
776+ <HintPath>..\..\lib\FluentNHibernate\Castle.Core.dll</HintPath>
777+ </Reference>
778+ <Reference Include="NHibernate.ByteCode.Castle">
779+ <HintPath>..\..\lib\FluentNHibernate\NHibernate.ByteCode.Castle.dll</HintPath>
780+ </Reference>
781+ <Reference Include="NHibernate">
782+ <HintPath>..\..\lib\FluentNHibernate\NHibernate.dll</HintPath>
783+ </Reference>
784+ </ItemGroup>
785+ <ItemGroup>
786+ <Compile Include="Command\Verify\VerifyCommand.cs" />
787+ <Compile Include="ConsoleTaskExecuter.cs" />
788+ <Compile Include="Program.cs" />
789+ <Compile Include="Properties\AssemblyInfo.cs" />
790+ <Compile Include="Command\IConsoleCommand.cs" />
791+ <Compile Include="Command\CommandManager.cs" />
792+ <Compile Include="Command\Create\CreateCommand.cs" />
793+ <Compile Include="Command\ICommandManager.cs" />
794+ <Compile Include="..\CommonAssemblyInfo.cs">
795+ <Link>Properties\CommonAssemblyInfo.cs</Link>
796+ </Compile>
797+ <Compile Include="Command\Version\DisplayVersionCommand.cs" />
798+ <Compile Include="Command\Help\HelpCommand.cs" />
799+ <Compile Include="Command\CommandParameter.cs" />
800+ <Compile Include="Command\History\HistoryCommand.cs" />
801+ <Compile Include="Command\History\HistoryArguments.cs" />
802+ <Compile Include="Command\History\HistoryOrder.cs" />
803+ <Compile Include="Command\SavedConnection\SavedConnectionCommand.cs" />
804+ <Compile Include="Command\SavedConnection\SavedConnectionArguments.cs" />
805+ <Compile Include="Command\ConnectionArguments.cs" />
806+ <Compile Include="Command\ConnectionCommandBase.cs" />
807+ <Compile Include="Command\Create\CreateArguments.cs" />
808+ </ItemGroup>
809+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
810 <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
811 Other similar extension points exist, see Microsoft.Common.targets.
812 <Target Name="BeforeBuild">
813 </Target>
814 <Target Name="AfterBuild">
815 </Target>
816- -->
817- <ItemGroup />
818- <ItemGroup>
819- <None Include="App.config" />
820- <None Include="scripts\dbversion" />
821- </ItemGroup>
822- <ItemGroup>
823- <Folder Include="Command\SavedConnection\" />
824- <Folder Include="Command\History\" />
825- <Folder Include="scripts\" />
826- </ItemGroup>
827- <Target Name="AfterBuild">
828- <Copy SourceFiles="scripts\dbversion" DestinationFolder="$(OutputPath)" />
829- </Target>
830- <ItemGroup>
831- <ProjectReference Include="..\DatabaseVersion\dbversion.csproj">
832- <Project>{694D9BDF-DCE8-4FC6-A416-CE4573F2F00C}</Project>
833- <Name>dbversion</Name>
834- </ProjectReference>
835- </ItemGroup>
836-</Project>
837+ -->
838+ <ItemGroup />
839+ <ItemGroup>
840+ <None Include="App.config" />
841+ <None Include="scripts\dbversion" />
842+ </ItemGroup>
843+ <ItemGroup />
844+ <Target Name="AfterBuild">
845+ <Copy SourceFiles="scripts\dbversion" DestinationFolder="$(OutputPath)" />
846+ </Target>
847+ <ItemGroup>
848+ <ProjectReference Include="..\DatabaseVersion\dbversion.csproj">
849+ <Project>{694D9BDF-DCE8-4FC6-A416-CE4573F2F00C}</Project>
850+ <Name>dbversion</Name>
851+ </ProjectReference>
852+ </ItemGroup>
853+</Project>
854\ No newline at end of file
855
856=== modified file 'src/DatabaseVersion/DatabaseCreator.cs'
857--- src/DatabaseVersion/DatabaseCreator.cs 2012-08-22 09:20:49 +0000
858+++ src/DatabaseVersion/DatabaseCreator.cs 2013-04-03 21:06:20 +0000
859@@ -62,9 +62,11 @@
860 MessageService.WriteLine("Starting Database Update");
861 }
862
863- private void LogUpdateComplete()
864+ private void LogUpdateComplete(bool commit)
865 {
866- MessageService.WriteLine(String.Format("Finished Database Update. Time Taken: {0}", DateTime.Now.Subtract(_updateStartTime)));
867+ MessageService.WriteLine(String.Format("{0} Database Update. Time Taken: {1}",
868+ commit ? "Finished" : "Rolled back",
869+ DateTime.Now.Subtract(_updateStartTime)));
870 }
871
872 #endregion
873@@ -80,7 +82,7 @@
874 /// <exception cref="TaskExecutionException">
875 /// Thrown if an error occurs while executing one of the tasks in the archive.
876 /// </exception>
877- public bool Create(IDatabaseArchive archive, string version, ITaskExecuter executer)
878+ public bool Create(IDatabaseArchive archive, string version, ITaskExecuter executer, bool commit)
879 {
880 using (var sessionFactory = this.SessionFactoryProvider.CreateSessionFactory())
881 {
882@@ -131,9 +133,16 @@
883
884 executer.ExecuteTasks(session);
885
886- transaction.Commit();
887-
888- LogUpdateComplete();
889+ if (commit)
890+ {
891+ transaction.Commit();
892+ }
893+ else
894+ {
895+ transaction.Rollback();
896+ }
897+
898+ LogUpdateComplete(commit);
899 }
900 }
901 }
902
903=== modified file 'src/DatabaseVersion/IDatabaseCreator.cs'
904--- src/DatabaseVersion/IDatabaseCreator.cs 2012-08-22 09:20:49 +0000
905+++ src/DatabaseVersion/IDatabaseCreator.cs 2013-04-03 21:06:20 +0000
906@@ -5,7 +5,7 @@
907
908 public interface IDatabaseCreator
909 {
910- bool Create(IDatabaseArchive archive, string version, ITaskExecuter taskExecuter);
911+ bool Create(IDatabaseArchive archive, string version, ITaskExecuter taskExecuter, bool commit);
912 }
913 }
914

Subscribers

People subscribed via source and target branches

to all changes: