public void ShouldUseManifestReaderToCreateDatabaseVersions()
        {
            // Arrange
            this.testDirectory = FileUtil.CreateTempDirectory();
            AssemblyUtil.CopyContentsToDirectory("DatabaseVersion.Tests.TestArchive", testDirectory.FullName);

            DatabaseVersion version1 = new DatabaseVersion(new NumericVersion(1), "_1" + Path.DirectorySeparatorChar + "database.xml", null);
            DatabaseVersion version2 = new DatabaseVersion(new NumericVersion(2), "_2" + Path.DirectorySeparatorChar + "database.xml", null);

            this.manifestReader.Setup(
                m => m.Read(It.IsAny <Stream>(),
                            string.Format("{1}{0}{2}{0}{3}", Path.DirectorySeparatorChar, this.testDirectory.FullName, "_1", "database.xml"),
                            It.IsAny <IDatabaseArchive>()))
            .Returns(version1);
            this.manifestReader.Setup(
                m => m.Read(It.IsAny <Stream>(),
                            string.Format("{1}{0}{2}{0}{3}", Path.DirectorySeparatorChar, this.testDirectory.FullName, "_2", "database.xml"),
                            It.IsAny <IDatabaseArchive>()))
            .Returns(version2);

            FileDatabaseArchive archive = new FileDatabaseArchive(testDirectory.FullName, this.manifestReader.Object);

            // Act
            var versions = archive.Versions;

            // Assert
            Assert.Contains(version1, versions);
            Assert.Contains(version2, versions);
        }
        public void ShouldBeAbleToGetAFileIfItExists()
        {
            // Arrange
            this.testDirectory = FileUtil.CreateTempDirectory();
            AssemblyUtil.CopyContentsToDirectory("DatabaseVersion.Tests.TestArchive", testDirectory.FullName);
            FileDatabaseArchive archive = new FileDatabaseArchive(testDirectory.FullName, this.manifestReader.Object);
            Stream expectedStream       = Assembly.GetExecutingAssembly()
                                          .GetManifestResourceStream("DatabaseVersion.Tests.TestArchive._1.data.authors.sql");

            // Act
            Stream stream = archive.GetFile("_1/data/authors.sql");

            // Assert
            Assert.Equal(StreamToString(expectedStream), StreamToString(stream));
        }
        public void ShouldReturnCorrectNumberOfDatabaseVersions()
        {
            // Arrange
            this.testDirectory = FileUtil.CreateTempDirectory();
            AssemblyUtil.CopyContentsToDirectory("DatabaseVersion.Tests.TestArchive", testDirectory.FullName);

            Mock <IManifestReader> manifestReader = new Mock <IManifestReader>();

            manifestReader.Setup(
                m => m.Read(It.IsAny <Stream>(), It.IsAny <string>(), It.IsAny <IDatabaseArchive>()))
            .Returns(new Mock <IDatabaseVersion>().Object);

            FileDatabaseArchive archive = new FileDatabaseArchive(testDirectory.FullName, manifestReader.Object);

            // Act
            var versions = archive.Versions;

            // Assert
            Assert.Equal(2, versions.Count());
        }