public async Task Execute_Success(string?input, string password, uint?iterationCount, uint?saltSize, string?inputPath, string?outputPath)
        {
            TestStore store   = new TestStore(input);
            var       command = new EncryptCommand.EncryptCommandHandler(input, password, iterationCount, saltSize, inputPath is null ? null : new FileInfo(inputPath), outputPath is null ? null : new FileInfo(outputPath), true, store);

            TestConsole console = new TestConsole();
            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 EncryptCommand.EncryptCommandHandler(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));
        }
Пример #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;
        }
Пример #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";
        }
Пример #5
0
        public async Task <EncryptResult> Encrypt([FromBody] EncryptCommand command)
        {
            EncryptResult result = new EncryptHandler().Handle(command);

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