public async Task TestReadingAlreadyExists() { using (var context = new SpendingTrackContext(options)) { SpendingController controller = new SpendingController(context, configuration); IEnumerable <SpendingItem> result = controller.GetSpendingItem(); Assert.IsNotNull(result); IList <SpendingItem> resultList = result.ToList(); //Assumes same order Assert.IsTrue(resultList[0].Heading == headingList[0]); Assert.IsTrue(resultList[0].Currency == currencyList[0]); Assert.IsTrue(resultList[0].Cost == costList[0]); Assert.IsTrue(resultList[0].CreatedAt == createdAtList[0]); Assert.IsTrue(resultList[0].Category == categoryList[0]); Assert.IsTrue(resultList[0].ReceiptID == receiptIDList[0]); Assert.IsTrue(resultList[0].TripID == tripIDList[0]); Assert.IsTrue(resultList[1].Heading == headingList[1]); Assert.IsTrue(resultList[1].Currency == currencyList[1]); Assert.IsTrue(resultList[1].Cost == costList[1]); Assert.IsTrue(resultList[1].CreatedAt == createdAtList[1]); Assert.IsTrue(resultList[1].Category == categoryList[1]); Assert.IsTrue(resultList[1].ReceiptID == receiptIDList[1]); Assert.IsTrue(resultList[1].TripID == tripIDList[1]); } }
public async Task TestDelete() { using (var context = new SpendingTrackContext(options)) { SpendingController controller = new SpendingController(context, configuration); IEnumerable <SpendingItem> get_result = controller.GetSpendingItem(); Assert.IsNotNull(get_result); IList <SpendingItem> resultList = get_result.ToList(); IActionResult del_result = await controller.DeleteSpendingItem(resultList[0].ID) as IActionResult; Assert.IsInstanceOfType(del_result, typeof(OkObjectResult)); IActionResult result_after = await controller.GetSpendingItem(resultList[0].ID) as IActionResult; Assert.IsInstanceOfType(result_after, typeof(NotFoundResult)); } }