Exemplo n.º 1
0
            public void Should_Throw_If_Context_Is_Null()
            {
                // Given, When
                var source = new FilePath("./source.txt");
                var target = new FilePath("./target.txt");

                var result = Record.Exception(() =>
                                              FileAliases.MoveFile(null, source, target));

                // Then
                Assert.IsArgumentNullException(result, "context");
            }
Exemplo n.º 2
0
            public void Should_Move_File()
            {
                // Given
                var fixture = new FileCopyFixture();

                // When
                FileAliases.MoveFile(fixture.Context, "./file1.txt", "./target/file1.txt");

                // Then
                fixture.TargetFiles[0].Received(1).Move(
                    Arg.Is <FilePath>(p => p.FullPath == "/Working/target/file1.txt"));
            }
Exemplo n.º 3
0
            public void Should_Throw_If_Target_File_Path_Is_Null()
            {
                // Given
                var context = Substitute.For <ICakeContext>();
                var source  = new FilePath("./source.txt");

                // When
                var result = Record.Exception(() =>
                                              FileAliases.MoveFile(context, source, null));

                // Then
                Assert.IsArgumentNullException(result, "targetFilePath");
            }
Exemplo n.º 4
0
            public void Should_Throw_If_Source_File_Path_Is_Null()
            {
                // Given
                var context = Substitute.For <ICakeContext>();
                var target  = new FilePath("./target.txt");

                // When
                var result = Record.Exception(() =>
                                              FileAliases.MoveFile(context, null, target));

                // Then
                AssertEx.IsArgumentNullException(result, "filePath");
            }
Exemplo n.º 5
0
            public void Should_Throw_If_File_Do_Not_Exist()
            {
                // Given
                var fixture = new FileCopyFixture();

                fixture.TargetFiles[0] = Substitute.For <IFile>();
                fixture.TargetFiles[0].Exists.Returns(false);

                // When
                var result = Record.Exception(() =>
                                              FileAliases.MoveFile(fixture.Context, "./file1.txt", "./target/file1.txt"));

                // Then
                Assert.IsType <FileNotFoundException>(result);
                Assert.Equal("The file '/Working/file1.txt' do not exist.", result.Message);
            }
Exemplo n.º 6
0
            public void Should_Throw_If_Target_Directory_Do_Not_Exist()
            {
                // Given
                var fixture = new FileCopyFixture();

                fixture.TargetDirectory = Substitute.For <IDirectory>();
                fixture.TargetDirectory.Exists.Returns(false);

                // When
                var result = Record.Exception(() =>
                                              FileAliases.MoveFile(fixture.Context, "./file1.txt", "./target/file1.txt"));

                // Then
                Assert.IsType <DirectoryNotFoundException>(result);
                Assert.Equal("The directory '/Working/target' does not exist.", result?.Message);
            }