public async Task GetRecipientByIdShouldReturnCorrectlyTest() { 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 recipient = recipientRepository.All().FirstOrDefault(); var result = service.GetById <RecipientInfoViewModel>(recipient.Id); Assert.NotNull(result); }
public async Task GetRecipientByIdShouldThrowErrorTest() { 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); Assert.Throws <ArgumentException>(() => service.GetById <RecipientInfoViewModel>(null)); }