public void CreateSignature(ApplicationArguments arguments) { ReadKeyFromFileCommand readPrivateKeyFromFile = fileCommandProvider.GetReadPrivateKeyFromFileCommand(arguments.PrivateKeyPath, arguments.Password); commandExecutor.Execute(readPrivateKeyFromFile); byte[] contentToSign; if (arguments.HasFileInput) { ReadFileCommand <byte[]> readFileToSign = fileCommandProvider.GetReadFileCommand <byte[]>(arguments.FileInput); commandExecutor.Execute(readFileToSign); contentToSign = readFileToSign.Result; } else { contentToSign = encoding.GetBytes(arguments.Input); } CreateSignatureCommand createSignature = signatureCommandProvider.GetCreateSignatureCommand(readPrivateKeyFromFile.Result, contentToSign); commandExecutor.Execute(createSignature); if (arguments.HasFileOutput) { WriteFileCommand <Signature> writeSignatureTofile = fileCommandProvider.GetWriteToFileCommand(createSignature.Result, arguments.FileOutput); commandExecutor.Execute(writeSignatureTofile); return; } WriteToStdOutCommand <Signature> writeSignatureToStdOut = fileCommandProvider.GetWriteToStdOutCommand <Signature>(createSignature.Result); commandExecutor.Execute(writeSignatureToStdOut); }
public void ShouldExecuteDecoratedHandlerWithBase64FormattedContent() { var command = new WriteToStdOutCommand <Signature> { Out = signature }; decorator.Execute(command); decoratedHandler.Verify(dh => dh.Execute(It.Is <WriteToStdOutCommand <Signature> >(c => c.ContentToStdOut == "Base64FormattedContent"))); }
public void Setup() { console = new Mock <ConsoleWrapper>(); commandHandler = new WriteToStdOutCommandHandler <object>(console.Object); var command = new WriteToStdOutCommand <object> { ContentToStdOut = "Written Content" }; commandHandler.Execute(command); }
public void Setup() { var content = new byte[] { 0x09 }; signature = new Signature { Content = content }; base64 = new Mock <Base64Wrapper>(); base64.Setup(b => b.ToBase64String(content)) .Returns("Base64FormattedContent"); decoratedHandler = new Mock <ICommandHandler <WriteToStdOutCommand <Signature> > >(); decorator = new WriteToStdOutBase64FormattingDecorator <WriteToStdOutCommand <Signature> >(decoratedHandler.Object, base64.Object); var command = new WriteToStdOutCommand <Signature> { Out = signature }; }
public void Execute(WriteToStdOutCommand <T> command) { console.WriteLine(command.ContentToStdOut); }
public void Setup() { result = provider.GetWriteToStdOutCommand <int>(4); }