Ejemplo n.º 1
0
        public void HandlesShortDirectoryName()
        {
            var testFile = @"C:\Somewhere.txt";
            var result = mocks.StrictMock<IIntegrationResult>();
            SetupResult.For(result.WorkingDirectory).Return(@"C:\OnceUponATime\InALandFarFarWayFromHere\ThereLivedABeautifulPrincess");
            var fileSystem = mocks.StrictMock<IFileSystem>();
            Expect.Call(fileSystem.FileExists(testFile)).Return(true);
            var inputStream = new MemoryStream(Encoding.UTF8.GetBytes("This is some test data"));
            Expect.Call(fileSystem.GetFileLength(testFile)).Return(inputStream.Length);
            Expect.Call(fileSystem.OpenInputStream(testFile)).Return(inputStream);
            Expect.Call(fileSystem.GetLastWriteTime(testFile)).Return(System.DateTime.Now);

            var file = new PackageFile(testFile);
            file.FileSystem = fileSystem;
            var outputStream = mocks.DynamicMock<ZipOutputStream>();

            mocks.ReplayAll();
            file.Package(result, outputStream);
            mocks.VerifyAll();
        }
 private void AssertFilesAreTheSame(PackageFile expected, object actual)
 {
     Assert.IsInstanceOf<PackageFile>(actual);
     var actualFile = actual as PackageFile;
     Assert.AreEqual(expected.SourceFile, actualFile.SourceFile);
     Assert.AreEqual(expected.TargetFileName, actualFile.TargetFileName);
     Assert.AreEqual(expected.TargetFolder, actualFile.TargetFolder);
 }