Exemplo n.º 1
0
        public void ShouldThrowExceptionWhenSourceDoesntExist()
        {
            var mockBounce = new Mock<IBounce>();

            var from = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
            var to = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());

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

            var rename = new RenameDirectory { From = from, To = to };
            Assert.Throws<ArgumentException>(() => rename.Build(mockBounce.Object));
        }
Exemplo n.º 2
0
        public void ShouldThrowExceptionWhenSourceDoesntExist()
        {
            var mockBounce = new Mock <IBounce>();

            var from = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
            var to   = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());

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

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

            Assert.Throws <ArgumentException>(() => rename.Build(mockBounce.Object));
        }
Exemplo n.º 3
0
        public void ShouldRenameDirectory()
        {
            var mockBounce = new Mock<IBounce>();

            var from = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
            var to = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
            Directory.CreateDirectory(from);

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

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

            Assert.That(Directory.Exists(from), Is.False, "Directory " + from + " should not exist");
            Assert.That(Directory.Exists(to), Is.True, "Directory " + to + " should exist");
            
            Directory.Delete(to);
        }
Exemplo n.º 4
0
        public void ShouldThrowExceptionWhenTargetAlreadyExists()
        {
            var mockBounce = new Mock<IBounce>();

            var from = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
            var to = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
            Directory.CreateDirectory(from);
            Directory.CreateDirectory(to);

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

            var rename = new RenameDirectory { From = from, To = to };
            Assert.Throws<ArgumentException>(() => rename.Build(mockBounce.Object));

            Assert.That(Directory.Exists(from), Is.True, "Directory " + from + " should exist");
            Assert.That(Directory.Exists(to), Is.True, "Directory " + to + " should exist");
            Directory.Delete(from);
            Directory.Delete(to);
        }
Exemplo n.º 5
0
        private void TreeView_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
        {
            var node = e.Node;
            var path = GetPath(node);

            if (e.Label == null)
            {
                return;
            }

            // don't rename the directory if we haven't changed the name
            if (e.Label == node.Name)
            {
                e.CancelEdit = true;
                return;
            }

            RenameDirectory?.Invoke(sender, new RenameDirectoryEventArgs(path, e.Label));

            // let the presenter descide whether it will change the name or not
            e.CancelEdit = true;
        }
Exemplo n.º 6
0
        public void ShouldRenameDirectory()
        {
            var mockBounce = new Mock <IBounce>();

            var from = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
            var to   = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());

            Directory.CreateDirectory(from);

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

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

            rename.Build(mockBounce.Object);

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

            Directory.Delete(to);
        }
Exemplo n.º 7
0
        public void ShouldThrowExceptionWhenTargetAlreadyExists()
        {
            var mockBounce = new Mock <IBounce>();

            var from = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
            var to   = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());

            Directory.CreateDirectory(from);
            Directory.CreateDirectory(to);

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

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

            Assert.Throws <ArgumentException>(() => rename.Build(mockBounce.Object));

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