public void TestInit()
 {
     // get a new build manager after each test
     this.versionManagerUnderTest = new BuildVersionManager(ArchivePath);
 }
 public void Ctor_EmptyArchivePath_ThrowsException()
 {
     var target = new BuildVersionManager(string.Empty);
 }
 public void Ctor_ValidPath_AssertDefaults()
 {
     var target = new BuildVersionManager(ArchivePath);
     Assert.IsNull(target.Name);
     Assert.AreEqual(byte.MaxValue, target.MaxArchiveSize);
     Assert.AreEqual(Path.GetFullPath(ArchivePath), target.ArchivePath, true);
 }
        public void Ctor_WithNameAndMaxArchiveSize_PropertiesSet()
        {
            byte maxBuilds = 100;
            string name = "MyBuildManager";

            var target = new BuildVersionManager(
                ArchivePath,
                maxBuilds,
                name);

            var expectedPath = Path.Combine(Path.GetFullPath(ArchivePath), name);
            Assert.AreEqual(expectedPath, target.ArchivePath, true);
            Assert.AreEqual(maxBuilds, target.MaxArchiveSize);
            Assert.AreEqual(name, target.Name, true);
        }
        public void Ctor_ValidName_CorrectPathsWhenLoadingRecentBuild()
        {
            string name = "foo";
            this.versionManagerUnderTest = new BuildVersionManager(ArchivePath, name: name);

            string expectedPath = Path.Combine(
                ArchivePath,
                name,
                this.versionManagerUnderTest.SequenceNumber.ToString(),
                TestAssemblyV1Name);

            this.versionManagerUnderTest.AddNewSuccessfulBuild(TestAssemblyV1Path);
            Build mostRecent = this.versionManagerUnderTest.GetMostRecentBuild();

            Assert.AreEqual(this.versionManagerUnderTest.Name, name);
            Assert.IsNotNull(mostRecent);
            Assert.AreEqual(mostRecent.AssemblyPath, Path.GetFullPath(expectedPath), true);
            Assert.IsTrue(File.Exists(expectedPath));
        }
 public void Ctor_NullArchivePath_ThrowsException()
 {
     var target = new BuildVersionManager(null);
 }
        public void Ctor_NonExistingDirectory_DirectoryCreated()
        {
            var path = Path.Combine(ArchivePath, "test-dir");
            var target = new BuildVersionManager(path);

            Assert.IsTrue(Directory.Exists(path));
            Assert.AreEqual(Path.GetFullPath(path), target.ArchivePath, true);
        }
        public void Ctor_NoNameAndMaxArchiveSize_PropertiesSet()
        {
            byte maxBuilds = 100;
            var target = new BuildVersionManager(ArchivePath, maxBuilds);

            Assert.AreEqual(Path.GetFullPath(ArchivePath), target.ArchivePath, true);
            Assert.AreEqual(maxBuilds, target.MaxArchiveSize);
            Assert.IsNull(target.Name);
        }
 public void Ctor_ExistingFilePath_ThrowsException()
 {
     var target = new BuildVersionManager(TestAssemblyV1Path);
 }