TestService.Delete C# (CSharp) Метод

Delete() приватный Метод

private Delete ( int id ) : HttpResponseMessage,
id int
Результат HttpResponseMessage,
	public HttpResponseMessage Delete(int id)
	{
		var product = this.products.FirstOrDefault(x => x.Id == id);

		if (product == null)
			return new System.Net.Http.HttpResponseMessage(System.Net.HttpStatusCode.NotFound, "Not found");

		this.products.Remove(product);

		return new HttpResponseMessage(System.Net.HttpStatusCode.OK, "Deleted");
	}

Usage Example

        public void AddOrUpdate_GetAll_Delete_TestClass()
        {
            Test test = new Test()
            {
                Name = "oblect_1"
            };

            testService.AddOrUpdateTest(test);

            Assert.AreEqual(testService.GetAll().Where(t => t.Name == test.Name).FirstOrDefault().Name, test.Name);

            foreach (var item in testService.GetAll().ToList())
            {
                testService.Delete(item.Id);
            }
        }
All Usage Examples Of TestService::Delete