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 FileCopyCommand(source, destination);

                Assert.Throws <FileNotFoundException>(() => obj.Act());
            }
        }
        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 FileCopyCommand(source, destination);

                Assert.Throws <IOException>(() => obj.Act());
            }
        }
        public void serialize_whenPathNull()
        {
            var obj = new FileCopyCommand();

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

            if (null == navigator.NameTable)
            {
                Assert.NotNull(navigator.NameTable);
            }
            else
            {
                Assert.True(navigator.Evaluate <bool>(@"1 = count(/file.copy[not(@source)][not(@destination)])"));
            }
        }
        public void op_Act()
        {
            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 FileCopyCommand(source, destination);

                Assert.True(obj.Act());
                Assert.True(obj.Undo);
                Assert.Equal("example", destination.ReadToEnd());
            }
        }
        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 FileCopyCommand(source, destination);

                Assert.True(obj.Act());
                Assert.True(destination.Exists);
                Assert.True(obj.Revert());
                destination.Refresh();
                Assert.False(destination.Exists);
            }
        }
        public void serialize()
        {
            var obj = new FileCopyCommand
            {
                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.copy[@source='C:\from.txt'][@destination='C:\to.txt'][@undo='true'][@unidirectional='false'])"));
            }
        }
        public void serialize_whenPathNull()
        {
            var obj = new FileCopyCommand();

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

            if (null == navigator.NameTable)
            {
                Assert.NotNull(navigator.NameTable);
            }
            else
            {
                Assert.True(navigator.Evaluate<bool>(@"1 = count(/file.copy[not(@source)][not(@destination)])"));
            }
        }
        public void serialize()
        {
            var obj = new FileCopyCommand
                          {
                              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.copy[@source='C:\from.txt'][@destination='C:\to.txt'][@undo='true'][@unidirectional='false'])"));
            }
        }
        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 FileCopyCommand(source, destination, true);

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

                Assert.True(obj.Revert());
                Assert.Equal("example", destination.ReadToEnd());
            }
        }
Example #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 FileCopyCommand(source, destination);

                Assert.True(obj.Act());
                Assert.True(destination.Exists);
                Assert.True(obj.Revert());
                destination.Refresh();
                Assert.False(destination.Exists);
            }
        }
Example #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 FileCopyCommand(source, destination);

                Assert.Throws<FileNotFoundException>(() => obj.Act());
            }
        }
Example #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 FileCopyCommand(source, destination);

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