public async Task DeleteAsyncRecipientsCorrectlyTest() { var dbContext = ApplicationDbContextInMemoryFactory.InitializeContext(); MapperInitializer.InitializeMapper(); var recipientRepository = new EfDeletableEntityRepository <Recipient>(dbContext); var hospitalDataRepository = new EfDeletableEntityRepository <HospitalData>(dbContext); var recipientReques = new EfDeletableEntityRepository <RecipientRequest>(dbContext); var recipientHospitalDataRepository = new EfDeletableEntityRepository <RecipientHospitalData>(dbContext); var service = new RecipientsService( recipientRepository, hospitalDataRepository, recipientReques, recipientHospitalDataRepository); await SeedDataAsync(dbContext); var hospital = hospitalDataRepository.All().FirstOrDefault(); var recipient = recipientRepository.All().FirstOrDefault(); await service.DeleteAsync(hospital.ApplicationUserId, recipient.Id); var result = service.TotalRecipients <RecipientInfoViewModel>(hospital.ApplicationUserId).Count(); Assert.Equal(0, result); }
public async Task DeleteAsyncRecipientsThrowsExceptionTest() { var dbContext = ApplicationDbContextInMemoryFactory.InitializeContext(); MapperInitializer.InitializeMapper(); var recipientRepository = new EfDeletableEntityRepository <Recipient>(dbContext); var hospitalDataRepository = new EfDeletableEntityRepository <HospitalData>(dbContext); var recipientReques = new EfDeletableEntityRepository <RecipientRequest>(dbContext); var recipientHospitalDataRepository = new EfDeletableEntityRepository <RecipientHospitalData>(dbContext); var service = new RecipientsService( recipientRepository, hospitalDataRepository, recipientReques, recipientHospitalDataRepository); await SeedDataAsync(dbContext); var hospital = hospitalDataRepository.All().FirstOrDefault(); await Assert.ThrowsAsync <ArgumentException>(() => service.DeleteAsync(hospital.ApplicationUserId, "1")); }