public void GetFindResultNegativeTest() { using var cryptoManager = new CryptoProvider(); var hashProvider = new HashUtils(EnvId, false, Encoding.UTF8); var transformer = new DtoTransformer(cryptoManager, hashProvider); var exception = Assert.Throws <StorageServerException>(() => transformer.GetFindResult(null)); Assert.AreEqual("Response error: Find response is null", exception.Message); exception = Assert.Throws <StorageServerException>(() => transformer.GetFindResult(new TransferFindResult(null, null))); Assert.AreEqual("Response error: Find result metadata is null", exception.Message); exception = Assert.Throws <StorageServerException>(() => transformer.GetFindResult(new TransferFindResult(null, new TransferFindResult.FindMeta(1, 1, 1, -1)))); Assert.AreEqual("Response error: Negative values in find result metadata", exception.Message); exception = Assert.Throws <StorageServerException>(() => transformer.GetFindResult(new TransferFindResult(null, new TransferFindResult.FindMeta(1, 1, -1, 1)))); Assert.AreEqual("Response error: Negative values in find result metadata", exception.Message); exception = Assert.Throws <StorageServerException>(() => transformer.GetFindResult(new TransferFindResult(null, new TransferFindResult.FindMeta(1, -1, 1, 1)))); Assert.AreEqual("Response error: Negative values in find result metadata", exception.Message); exception = Assert.Throws <StorageServerException>(() => transformer.GetFindResult(new TransferFindResult(null, new TransferFindResult.FindMeta(-1, 1, 1, 1)))); Assert.AreEqual("Response error: Negative values in find result metadata", exception.Message); exception = Assert.Throws <StorageServerException>(() => transformer.GetFindResult(new TransferFindResult(null, new TransferFindResult.FindMeta(1, 1, 1, 1)))); Assert.AreEqual("Response error: count in find results metadata differs from data size", exception.Message); exception = Assert.Throws <StorageServerException>(() => transformer.GetFindResult(new TransferFindResult(new List <TransferRecord>(), new TransferFindResult.FindMeta(1, 1, 1, 1)))); Assert.AreEqual("Response error: count in find results metadata differs from data size", exception.Message); exception = Assert.Throws <StorageServerException>(() => transformer.GetFindResult(new TransferFindResult( new List <TransferRecord> { new TransferRecord("1"), new TransferRecord("2") }, new TransferFindResult.FindMeta(1, 1, 1, 2)))); Assert.AreEqual("Response error: incorrect total in find results metadata, less then received", exception.Message); }
public async Task <FindResult> FindAsync(string country, FindFilter filter) { s_helper.Check <StorageClientException>(filter == null, Messages.DtoTransformer.s_errNullFilter); #pragma warning disable CA1062 var transferFindResult = await _dao.FindRecordsAsync(country?.ToLowerInvariant(), _transformer.TransformFilter(filter)) .ConfigureAwait(false); #pragma warning restore CA1062ƒ return(_transformer.GetFindResult(transferFindResult)); }