public void Delete_a_setting() { //Arrange //Arrange var origCount = _inMemRepo.GetListOf().Count; var newSetting = new SettingFromPost() { CustomerId = Guid.NewGuid(), SettingTypeId = 1, SettingValue = "Test Value" }; //Act // Add the record to delete var postAction = _controller.Post(newSetting); var addViewResult = Assert.IsType <CreatedAtRouteResult>(postAction).Value; var setting = (Setting)addViewResult; // Now delete the record var deleteAction = _controller.DeleteById(setting.Id); Assert.IsType <NoContentResult>(deleteAction); // Assert var checkSetting = _inMemRepo.GetListOf(c => c.Id == setting.Id).SingleOrDefault(); Assert.Null(checkSetting); Assert.Equal(origCount, _inMemRepo.GetListOf().Count); }