public void GetOrder_OrderDoesNotExist_ReturnNotFound() { var orderId = -1; var result = _sut.Get(orderId); Assert.Equal(typeof(NotFoundResult), result.GetType()); }
public void UpdateOrder_OkResult() { //Arrange var controller = new OrderItemsController(_uow); var orderItemId = 2; var orderItem = new OrderItem { OrderItemId = orderItemId, OrderId = 3, ProductId = 2, Quantity = 4 }; //Act var result = controller.Put(orderItemId, orderItem); var updated = controller.Get(orderItem.OrderItemId); var updatedOrder = updated.Value.Should().BeAssignableTo <OrderItem>().Subject; //Assert Assert.IsType <OkResult>(result.Result); Assert.Equal(updatedOrder.OrderItemId, orderItem.OrderItemId); Assert.Equal(updatedOrder.OrderId, orderItem.OrderId); Assert.Equal(updatedOrder.ProductId, orderItem.ProductId); Assert.Equal(updatedOrder.Quantity, orderItem.Quantity); }
public void GetOrderItemReturns404WhenOrderNotFound() { _mockOrderItemAccess.Reset(); _mockOrderItemAccess.Setup(a => a.GetOrderItem(It.IsAny <Guid>())).Returns((OrderItem)null); OrderItemsController sut = CreateSystemUnderTest(); var result = sut.Get(It.IsAny <Guid>()); _mockOrderItemAccess.Verify(a => a.GetOrderItem(It.IsAny <Guid>()), Times.Once); Assert.IsType <NotFoundResult>(result); }
public void GetOrderItems_OkResult() { //Arrange var controller = new OrderItemsController(_uow); //Act var result = controller.Get(); //Assert Assert.IsType <List <OrderItem> >(result.Value); }
public void GetOrderItemById_NotFoundResult() { //Arrange var controller = new OrderItemsController(_uow); int orderId = 3333333; //Act var result = controller.Get(orderId); //Assert Assert.IsType <NotFoundResult>(result.Result); }
public void GetOrderItemById_OkResult() { //Arrange var controller = new OrderItemsController(_uow); int orderItemId = 1; //Act var result = controller.Get(orderItemId); //Assert Assert.IsType <OrderItem>(result.Value); }
public void GetOrderItemReturnsOkayWhenOrderIsFound() { OrderItem orderItem = _fixture.Create <OrderItem>(); _mockOrderItemAccess.Reset(); _mockOrderItemAccess.Setup(a => a.GetOrderItem(It.IsAny <Guid>())).Returns(orderItem); OrderItemsController sut = CreateSystemUnderTest(); var result = sut.Get(It.IsAny <Guid>()); _mockOrderItemAccess.Verify(a => a.GetOrderItem(It.IsAny <Guid>()), Times.Once); Assert.IsType <OkObjectResult>(result); Assert.NotNull((OrderItem)((OkObjectResult)result).Value); }
public void CreateOrderItem_OkResult() { //Arrange var controller = new OrderItemsController(_uow); var orderItem = new OrderItem { OrderId = 3, ProductId = 2, Quantity = 5 }; //Act var result = controller.Post(orderItem); var created = controller.Get(orderItem.OrderItemId); var createdOrder = created.Value.Should().BeAssignableTo <OrderItem>().Subject; //Assert Assert.IsType <CreatedAtRouteResult>(result.Result); Assert.Equal(createdOrder.OrderItemId, orderItem.OrderItemId); Assert.Equal(createdOrder.OrderId, orderItem.OrderId); Assert.Equal(createdOrder.ProductId, orderItem.ProductId); Assert.Equal(createdOrder.Quantity, orderItem.Quantity); }