public void OpenInputFile_Failed() { // ASSERT var testTextFile = "NonExistTestTextFile.txt"; var testLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var fullPath = Path.Combine(testLocation, testTextFile); FileNotFoundException exception = null; // ACT try { var testInput = new Aes256CBC() { InputFilePath = fullPath }; } catch (FileNotFoundException e) { exception = e; } // ARRANGE Assert.IsNotNull(exception); }
public async Task OpenInputFile_Success() { // ASSERT var testTextFile = "TestTextFile.txt"; CreateTestTextFile(testTextFile); var testLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var fullPath = Path.Combine(testLocation, testTextFile); var testFileContent = await File.ReadAllLinesAsync(fullPath); // ACT var testInput = new Aes256CBC() { InputFilePath = fullPath }; // ARRANGE Assert.AreEqual(testInput.Content, string.Join('\n', testFileContent)); }
public void Aes_CLI_Success(int keySize, CipherMode cipherMode, string phrase) { // ARRANGE SymmetricCryptographyCliInput cliInput; if (keySize == 128) { if (cipherMode == CipherMode.ECB) { cliInput = new Aes128ECB(); } else { cliInput = new Aes128CBC(); } } else if (keySize == 192) { if (cipherMode == CipherMode.ECB) { cliInput = new Aes192ECB(); } else { cliInput = new Aes192CBC(); } } else { if (cipherMode == CipherMode.ECB) { cliInput = new Aes256ECB(); } else { cliInput = new Aes256CBC(); } } cliInput.Content = phrase; cliInput.Encryption = true; // ACT #region Encryption var cliOutputEncryption = SymmetricCryptographyServices.ProcessOperation(cliInput); OutputModeler.CreateOutput(cliInput, cliOutputEncryption); #endregion cliInput.Content = cliOutputEncryption.Phrase; cliInput.Key = cliOutputEncryption.Key; cliInput.InitializationVector = cliOutputEncryption.IV; cliInput.Encryption = false; cliInput.Decryption = true; #region Decryption var cliOutputDecryption = SymmetricCryptographyServices.ProcessOperation(cliInput); OutputModeler.CreateOutput(cliInput, cliOutputDecryption); #endregion // ASSERT Assert.AreEqual(cliOutputDecryption.Phrase, phrase); }