public Lib.Models.GarmentDetailCurrency GetTestData(CoreDbContext dbContext) { Lib.Models.GarmentDetailCurrency data = new Lib.Models.GarmentDetailCurrency() { Code = "", Rate = 1 }; dbContext.GarmentDetailCurrencies.Add(data); dbContext.SaveChanges(); return(data); }
public void GetByCode_Return_Ok() { //Setup CoreDbContext dbContext = _dbContext(GetCurrentAsyncMethod()); Mock <IServiceProvider> serviceProvider = GetServiceProvider(); GarmentDetailCurrencyService service = new GarmentDetailCurrencyService(serviceProvider.Object); serviceProvider.Setup(s => s.GetService(typeof(GarmentDetailCurrencyService))).Returns(service); serviceProvider.Setup(s => s.GetService(typeof(CoreDbContext))).Returns(dbContext); Lib.Models.GarmentDetailCurrency testData = GetTestData(dbContext); //Act IActionResult response = GetController(service).GetByCode(""); //Assert int statusCode = this.GetStatusCode(response); Assert.Equal((int)HttpStatusCode.OK, statusCode); }