public When_ProviderService_Is_Called_To_Get_Provider_Detail_By_Id() { var config = new MapperConfiguration(c => c.AddMaps(typeof(ProviderMapper).Assembly)); var mapper = new Mapper(config); var logger = Substitute.For <ILogger <ProviderRepository> >(); var providerReferenceRepository = Substitute.For <IRepository <ProviderReference> >(); using var dbContext = InMemoryDbContext.Create(); dbContext.Add(new ValidProviderBuilder() .Build()); dbContext.SaveChanges(); var providerRepository = new ProviderRepository(logger, dbContext); var service = new ProviderService(mapper, providerRepository, providerReferenceRepository); _result = service.GetProviderDetailByIdAsync(1).GetAwaiter().GetResult(); }