public async Task DownloadAsync_ShouldReturn_Null_IfContractDoNotExists() { var db = GetDatabase(); var mapper = GetMapper(); var firstContract = new Contract { Id = 1, IsDeleted = false, ScannedContract = new byte[] { 123 } }; var secondContract = new Contract { Id = 2, IsDeleted = false, ScannedContract = new byte[] { 1 } }; var thirdContract = new Contract { Id = 3, IsDeleted = false, ScannedContract = new byte[] { 34 } }; await db.Contracts.AddRangeAsync(firstContract, secondContract, thirdContract); await db.SaveChangesAsync(); var contractService = new ContractsService(mapper, db); var result = await contractService.DownloadAsync(4); result .Should() .BeNull(); }
public async Task DownloadAsync_ShouldReturn_CorrectByteArray_IfContractExists() { var db = GetDatabase(); var mapper = GetMapper(); var firstContract = new Contract { Id = 1, IsDeleted = false, ScannedContract = new byte[] { 123 } }; var secondContract = new Contract { Id = 2, IsDeleted = false, ScannedContract = new byte[] { 1 } }; var thirdContract = new Contract { Id = 3, IsDeleted = false, ScannedContract = new byte[] { 34 } }; await db.Contracts.AddRangeAsync(firstContract, secondContract, thirdContract); await db.SaveChangesAsync(); var contractService = new ContractsService(mapper, db); var result = await contractService.DownloadAsync(1); var scandContract = new byte[] { 123 }; result .Should() .BeOfType <byte[]>() .And .Match <byte[]>(c => c.Length == scandContract.Length); }