Ejemplo n.º 1
0
        public void op_Act_whenSourceMissing()
        {
            using (var temp = new TempDirectory())
            {
                var source      = temp.Info.ToFile("from.txt");
                var destination = temp.Info.ToFile("to.txt");

                var obj = new FileMoveCommand(source, destination);

                Assert.Throws <FileNotFoundException>(() => obj.Act());
            }
        }
Ejemplo n.º 2
0
        public void op_Act_whenDestinationAlreadyExists()
        {
            using (var temp = new TempDirectory())
            {
                var source = temp.Info.ToFile("from.txt");
                source.CreateNew();
                var destination = temp.Info.ToFile("to.txt");
                destination.CreateNew();

                var obj = new FileMoveCommand(source, destination);

                Assert.Throws <IOException>(() => obj.Act());
            }
        }
Ejemplo n.º 3
0
        public void serialize_whenPathNull()
        {
            var obj = new FileMoveCommand();

            var navigator = obj.XmlSerialize().CreateNavigator();

            if (null == navigator.NameTable)
            {
                Assert.NotNull(navigator.NameTable);
            }
            else
            {
                Assert.True(navigator.Evaluate <bool>(@"1 = count(/file.move[not(@source)][not(@destination)])"));
            }
        }
Ejemplo n.º 4
0
        public void op_Revert_whenUnidirectional()
        {
            using (var temp = new TempDirectory())
            {
                var source = temp.Info.ToFile("from.txt");
                source.CreateNew("example");
                var destination = temp.Info.ToFile("to.txt");

                var obj = new FileMoveCommand(source, destination, true);

                Assert.True(obj.Act());
                Assert.False(obj.Undo);

                Assert.True(obj.Revert());
                Assert.Equal("example", destination.ReadToEnd());
            }
        }
Ejemplo n.º 5
0
        public void serialize()
        {
            var obj = new FileMoveCommand
            {
                Source      = @"C:\from.txt",
                Destination = @"C:\to.txt",
                Undo        = true
            };

            var navigator = obj.XmlSerialize().CreateNavigator();

            if (null == navigator.NameTable)
            {
                Assert.NotNull(navigator.NameTable);
            }
            else
            {
                Assert.True(navigator.Evaluate <bool>(@"1 = count(/file.move[@source='C:\from.txt'][@destination='C:\to.txt'][@undo='true'][@unidirectional='false'])"));
            }
        }
Ejemplo n.º 6
0
        public void op_Revert()
        {
            using (var temp = new TempDirectory())
            {
                var source = temp.Info.ToFile("from.txt");
                source.CreateNew("example");
                var destination = temp.Info.ToFile("to.txt");

                var obj = new FileMoveCommand(source, destination);

                Assert.True(obj.Act());
                source.Refresh();
                Assert.False(source.Exists);
                Assert.True(destination.Exists);

                Assert.True(obj.Revert());
                source.Refresh();
                Assert.True(source.Exists);
                destination.Refresh();
                Assert.False(destination.Exists);
            }
        }
Ejemplo n.º 7
0
        public void serialize_whenPathNull()
        {
            var obj = new FileMoveCommand();

            var navigator = obj.XmlSerialize().CreateNavigator();

            if (null == navigator.NameTable)
            {
                Assert.NotNull(navigator.NameTable);
            }
            else
            {
                Assert.True(navigator.Evaluate<bool>(@"1 = count(/file.move[not(@source)][not(@destination)])"));
            }
        }
Ejemplo n.º 8
0
        public void serialize()
        {
            var obj = new FileMoveCommand
                          {
                              Source = @"C:\from.txt",
                              Destination = @"C:\to.txt",
                              Undo = true
                          };

            var navigator = obj.XmlSerialize().CreateNavigator();

            if (null == navigator.NameTable)
            {
                Assert.NotNull(navigator.NameTable);
            }
            else
            {
                Assert.True(navigator.Evaluate<bool>(@"1 = count(/file.move[@source='C:\from.txt'][@destination='C:\to.txt'][@undo='true'][@unidirectional='false'])"));
            }
        }
Ejemplo n.º 9
0
        public void op_Revert_whenUnidirectional()
        {
            using (var temp = new TempDirectory())
            {
                var source = temp.Info.ToFile("from.txt");
                source.CreateNew("example");
                var destination = temp.Info.ToFile("to.txt");

                var obj = new FileMoveCommand(source, destination, true);

                Assert.True(obj.Act());
                Assert.False(obj.Undo);

                Assert.True(obj.Revert());
                Assert.Equal("example", destination.ReadToEnd());
            }
        }
Ejemplo n.º 10
0
        public void op_Revert()
        {
            using (var temp = new TempDirectory())
            {
                var source = temp.Info.ToFile("from.txt");
                source.CreateNew("example");
                var destination = temp.Info.ToFile("to.txt");

                var obj = new FileMoveCommand(source, destination);

                Assert.True(obj.Act());
                source.Refresh();
                Assert.False(source.Exists);
                Assert.True(destination.Exists);

                Assert.True(obj.Revert());
                source.Refresh();
                Assert.True(source.Exists);
                destination.Refresh();
                Assert.False(destination.Exists);
            }
        }
Ejemplo n.º 11
0
        public void op_Act_whenSourceMissing()
        {
            using (var temp = new TempDirectory())
            {
                var source = temp.Info.ToFile("from.txt");
                var destination = temp.Info.ToFile("to.txt");

                var obj = new FileMoveCommand(source, destination);

                Assert.Throws<FileNotFoundException>(() => obj.Act());
            }
        }
Ejemplo n.º 12
0
        public void op_Act_whenDestinationAlreadyExists()
        {
            using (var temp = new TempDirectory())
            {
                var source = temp.Info.ToFile("from.txt");
                source.CreateNew();
                var destination = temp.Info.ToFile("to.txt");
                destination.CreateNew();

                var obj = new FileMoveCommand(source, destination);

                Assert.Throws<IOException>(() => obj.Act());
            }
        }