예제 #1
0
        public void Should_Create_Order_Return_Success_ResponseCode_And_Guid()
        {
            // Arrange
            Guid  _guid = Guid.NewGuid();
            Order order = new Order()
            {
            };
            Mock <IOrderService> mockOrderService = new Mock <IOrderService>();

            mockOrderService.Setup(c => c.CreateOrder(It.IsAny <Order>()))
            .Returns(_guid);
            OrderApiController controller = new OrderApiController(mockOrderService.Object);

            // Act
            var result      = controller.CreateOrder(order);
            var checkresult = result as ObjectResult;

            // Assert
            Assert.IsNotNull(checkresult);
            Assert.AreEqual(_guid.ToString(), checkresult.Value.ToString());
            Assert.AreEqual(200, checkresult.StatusCode);
        }