Ejemplo n.º 1
0
        public void GetCommandListForFolderTask_SourceDoesNotExists_CreateFolderCommandIsFirst()
        {
            ICommandFactory factory = new MockCommandFactory();
            IFolder         linkTo  = new FakeFolder(@"c:\target\");

            FakeFolder linkFrom = new FakeFolder(@"c:\destination\");

            linkFrom.FolderExistsReturnValue = false;

            ICommandDiscovery discoverer = new CommandDiscovery(factory, (f) => new FakeFile(f), f => new FakeFolder(f));
            List <ICommand>   taskList   = discoverer.GetCommandListForFolderTask(linkTo, linkFrom, false, false);

            MockCommand mockCommand = (MockCommand)taskList[0];

            Assert.AreEqual("CreateFolder", mockCommand.CommandName);
            Assert.AreEqual(mockCommand.ctorParams[0], linkFrom);
        }
Ejemplo n.º 2
0
        public void GetCommandListForFolderTask_TargetDoesNotExist_JustCreateLinkCommandReturned()
        {
            ICommandFactory factory = new MockCommandFactory();
            IFolder         linkTo  = MockRepository.GenerateMock <IFolder>();

            linkTo.Stub(l => l.FolderExists()).Return(false);

            IFolder linkFrom = MockRepository.GenerateMock <IFolder>();

            linkFrom.Stub(l => l.FolderExists()).Return(true);

            ICommandDiscovery discoverer = new CommandDiscovery(factory, null, null);
            List <ICommand>   taskList   = discoverer.GetCommandListForFolderTask(linkTo, linkFrom, false, false);

            Assert.IsTrue(taskList.Count() == 1, "There should be one item in the list");
            Assert.IsTrue(((MockCommand)taskList[0]).CommandName.Equals("CreateLinkCommand"));
        }
Ejemplo n.º 3
0
        public void GetCommandListForFolderTask_TargetExistsNoFiles_DeleteFolderThenCreateLinkReturned()
        {
            ICommandFactory factory = new MockCommandFactory();
            FakeFolder      linkTo  = new FakeFolder()
            {
                FolderExistsReturnValue = true
            };

            FakeFolder linkFrom = new FakeFolder(@"c:\dest\");

            linkFrom.FolderExistsReturnValue = true;

            ICommandDiscovery discoverer = new CommandDiscovery(factory, s => new FakeFile(s), f => new FakeFolder(f));
            List <ICommand>   taskList   = discoverer.GetCommandListForFolderTask(linkTo, linkFrom, true, false);

            Assert.IsTrue(taskList.Count() == 2, "There should be three items in the list");
            Assert.IsTrue(((MockCommand)taskList[0]).CommandName.Equals("DeleteFolderCommand"));
            Assert.IsTrue(((MockCommand)taskList[1]).CommandName.Equals("CreateLinkCommand"));
        }
Ejemplo n.º 4
0
        public void GetCommandListForFolderTask_TargetExistsOneFiles_MoveFileThenDeleteFolderThenCreateLinkReturned()
        {
            ICommandFactory factory = new MockCommandFactory();
            FakeFolder      linkTo  = new FakeFolder();

            linkTo.FileList = new List <IFile> {
                Helpers.CreateStubHelpers.GetIFileStub("1.txt", @"c:\path")
            };
            linkTo.FolderExistsReturnValue = true;

            FakeFolder linkFrom = new FakeFolder(@"c:\dest\");

            linkFrom.FolderExistsReturnValue = true;

            ICommandDiscovery discoverer = new CommandDiscovery(factory, (f) => new FakeFile(f), f => new FakeFolder(f));
            List <ICommand>   taskList   = discoverer.GetCommandListForFolderTask(linkTo, linkFrom, true, false);

            Assert.IsTrue(taskList.Count() == 3, "There should be three items in the list");
            Assert.IsTrue(((MockCommand)taskList[0]).CommandName.Equals("MoveFileCommand"));
            Assert.IsTrue(((MockCommand)taskList[1]).CommandName.Equals("DeleteFolderCommand"));
            Assert.IsTrue(((MockCommand)taskList[2]).CommandName.Equals("CreateLinkCommand"));
        }
        public void GetCommandListForFolderTask_TargetDoesNotExist_JustCreateLinkCommandReturned()
        {
            ICommandFactory factory = new MockCommandFactory();
            IFolder linkTo = MockRepository.GenerateMock<IFolder>();
            linkTo.Stub(l => l.FolderExists()).Return(false);

            IFolder linkFrom = MockRepository.GenerateMock<IFolder>();
            linkFrom.Stub(l => l.FolderExists()).Return(true);

            ICommandDiscovery discoverer = new CommandDiscovery(factory, null, null);
            List<ICommand> taskList = discoverer.GetCommandListForFolderTask(linkTo, linkFrom, false, false);

            Assert.IsTrue(taskList.Count() == 1, "There should be one item in the list");
            Assert.IsTrue(((MockCommand)taskList[0]).CommandName.Equals("CreateLinkCommand"));
        }
        public void GetCommandListForFolderTask_SourceDoesNotExists_CreateFolderCommandIsFirst()
        {
            ICommandFactory factory = new MockCommandFactory();
            IFolder linkTo = new FakeFolder(@"c:\target\");

            FakeFolder linkFrom = new FakeFolder(@"c:\destination\");
            linkFrom.FolderExistsReturnValue = false;

            ICommandDiscovery discoverer = new CommandDiscovery(factory, (f) => new FakeFile(f), f => new FakeFolder(f));
            List<ICommand> taskList = discoverer.GetCommandListForFolderTask(linkTo, linkFrom, false, false);
            
            MockCommand mockCommand = (MockCommand)taskList[0];

            Assert.AreEqual("CreateFolder", mockCommand.CommandName);
            Assert.AreEqual(mockCommand.ctorParams[0], linkFrom);   
        }
        public void GetCommandListForFolderTask_TargetExistsOneFiles_MoveFileThenDeleteFolderThenCreateLinkReturned()
        {
            ICommandFactory factory = new MockCommandFactory();
            FakeFolder linkTo = new FakeFolder();
            linkTo.FileList = new List<IFile> { Helpers.CreateStubHelpers.GetIFileStub("1.txt", @"c:\path") };
            linkTo.FolderExistsReturnValue = true;

            FakeFolder linkFrom = new FakeFolder(@"c:\dest\");
            linkFrom.FolderExistsReturnValue = true;

            ICommandDiscovery discoverer = new CommandDiscovery(factory, (f) => new FakeFile(f), f => new FakeFolder(f));
            List<ICommand> taskList = discoverer.GetCommandListForFolderTask(linkTo, linkFrom, true, false);

            Assert.IsTrue(taskList.Count() == 3, "There should be three items in the list");
            Assert.IsTrue(((MockCommand)taskList[0]).CommandName.Equals("MoveFileCommand"));
            Assert.IsTrue(((MockCommand)taskList[1]).CommandName.Equals("DeleteFolderCommand"));
            Assert.IsTrue(((MockCommand)taskList[2]).CommandName.Equals("CreateLinkCommand"));
        }
        public void GetCommandListForFolderTask_TargetExistsNoFiles_DeleteFolderThenCreateLinkReturned()
        {
            ICommandFactory factory = new MockCommandFactory();
            FakeFolder linkTo = new FakeFolder() { FolderExistsReturnValue = true };
            
            FakeFolder linkFrom = new FakeFolder(@"c:\dest\");
            linkFrom.FolderExistsReturnValue = true;

            ICommandDiscovery discoverer = new CommandDiscovery(factory, s => new FakeFile(s), f => new FakeFolder(f));
            List<ICommand> taskList = discoverer.GetCommandListForFolderTask(linkTo, linkFrom, true, false);

            Assert.IsTrue(taskList.Count() == 2, "There should be three items in the list");
            Assert.IsTrue(((MockCommand)taskList[0]).CommandName.Equals("DeleteFolderCommand"));
            Assert.IsTrue(((MockCommand)taskList[1]).CommandName.Equals("CreateLinkCommand"));
        }