Esempio n. 1
0
            public void Should_Delete_File()
            {
                // Given
                var fixture = new FileDeleteFixture();

                // When
                FileExtensions.DeleteFile(fixture.Context, fixture.Paths[0]);

                // Then
                fixture.Files[0].Received(1).Delete();
            }
Esempio n. 2
0
            public void Should_Make_Relative_File_Path_Absolute()
            {
                // Given
                var fixture = new FileDeleteFixture();

                // When
                FileExtensions.DeleteFile(fixture.Context, "file1.txt");

                // Then
                fixture.FileSystem.Received(1).GetFile(Arg.Is <FilePath>(
                                                           p => p.FullPath == "/Working/file1.txt"));
            }
Esempio n. 3
0
            public void Should_Throw_If_File_Path_Is_Null()
            {
                // Given
                var context = Substitute.For <ICakeContext>();

                // When
                var result = Record.Exception(() =>
                                              FileExtensions.DeleteFile(context, null));

                // Then
                Assert.IsType <ArgumentNullException>(result);
                Assert.Equal("filePath", ((ArgumentNullException)result).ParamName);
            }
Esempio n. 4
0
            public void Should_Throw_If_File_Do_Not_Exist()
            {
                // Given
                var fixture = new FileDeleteFixture();

                // When
                var result = Record.Exception(() =>
                                              FileExtensions.DeleteFile(fixture.Context, "/file.txt"));

                // Then
                Assert.IsType <FileNotFoundException>(result);
                Assert.Equal("The file '/file.txt' do not exist.", result.Message);
            }
Esempio n. 5
0
            public void Should_Throw_If_Context_Is_Null()
            {
                // Given
                var filePath = new FilePath("./file.txt");

                // When
                var result = Record.Exception(() =>
                                              FileExtensions.DeleteFile(null, filePath));

                // Then
                Assert.IsType <ArgumentNullException>(result);
                Assert.Equal("context", ((ArgumentNullException)result).ParamName);
            }