public void ShouldRunBatchFileBeforeRunningTargets() { UnzipSolution(); FileSystemTestHelper.RecreateDirectory(@"BeforeBounceFeature\bounce"); //as there is a circular dependancy between BeforeBounceFeature.sln and the main bounce dll's //this needs to be run and built under the same framework version #if (FRAMEWORKV35) File.WriteAllText(@"BeforeBounceFeature\bounce\beforebounce.bat", @"%SystemRoot%\Microsoft.NET\Framework\v3.5\msbuild.exe BeforeBounceFeature.sln /p:Configuration=Debug_3_5"); #else File.WriteAllText(@"BeforeBounceFeature\bounce\beforebounce.bat", @"%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe BeforeBounceFeature.sln"); #endif var shell = new Shell(new FakeLog()); ProcessOutput output = null; Pushd(@"BeforeBounceFeature", () => { output = shell.Execute(@"..\bounce.exe", "BeforeBounceFeature"); System.Console.WriteLine(output.ErrorAndOutput); }); Assert.That(output, Is.Not.Null); Assert.That(output.ExitCode, Is.EqualTo(0)); Assert.That(output.Error.Trim(), Is.EqualTo("")); Assert.That(output.Output, Is.StringContaining("building before bounce feature")); }
public void ShouldCopyContents() { FileSystemTestHelper.RecreateDirectory("testfrom"); FileSystemTestHelper.RecreateDirectory("testto"); Touch(@"testfrom\one.txt", "one"); Touch(@"testfrom\two.txt", "two"); Touch(@"testfrom\subdir\three.txt", "three"); Touch(@"testfrom\subdir\exclude.txt", "three"); var includes = new string[0]; var excludes = new string[0]; var filterFactory = new Mock <IFileNameFilterFactory>(); var filter = new Mock <IFileNameFilter>(); filterFactory.Setup(ff => ff.CreateFileNameFilter(excludes, includes)).Returns(filter.Object); filter.Setup(f => f.IncludeFile(@"one.txt")).Returns(true); filter.Setup(f => f.IncludeFile(@"two.txt")).Returns(true); filter.Setup(f => f.IncludeFile(@"subdir\three.txt")).Returns(true); filter.Setup(f => f.IncludeFile(@"subdir\exclude.txt")).Returns(false); filter.Setup(f => f.IncludeFile(@"subdir\")).Returns(true); new DirectoryUtils(filterFactory.Object).CopyDirectory("testfrom", "testto", excludes, includes); AssertFileContains(@"testto\one.txt", "one"); AssertFileContains(@"testto\two.txt", "two"); AssertFileContains(@"testto\subdir\three.txt", "three"); Assert.That(File.Exists(@"testto\subdir\exclude.txt"), Is.False); }
public void ShouldPrintOutputOfScriptIfItFailed() { UnzipSolution(); FileSystemTestHelper.RecreateDirectory(@"BeforeBounceFeature\BeforeBounceFeature\bounce"); File.WriteAllText(@"BeforeBounceFeature\BeforeBounceFeature\bounce\beforebounce.bat", @"c:\Windows\Microsoft.NET\Framework\v3.5\msbuild.exe NonExtantSolution.sln"); var shell = new Shell(new FakeLog()); ProcessOutput output = null; Pushd(@"BeforeBounceFeature\BeforeBounceFeature", () => shell.Exec(@"..\..\bounce.exe", "BeforeBounceFeature")); Assert.That(output, Is.Not.Null); Assert.That(output.ExitCode, Is.EqualTo(1)); Assert.That(output.Error, Is.StringContaining("MSBUILD : error MSB1009: Project file does not exist.")); }
public void ShouldDeleteDirectory() { string dir = "test"; FileSystemTestHelper.RecreateDirectory(dir); Assert.That(Directory.Exists(dir)); Touch(@"test\one.txt", "one"); var directoryUtils = new DirectoryUtils(); directoryUtils.DeleteDirectory(dir); Assert.That(!Directory.Exists(dir)); directoryUtils.DeleteDirectory(dir); Assert.That(!Directory.Exists(dir)); }
private void UnzipSolution() { FileSystemTestHelper.RecreateDirectory(@"BeforeBounceFeature"); new DirectoryUtils().CopyDirectory(@"..\..\BeforeBounceFeature", @"BeforeBounceFeature", new string [0], new string [0]); }
private void UnzipSolution() { FileSystemTestHelper.RecreateDirectory(@"BeforeBounceFeature"); new FS.FileSystem().Copy(@"..\..\BeforeBounceFeature", @"BeforeBounceFeature"); }