public void DeleteValidId() { // act var actual = ((ViewResult)controller.Delete(1)).Model; // assert Assert.AreEqual(orders[0], actual); }
public void Delete_ReturnsTrue() { _ordersController.Submit(new Order() { OrderId = _defaultOrderId }); var result = _ordersController.Delete(_defaultOrderId); Assert.IsInstanceOfType(result, typeof(OkObjectResult)); }
public void Delete_Get_Object() { // Arrange var expectedId = 1; // Act var actionResult = _orderController.Delete(expectedId); var viewResult = actionResult as ViewResult; var actual = (Order)viewResult.Model; // Assert Assert.AreEqual(expectedId, actual.Id); }
public void Orders_Controller_Delete_ShouldBeOk() { // Arrange var isUpdated = true; _orderServiceMock.Setup(c => c.Remove(_orderRemoveCmd.Object)).Returns(isUpdated); // Action IHttpActionResult callback = _ordersController.Delete(_orderRemoveCmd.Object); // Assert var httpResponse = callback.Should().BeOfType <OkNegotiatedContentResult <bool> >().Subject; _orderServiceMock.Verify(s => s.Remove(_orderRemoveCmd.Object), Times.Once); httpResponse.Content.Should().BeTrue(); }
public void DeleteOrderViewSuccess() { var item = new Item { item_id = Guid.NewGuid(), name = "Test", price = 20.00M, quantity = 100 }; var ord_id = Guid.NewGuid(); var order = new Order { order_id = ord_id, quantity = 10, total_price = 200.00M, city = "Dayton", street_address = "123 Forth Avenue", state = "OH", order_date = DateTime.Today, shipping_date = DateTime.Today.AddDays(8) }; var mockOrder = new Mock <DbSet <Order> >(); mockOrder.Setup(m => m.Find(ord_id)).Returns(order); var mockContext = new Mock <StoreDbContext>(); mockContext.Setup(m => m.Orders).Returns(mockOrder.Object); var controller = new OrdersController(mockContext.Object); var result = controller.Delete(ord_id); Assert.IsAssignableFrom(typeof(ViewResult), result); }
public void DeleteUserNegative() { var repo = new Mock <OrdersRep>(db); OrdersController controller = new OrdersController(repo.Object); var data = controller.Delete(66); var result = data as ObjectResult; Assert.AreEqual(400, result.StatusCode); }
public void Delete() { orderManagmentServiceMock .Setup(x => x.Delete(It.Is <int>(id => id == order2.Id))) .Verifiable(); testable.Delete(order2.Id); orderManagmentServiceMock.VerifyAll(); }
public void Remove_ExistingGuidPassed_RemovesOneItem() { // Arrange var existingID = 12345; // Act var okResponse = _controller.Delete(existingID); // Assert Assert.Equal(2, _service.GetAll().Count()); }
public void DeleteOrder_OkResult() { //Arrange var controller = new OrdersController(_uow); //Act var result = controller.Delete(7); //Assert Assert.IsType <OkResult>(result.Result); }
public void DeleteReturnsOk() { // Arrange var mock = new Mock <IOrdersRepository>(); var controller = new OrdersController(mock.Object); // Act IHttpActionResult actionResult = (IHttpActionResult)controller.Delete(5); // Assert Assert.IsInstanceOf((System.Type)actionResult, typeof(OkResult)); }
public async Task Delete_ResturnsNotFound_WhenOrderIdNotExists() { //Arrage OrdersController controller = ArrageNotFound(out Mock <ILogger <OrdersController> > logger); //Act IActionResult result = await controller.Delete(0); //Assert Assert.IsType <NotFoundResult>(result); logger.Verify(); }
public void TestDeleteOrderIdDeleted() { var id = Guid.NewGuid(); _orderService.Setup(x => x.Delete(_cancellationService.Object.GetToken(), id)) .Returns(true); var controller = new OrdersController(_orderService.Object, _logger.Object, _cancellationService.Object); var result = controller.Delete(id); var contentResult = result as OkObjectResult; Assert.Equal(200, contentResult.StatusCode); }
public void DeleteOrder_ShouldReturnOK() { var context = new OrdersManager(new TestCoffeeContext()); var controller = new OrdersController(context); var item = getOrderDemo(); context.save(item); var result = controller.Delete(1) as OkNegotiatedContentResult <SuccessDTO <int> >; Assert.IsNotNull(result); Assert.AreEqual(item.Id, result.Content.Response); Assert.AreEqual(DTOStatus.SUCCESS, result.Content.status); }
public async Task Delete_ReturnsOrderInfoForDeleting() { int id = 1; var order = GetTestOrders().FirstOrDefault(o => o.CustomerId == id); //Arrange mock.Setup(repo => repo.DeleteAsync(order.Id)).Throws(new Exception()); controller = new OrdersController(mock.Object); //Act var result = await controller.Delete(order.Id); //Assert var viewResult = Assert.IsType <ViewResult>(result); }
public void DeleteNotFoundTest() { //// Arrange var testContext = new TestShopAppContext(); var controller = new OrdersController(new OrdersManager(testContext)); controller.UserId = "1234"; //// Act var actual = controller.Delete(2) as NotFoundResult; //// Assert Assert.IsInstanceOfType(actual, typeof(NotFoundResult)); Assert.AreEqual(testContext.Orders.Count(), 1); }
public async Task Delete_Returns_RedirectToActionResult() { int id = 1; var order = GetTestOrders().FirstOrDefault(o => o.CustomerId == id); //Arrange mock.Setup(repo => repo.DeleteAsync(order.Id)); controller = new OrdersController(mock.Object); //Act var result = await controller.Delete(order.Id); //Assert var redirectToActionResult = Assert.IsType <RedirectToActionResult>(result); }
public void OrderDelete_Order_HttpOk() { // Arrange int id = 1; MockHttpConfiguration.HttpGet(_controller); IHttpActionResult response = _controller.Get(id); var result = response as OkNegotiatedContentResult <PurchaseOrder>; var existingOrder = result.Content; MockHttpConfiguration.HttpDelete(_controller); // Act response = _controller.Delete(existingOrder); // Assert Assert.IsInstanceOfType(response, typeof(OkResult)); }
public async Task Delete_ResturnsNoContent_WhenOrderDeleted() { //Arrage var id = 1; Mock <ICrudService <Order> > service = new Mock <ICrudService <Order> >(); service.Setup(x => x.ReadAsync(It.Is <int>(x => x > 0))).ReturnsAsync(new Order()); service.Setup(x => x.DeleteAsync(It.Is <int>(x => x == id))).Verifiable(); OrdersController controller = new OrdersController(service.Object, null); //Act IActionResult result = await controller.Delete(id); //Assert Assert.IsType <NoContentResult>(result); service.Verify(); }
public async Task RemoveItem_ValidExistinItem_ReturnsOk() { //Arrange orderService.Setup(s => s.RemoveItem(OrderId, ItemId)). ReturnsAsync(new OrderDto { Id = OrderId }); OrdersController ordersController = new OrdersController(orderService.Object); //Act var actionResult = await ordersController.Delete(OrderId, ItemId); //Assert Assert.IsNotNull(actionResult); Assert.IsInstanceOf(typeof(OkObjectResult), actionResult); OkObjectResult result = actionResult as OkObjectResult; OrderDto orderData = result.Value as OrderDto; Assert.IsNotNull(orderData); Assert.IsNull(orderData.Items); }
public async Task OrdersReturnsDelete() { //Arrange Orders orderTest = new Orders() { OrderID = 222, EmployeeID = 3 }; await _ordersControllerUnderTest.Create(orderTest); //Act var result = _ordersControllerUnderTest.Delete(orderTest.OrderID); //Assert Assert.IsNotNull(result); var orders = db.Orders.Where(o => o.OrderID == orderTest.OrderID && o.EmployeeID == orderTest.EmployeeID); db.Orders.RemoveRange(orders); db.SaveChanges(); }
private void bwDelete_DoWork(object sender, DoWorkEventArgs e) { OrdersController.Delete(productNo); }