public void DeleteClass_ShouldReturnNoContentStatusCode() { Class testItem = _dbContext.Classes.First(); var result = _testController.DeleteClass(testItem.Id).GetAwaiter().GetResult() as StatusCodeResult; Assert.IsNotNull(result); Assert.AreEqual((int)HttpStatusCode.NoContent, result.StatusCode); }
public async System.Threading.Tasks.Task TestDeleteClass_NotFound_OnEmptySet() { //Arrange var context = TestingUtilities.CreateInMemoryDatabaseContext("DeleteClassSuccefull"); var controller = new ClassesController(context); //Act var result = await controller.DeleteClass(44); //Assert Assert.IsType <NotFoundResult>(result); context.Database.EnsureDeleted(); }
public async System.Threading.Tasks.Task TestDeleteClass_NotFound_OnWrongId() { //Arrange var context = TestingUtilities.CreateInMemoryDatabaseContext("DeleteClassSuccefull"); var testEntity = new Class() { Id = 42 }; context.Classes.Add(testEntity); context.SaveChanges(); var controller = new ClassesController(context); //Act var result = await controller.DeleteClass(44); //Assert Assert.IsType <NotFoundResult>(result); Assert.True(context.Classes.Contains(testEntity)); Assert.Equal(1, context.Classes.Where(x => x.Id == 42).Count()); context.Database.EnsureDeleted(); }