コード例 #1
0
                public void Should_Throw_If_Context_Is_Null()
                {
                    // Given, When
                    var result = Record.Exception(() =>
                                                  FileExtensions.CopyFiles(null, "", "./target"));

                    // Then
                    Assert.IsType <ArgumentNullException>(result);
                    Assert.Equal("context", ((ArgumentNullException)result).ParamName);
                }
コード例 #2
0
                public void Should_Copy_Files()
                {
                    // Given
                    var fixture = new FileCopyFixture();

                    // When
                    FileExtensions.CopyFiles(fixture.Context, "*", "./target");

                    // Then
                    fixture.TargetFiles[0].Received(1).Copy(Arg.Any <FilePath>(), true);
                    fixture.TargetFiles[1].Received(1).Copy(Arg.Any <FilePath>(), true);
                }
コード例 #3
0
                public void Should_Throw_If_Target_Directory_Path_Is_Null()
                {
                    // Given
                    var fixture = new FileCopyFixture();

                    // When
                    var result = Record.Exception(() =>
                                                  FileExtensions.CopyFiles(fixture.Context, "", null));

                    // Then
                    Assert.IsType <ArgumentNullException>(result);
                    Assert.Equal("targetDirectoryPath", ((ArgumentNullException)result).ParamName);
                }
コード例 #4
0
                public void Should_Throw_If_Glob_Expression_Is_Null()
                {
                    // Given
                    var fixture = new FileCopyFixture();

                    // When
                    var result = Record.Exception(() =>
                                                  FileExtensions.CopyFiles(fixture.Context, (string)null, "./target"));

                    // Then
                    Assert.IsType <ArgumentNullException>(result);
                    Assert.Equal("pattern", ((ArgumentNullException)result).ParamName);
                }
コード例 #5
0
                public void Should_Copy_Files()
                {
                    // Given
                    var fixture   = new FileCopyFixture();
                    var filePaths = fixture.SourceFilePaths.Select(x => x.FullPath);

                    // When
                    FileExtensions.CopyFiles(fixture.Context, filePaths, "./target");

                    // Then
                    fixture.TargetFiles[0].Received(1).Copy(Arg.Any <FilePath>(), true);
                    fixture.TargetFiles[1].Received(1).Copy(Arg.Any <FilePath>(), true);
                }
コード例 #6
0
                public void Should_Throw_If_File_Paths_Are_Null()
                {
                    // Given
                    var context = Substitute.For <ICakeContext>();

                    // When
                    var result = Record.Exception(() =>
                                                  FileExtensions.CopyFiles(context, (IEnumerable <string>)null, "./target"));

                    // Then
                    Assert.IsType <ArgumentNullException>(result);
                    Assert.Equal("filePaths", ((ArgumentNullException)result).ParamName);
                }
コード例 #7
0
                public void Should_Throw_If_Context_Is_Null()
                {
                    // Given
                    var fixture   = new FileCopyFixture();
                    var filePaths = fixture.SourceFilePaths.Select(x => x.FullPath);

                    // When
                    var result = Record.Exception(() =>
                                                  FileExtensions.CopyFiles(null, filePaths, "./target"));

                    // Then
                    Assert.IsType <ArgumentNullException>(result);
                    Assert.Equal("context", ((ArgumentNullException)result).ParamName);
                }
コード例 #8
0
                public void Should_Throw_If_Any_File_Do_Not_Exist()
                {
                    // Given
                    var fixture = new FileCopyFixture();

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

                    // When
                    var result = Record.Exception(() =>
                                                  FileExtensions.CopyFiles(fixture.Context, "*", "./target"));

                    // Then
                    Assert.IsType <FileNotFoundException>(result);
                    Assert.Equal("The file '/Working/file2.txt' do not exist.", result.Message);
                }
コード例 #9
0
                public void Should_Throw_If_Any_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(() =>
                                                  FileExtensions.CopyFiles(fixture.Context, "*", "./target"));

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