public async Task Execute(string?input, string password, uint?iterationCount, uint?saltSize, string?inputPath, string?outputPath) { TestStore store = new TestStore(input); var command = new DecryptCommand.DecryptCommandHandler(input, password, iterationCount, saltSize, inputPath is null ? null : new FileInfo(inputPath), outputPath is null ? null : new FileInfo(outputPath), true, store); TestConsole console = new TestConsole(); new Parser(); await command.InvokeAsync(console); if (inputPath is null) { Assert.False(store.WasRead); } else { Assert.True(store.WasRead); } if (outputPath is null) { Assert.Null(store.Output); Assert.False(store.WasWritten); var output = console.Out.ToString() !; Assert.NotEqual(0, output.Length); } else { Assert.NotNull(store.Output); Assert.True(store.WasWritten); var output = console.Out.ToString() !; Assert.Equal(0, output.Length); } }
public void Execute_Fail(string?input, string password, uint?iterationCount, uint?saltSize, string?inputPath, string?outputPath) { TestStore store = new TestStore(input); var command = new DecryptCommand.DecryptCommandHandler(input, password, iterationCount, saltSize, inputPath is null ? null : new FileInfo(inputPath), outputPath is null ? null : new FileInfo(outputPath), true, store); TestConsole console = new TestConsole(); Assert.ThrowsAsync <InvalidOperationException>(() => command.InvokeAsync(console)); }