public void WithoutArguments() { // Arrange var tool = new CommandLineTool(); // Act tool.ReadFileText(null, null); // Assert // Without arguments the function should process nothing. }
public void With_MockedFileSystemInteraction() { // Arrange string inputFileDirectory = @"c:\Test"; string inputFileName = "test.ink"; var tool = new CommandLineTool(); tool.FileSystemInteractor = Substitute.For <IFileSystemInteractable>(); // Act string fileContents = tool.ReadFileText(inputFileDirectory, inputFileName); // Assert fileContents.Should().BeNullOrEmpty("because the file system interactor was substituted"); }
public void With_ExceptionThrowingReadFile() { // Arrange string inputFileDirectory = @"c:\Test"; string inputFileName = "test.ink"; var fileSystemInteractorMock = Substitute.For <IFileSystemInteractable>(); fileSystemInteractorMock.When(x => x.ReadAllTextFromFile(Arg.Any <string>())) .Do(x => throw new System.IO.DirectoryNotFoundException()); var tool = new CommandLineTool(); tool.FileSystemInteractor = fileSystemInteractorMock; // Act string fileContents = tool.ReadFileText(inputFileDirectory, inputFileName); // Assert fileContents.Should().BeNullOrEmpty("because the file system interactor was substituted"); }