public async Task GetOrderHistory_OutOfBounds() { // Arrange var repo = new FakePurchaseRepo(TestData.Purchases()); var productRepo = new FakeProductService(TestData.Products()); using (var controller = new PurchasesController(repo, productRepo, null, null)) { var accId = -6; // Act var result = await controller.OrderHistory(accId); // Assert Assert.IsInstanceOfType(result.Result, typeof(BadRequestResult)); } }
public async Task GetOrderHistoryTest_Success() { // Arrange var repo = new FakePurchaseRepo(TestData.Purchases()); var productRepo = new FakeProductService(TestData.Products()); using (var controller = new PurchasesController(repo, productRepo, null, null)) { var accId = 1; // Act var result = await controller.OrderHistory(accId); // Assert Assert.IsNotNull(result); var objResult = result.Result as OkObjectResult; Assert.IsNotNull(objResult); var retResult = objResult.Value as List<Purchase>; Assert.IsNotNull(retResult); //foreach (Purchase purchase in retResult) //{ // Assert.AreEqual(await repo.GetPurchase(purchase.Id), purchase); //} } }