Ejemplo n.º 1
0
            public void Should_Move_File()
            {
                // Given
                var fixture = new FileCopyFixture();

                // When
                FileExtensions.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"));
            }
Ejemplo n.º 2
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(() =>
                                              FileExtensions.MoveFile(null, source, target));

                // Then
                Assert.IsType <ArgumentNullException>(result);
                Assert.Equal("context", ((ArgumentNullException)result).ParamName);
            }
Ejemplo 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(() =>
                                              FileExtensions.MoveFile(context, source, null));

                // Then
                Assert.IsType <ArgumentNullException>(result);
                Assert.Equal("targetFilePath", ((ArgumentNullException)result).ParamName);
            }
Ejemplo n.º 4
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(() =>
                                              FileExtensions.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);
            }