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));
        }
Example #3
0
        public CipherViewModel()
        {
            this.cipher = new Cipher();

            this.encrypt = new EncryptCommand(this, this.DoEncrypt);
            this.decrypt = new DecryptCommand(this, this.DoDecrypt);

            this.IsInputEnabled = true;
            this.IsOutputEnabled = false;
        }
Example #4
0
        public EncryptionViewModel()
        {
            ShowPopUp = new RelayCommand(() => ShowPopUpExecute(), () => true);

            decryptCommand         = new DecryptCommand(this);
            encryptCommand         = new EncryptCommand(this);
            createAsmKeyCommand    = new CreateAsmKeysCommand(this);
            exportPublicKeyCommand = new ExportPublicKeyCommand(this);
            getPrivateKeyCommand   = new GetPrivateKeyCommand(this);
            importPublicKeyCommand = new ImportPublicKeyCommand(this);

            LabelText = "Welcome";
        }
Example #5
0
        public async Task <DecryptResult> Decrypt([FromBody] DecryptCommand command)
        {
            DecryptResult result = new DecryptHandler().Handle(command);

            return(await Task.FromResult(result));
        }