Ejemplo n.º 1
0
                public void Should_Throw_If_Context_Is_Null()
                {
                    // Given, When
                    var result = Record.Exception(() =>
                                                  FileExtensions.MoveFiles(null, "", "./target"));

                    // Then
                    Assert.IsType <ArgumentNullException>(result);
                    Assert.Equal("context", ((ArgumentNullException)result).ParamName);
                }
Ejemplo n.º 2
0
                public void Should_Move_Files()
                {
                    // Given
                    var fixture = new FileCopyFixture();

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

                    // Then
                    fixture.TargetFiles[0].Received(1).Move(Arg.Any <FilePath>());
                    fixture.TargetFiles[1].Received(1).Move(Arg.Any <FilePath>());
                }
Ejemplo n.º 3
0
                public void Should_Throw_If_Target_Directory_Path_Is_Null()
                {
                    // Given
                    var fixture = new FileCopyFixture();

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

                    // Then
                    Assert.IsType <ArgumentNullException>(result);
                    Assert.Equal("targetDirectoryPath", ((ArgumentNullException)result).ParamName);
                }
Ejemplo n.º 4
0
                public void Should_Throw_If_Glob_Expression_Is_Null()
                {
                    // Given
                    var fixture = new FileCopyFixture();

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

                    // Then
                    Assert.IsType <ArgumentNullException>(result);
                    Assert.Equal("pattern", ((ArgumentNullException)result).ParamName);
                }
Ejemplo n.º 5
0
                public void Should_Throw_If_File_Paths_Are_Null()
                {
                    // Given
                    var context = Substitute.For <ICakeContext>();

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

                    // Then
                    Assert.IsType <ArgumentNullException>(result);
                    Assert.Equal("filePaths", ((ArgumentNullException)result).ParamName);
                }
Ejemplo n.º 6
0
                public void Should_Throw_If_Context_Is_Null()
                {
                    // Given
                    var fixture = new FileCopyFixture();

                    // When
                    var result = Record.Exception(() =>
                                                  FileExtensions.MoveFiles(null, fixture.SourceFilePaths, "./target"));

                    // Then
                    Assert.IsType <ArgumentNullException>(result);
                    Assert.Equal("context", ((ArgumentNullException)result).ParamName);
                }
Ejemplo n.º 7
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.MoveFiles(fixture.Context, "*", "./target"));

                    // Then
                    Assert.IsType <FileNotFoundException>(result);
                    Assert.Equal("The file '/Working/file2.txt' do not exist.", result.Message);
                }
Ejemplo n.º 8
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(() =>
                                                  FileExtensions.MoveFiles(fixture.Context, "*", "./target"));

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