private ICarExtrasService GetCarExtrasService() { var dbContext = this.GetUseInMemoryDbContext().GetAwaiter().GetResult(); var repository = new EfRepository <CarExtra>(dbContext); var service = new CarExtrasService(repository, this.GetExtrasService()); return(service); }
private async Task <ICarExtrasService> GetCarExtrasService() { var dbContext = await this.GetUseInMemoryDbContext(); var repository = new EfRepository <CarExtra>(dbContext); var extrasService = await this.GetExtrasService(); var service = new CarExtrasService(repository, extrasService); return(service); }
private async Task CheckIfAddExtrasToDbAsyncMethodWorksCorrectlyWIthNoPassedCarExtras() { var carExtrasDb = new List <CarExtra>(); var carExtrasRepository = new Mock <IRepository <CarExtra> >(); carExtrasRepository.Setup(x => x.AddAsync(It.IsAny <CarExtra>())) .Callback((CarExtra x) => carExtrasDb.Add(x)); var extrasRepository = new Mock <IRepository <Extra> >(); IExtrasService extrasService = new ExtrasService(extrasRepository.Object); ICarExtrasService carExtrasService = new CarExtrasService(carExtrasRepository.Object, extrasService); await carExtrasService.AddExtrasToDbAsync(1, null); var carExtrasCount = carExtrasDb.Count(); Assert.Equal(0, carExtrasCount); }