c055bc6c78
Add file system abstraction to enable testability for file operations. - IFileSystem interface with common file operations - FileSystem implementation wrapping System.IO - Unit tests for FileExists functionality
41 lines
857 B
C#
41 lines
857 B
C#
using JdeScoping.ConfigManager.Services;
|
|
|
|
namespace JdeScoping.ConfigManager.Tests.Services;
|
|
|
|
public class FileSystemTests
|
|
{
|
|
[Fact]
|
|
public void FileExists_WithExistingFile_ReturnsTrue()
|
|
{
|
|
// Arrange
|
|
var sut = new FileSystem();
|
|
var tempFile = Path.GetTempFileName();
|
|
|
|
try
|
|
{
|
|
// Act
|
|
var result = sut.FileExists(tempFile);
|
|
|
|
// Assert
|
|
result.ShouldBeTrue();
|
|
}
|
|
finally
|
|
{
|
|
File.Delete(tempFile);
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public void FileExists_WithNonExistingFile_ReturnsFalse()
|
|
{
|
|
// Arrange
|
|
var sut = new FileSystem();
|
|
|
|
// Act
|
|
var result = sut.FileExists("/nonexistent/path/file.txt");
|
|
|
|
// Assert
|
|
result.ShouldBeFalse();
|
|
}
|
|
}
|