Example #1
0
        public void ShouldThrowExceptionWhenSourceDoesntExist()
        {
            var mockBounce = new Mock<IBounce>();

            var from = Path.GetTempFileName(); //GetTempFileName() creates the file
            var to = Path.GetTempFileName();
            File.Delete(from);
            File.Delete(to);

            Assert.That(File.Exists(from), Is.False, "File " + from + " should not exist");
            Assert.That(File.Exists(to), Is.False, "File " + to + " should not exist");

            var rename = new RenameFile { From = from, To = to };
            Assert.Throws<ArgumentException>(() => rename.Build(mockBounce.Object));
        }
Example #2
0
        public void ShouldRenameFile()
        {
            var mockBounce = new Mock<IBounce>();

            var from = Path.GetTempFileName();
            var to = Path.GetTempFileName();
            File.Delete(to); //GetTempFileName() creates the file

            Assert.That(File.Exists(from), Is.True, "File " + from + " should exist");
            Assert.That(File.Exists(to), Is.False, "File " + to + " should not exist");

            var rename = new RenameFile {From = from, To = to};
            rename.Build(mockBounce.Object);

            Assert.That(File.Exists(from), Is.False, "File " + from + " should not exist");
            Assert.That(File.Exists(to), Is.True, "File " + to + " should exist");
            File.Delete(to);
        }
Example #3
0
        public void ShouldThrowExceptionWhenSourceDoesntExist()
        {
            var mockBounce = new Mock <IBounce>();

            var from = Path.GetTempFileName(); //GetTempFileName() creates the file
            var to   = Path.GetTempFileName();

            File.Delete(from);
            File.Delete(to);

            Assert.That(File.Exists(from), Is.False, "File " + from + " should not exist");
            Assert.That(File.Exists(to), Is.False, "File " + to + " should not exist");

            var rename = new RenameFile {
                From = from, To = to
            };

            Assert.Throws <ArgumentException>(() => rename.Build(mockBounce.Object));
        }
Example #4
0
        public void ShouldRenameFile()
        {
            var mockBounce = new Mock <IBounce>();

            var from = Path.GetTempFileName();
            var to   = Path.GetTempFileName();

            File.Delete(to); //GetTempFileName() creates the file

            Assert.That(File.Exists(from), Is.True, "File " + from + " should exist");
            Assert.That(File.Exists(to), Is.False, "File " + to + " should not exist");

            var rename = new RenameFile {
                From = from, To = to
            };

            rename.Build(mockBounce.Object);

            Assert.That(File.Exists(from), Is.False, "File " + from + " should not exist");
            Assert.That(File.Exists(to), Is.True, "File " + to + " should exist");
            File.Delete(to);
        }