Beispiel #1
0
        public async Task Post_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            var unitUnderTest = CreateOrdersController();

            //fake

            var goodsId = Guid.NewGuid();
            var product = new Goods(goodsId, "Benang 401");

            var unitId = Guid.NewGuid();

            var unit = new UnitDepartment(unitId, "Spinning");

            var flowId = Guid.NewGuid();

            var flow = new ManufactureFlow(flowId, product, new List <ManufactureOrderActivityType> {
                ManufactureOrderActivityType.Spinning_Blowing,
                ManufactureOrderActivityType.Spinning_Carding
            });

            var orderCode = "MO010101";

            var order = new ManufactureOrder(Guid.NewGuid(), "MO010101", unit, flow, product);

            this.mockManufactureOrderService.Setup(x => x.PlaceOrderAsync(orderCode, unitId, flowId, goodsId)).Returns(Task.FromResult(order));

            var form = new ManufactureOrderForm
            {
                Code            = orderCode,
                UnitId          = unitId.ToString(),
                FlowId          = flowId.ToString(),
                OutputProductId = goodsId.ToString()
            };

            // Act
            IActionResult result = await unitUnderTest.Post(form);

            // Assert
            result.Should().BeOfType <OkObjectResult>()
            .Subject.Value.Should().BeOfType <string>()
            .Subject.Should().Be(order.Identity.ToString());
        }
        public async Task <IActionResult> Post([FromBody] ManufactureOrderForm form)
        {
            var order = await _manufactureOrderService.PlaceOrderAsync(form.Code, Guid.Parse(form.UnitId), Guid.Parse(form.FlowId), Guid.Parse(form.OutputProductId));

            return(Ok(order.Identity.ToString()));
        }