public void GivenTaskBuiltWithValidConfiguration__WhenRunningTask__ShouldCopyPolicyShouldBeCalled()
        {
            MockFileSystem fileSystem = new MockFileSystem(new Dictionary <string, MockFileData>
            {
                { TheSourcePath, string.Empty }
            });
            CopyPolicySpy copyPolicySpy = new CopyPolicySpy();

            CopyTaskBuilder sut = new CopyTaskBuilder(copyPolicySpy, fileSystem);

            ConfigureTask(sut);
            CopyTask task = (CopyTask)sut.Build();

            task.Run();

            Assert.IsTrue(copyPolicySpy.CopyCalled);
        }
Beispiel #2
0
        public void GivenPathToFileAndDestination__WhenCallingRun__ShouldCopyUsingCopyPolicy()
        {
            MockFileSystemWithFileInfoCopySpy fileSystem = new MockFileSystemWithFileInfoCopySpy();
            CopyPolicySpy copyPolicySpy = new CopyPolicySpy();

            fileSystem.FileSystem.AddFile("Data/MyFile.txt", string.Empty);

            const string destination = "Copy/MyFile.txt";

            _sut = new CopyTask(copyPolicySpy, fileSystem)
            {
                Source      = "Data/MyFile.txt",
                Destination = destination
            };

            _sut.Run();

            Assert.IsTrue(copyPolicySpy.CopyCalled);
            Assert.IsFalse(((FileInfoCopySpy)fileSystem.FileInfo.FromFileName("Data/MyFile.txt")).FileWasCopied);
        }
Beispiel #3
0
        public void GivenPathToFileAndCopyDestination__WhenCallingRun__ShouldCreateFileAtDestination()
        {
            AddFile("Data/MyFile.txt", string.Empty);

            const string destination = "Copy/MyFile.txt";

            _sut.Source      = "Data/MyFile.txt";
            _sut.Destination = destination;

            _sut.Run();

            _assertions.AssertFileExists(destination);
        }
 public void CopyFile(string fromPath, string toPath)
 {
     CopyTask t = new CopyTask(fromPath, toPath);
     t.Run();
     this.history.Push(t);
 }