public Lib.Models.Division GetTestData(CoreDbContext dbContext) { Lib.Models.Division data = new Lib.Models.Division(); dbContext.Divisions.Add(data); dbContext.SaveChanges(); return(data); }
public async Task Update() { Lib.Models.Division division = await DataUtil.GetTestDataAsync(); DivisionViewModel VM = Service.MapToViewModel(division); var response = await this.Client.PutAsync(string.Concat(URI, "/", VM.Id), new StringContent(JsonConvert.SerializeObject(VM).ToString(), Encoding.UTF8, "application/json")); Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); }
public async Task Delete() { Lib.Models.Division division = await DataUtil.GetTestDataAsync(); DivisionViewModel VM = Service.MapToViewModel(division); var response = await this.Client.DeleteAsync(string.Concat(URI, "/", VM.Id)); Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); }
public async Task TestJoinDivision() { CategoryService service = this.Service; DivisionService divisionService = ServiceProvider.GetService <DivisionService>(); string guid = Guid.NewGuid().ToString(); var division = new Lib.Models.Division() { Name = String.Concat("TEST DIVISION ", guid), }; Category createdData = await this.GetCreatedTestData(service); var createdDivision = await divisionService.CreateModel(division); var data = service.JoinDivision(); Assert.NotNull(data); }
public void GetDivisionName_Return_OK() { //Setup CoreDbContext dbContext = _dbContext(GetCurrentAsyncMethod()); Mock <IServiceProvider> serviceProvider = GetServiceProvider(); DivisionService service = new DivisionService(serviceProvider.Object); serviceProvider.Setup(s => s.GetService(typeof(DivisionService))).Returns(service); serviceProvider.Setup(s => s.GetService(typeof(CoreDbContext))).Returns(dbContext); Lib.Models.Division testData = GetTestData(dbContext); //Act IActionResult response = GetController(service).GetByDivisionName(); //Assert int statusCode = this.GetStatusCode(response); Assert.NotEqual((int)HttpStatusCode.NotFound, statusCode); }