public void GetTransferRecordFromNullTest()
        {
            using var cryptoManager = new CryptoProvider();
            var hashProvider = new HashUtils(EnvId, false, Encoding.UTF8);
            var transformer  = new DtoTransformer(cryptoManager, hashProvider);
            var exception    = Assert.Throws <StorageClientException>(() => transformer.GetTransferRecord(null));

            Assert.AreEqual("Record is null", exception.Message);
        }
        public void GetRecordWithNonHashingModeTest()
        {
            using var cryptoManager = new CryptoProvider();
            var hashProvider = new HashUtils(EnvId, false, Encoding.UTF8);
            var transformer  = new DtoTransformer(cryptoManager, hashProvider, false);

            var record          = new Record("hashed_RecordKey", key1: "non_hashed_key1");
            var transformRecord = transformer.GetTransferRecord(record);

            Assert.AreEqual("f09b57bd0932fd2ec1f4ba63f1cbc77a2f02efac25c31a9a0d1ed3a078330524",
                            transformRecord.RecordKey);
            Assert.AreEqual("non_hashed_key1", transformRecord.Key1);
        }
Example #3
0
        public async Task <Record> WriteAsync(string country, Record record)
        {
            s_helper.Check <StorageClientException>(record == null, Messages.Storage.s_errNullRecord);
#pragma warning disable CA1062
            s_helper.Check <StorageClientException>(string.IsNullOrEmpty(record.RecordKey),
                                                    Messages.Storage.s_errNullRecordKey);
#pragma warning restore CA1062
#pragma warning disable CA1308
            await _dao
            .CreateRecordAsync(country?.ToLowerInvariant(), _transformer.GetTransferRecord(record))
            .ConfigureAwait(false);

            return(record);
        }
        public void GetTransferRecordWithNullBodyTest()
        {
            const string recordKey = "someRecordKey";
            var          record    = new Record(recordKey);

            using var cryptoManager = new CryptoProvider();
            var hashProvider   = new HashUtils(EnvId, false, Encoding.UTF8);
            var transformer    = new DtoTransformer(cryptoManager, hashProvider);
            var transferRecord = transformer.GetTransferRecord(record);

            Assert.NotNull(transferRecord);
            Assert.AreEqual("6717f3b00ef569e5604566335ff0b10a58a236a07a066372ede034ed5b732690",
                            transferRecord.RecordKey);
            Assert.NotNull(transferRecord.Body);
            var restoredRecord = transformer.GetRecord(transferRecord);

            Assert.NotNull(restoredRecord);
            Assert.AreEqual(recordKey, restoredRecord.RecordKey);
            Assert.IsNull(restoredRecord.Body);
        }