Esempio n. 1
0
            public void Should_Throw_If_Context_Is_Null()
            {
                // Given, When
                var result = Record.Exception(() => FileAliases.FileSize(null, "some file"));

                // Then
                AssertEx.IsArgumentNullException(result, "context");
            }
Esempio n. 2
0
            public void Should_Throw_If_Path_Is_Null()
            {
                // Given
                var context = Substitute.For <ICakeContext>();

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

                // Then
                AssertEx.IsArgumentNullException(result, "filePath");
            }
Esempio n. 3
0
            public void Should_Throw_If_Directory_Does_Not_Exist()
            {
                // Given
                var context     = Substitute.For <ICakeContext>();
                var environment = FakeEnvironment.CreateUnixEnvironment();
                var fileSystem  = new FakeFileSystem(environment);

                context.FileSystem.Returns(fileSystem);
                context.Environment.Returns(environment);

                // When / Then
                Assert.Throws <FileNotFoundException>(() => FileAliases.FileSize(context, "non-existent-file.txt"));
            }
Esempio n. 4
0
            public void Should_Return_Size_If_Path_Exist(string workingDirectory, string filePath)
            {
                // Given
                var context     = Substitute.For <ICakeContext>();
                var environment = FakeEnvironment.CreateUnixEnvironment();

                environment.WorkingDirectory = workingDirectory;
                var fileSystem = new FakeFileSystem(environment);

                fileSystem.CreateFile(filePath, new byte[] { 1, 2, 3, 4 });
                context.FileSystem.Returns(fileSystem);
                context.Environment.Returns(environment);

                // When
                var result = FileAliases.FileSize(context, filePath);

                // Then
                Assert.Equal(result, 4);
            }