public async Task DeleteAsync_ShouldReturn_False_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.DeleteAsync(4); var deletedContract = await db.Contracts.FindAsync(4); result .Should() .BeFalse(); deletedContract .Should() .BeNull(); }
public async Task DeleteAsync_ShouldReturn_True_IfContractExistsAndNotDeleted() { 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.DeleteAsync(2); var deletedContract = await db.Contracts.FindAsync(2); result .Should() .BeTrue(); deletedContract .Should() .BeOfType <Contract>() .And .Match <Contract>(c => c.IsDeleted == true); }