public async void Encrypted_stream_should_be_decryptable() { var encryptedData = await _streamHandler.EncryptData(_nonEncryptedSourceData); var decryptedData = await _streamHandler.DecryptData(encryptedData); Assert.Equal(_nonEncryptedSourceData, decryptedData); }
public async Task <string> HandleUpload(IFormFile file) { var data = await _streamHandler.CopyStreamToByteBuffer(file.OpenReadStream()); var encryptedData = await _streamHandler.EncryptData(data); var uniqueFileName = Guid.NewGuid().ToString(); await _streamHandler.WriteBufferToFile(encryptedData, _hostingEnvironment.WebRootPath + "uploads/" + uniqueFileName); return(uniqueFileName); }
public void for_FileUploadHandler_when_fileupload_it_should_encrypt_the_file_write_it_to_storage_and_return_a_uniqe_filename() { var fileId = _fileUploadHandler.HandleUpload(A.Fake <IFormFile>()); A.CallTo(() => _streamHandler.CopyStreamToByteBuffer(A <Stream> .Ignored)).MustHaveHappened(); A.CallTo(() => _streamHandler.EncryptData(A <byte[]> .Ignored)).MustHaveHappened(); A.CallTo(() => _streamHandler.WriteBufferToFile(A <byte[]> .Ignored, A <string> .Ignored)).MustHaveHappened(); Assert.NotNull(fileId); }
public async void Encrypted_data_should_not_equal_source_data() { _encryptedData = await _streamHandler.EncryptData(_dataToEncrypt); Assert.NotEqual(_dataToEncrypt, _encryptedData); }