Пример #1
0
        public async Task <IActionResult> GetMonitoring(int unit, DateTime date, string ro, int page = 1, int size = 25, string Order = "{}")
        {
            VerifyUser();
            GetMonitoringProductionFlowQuery query = new GetMonitoringProductionFlowQuery(page, size, Order, unit, date, ro, WorkContext.Token);
            var viewModel = await Mediator.Send(query);

            return(Ok(viewModel.garmentMonitorings, info: new
            {
                page,
                size,
                viewModel.count
            }));
        }
        public async Task Handle_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            GetMonitoringProductionFlowQueryHandler unitUnderTest = CreateGetMonitoringProductionFlowQueryHandler();
            CancellationToken cancellationToken = CancellationToken.None;

            Guid guidLoading          = Guid.NewGuid();
            Guid guidLoadingItem      = Guid.NewGuid();
            Guid guidCuttingOut       = Guid.NewGuid();
            Guid guidCuttingOutItem   = Guid.NewGuid();
            Guid guidCuttingOutDetail = Guid.NewGuid();
            Guid guidFinishingOut     = Guid.NewGuid();
            Guid guidFinishingOutItem = Guid.NewGuid();
            Guid guidSewingOut        = Guid.NewGuid();
            Guid guidSewingOutItem    = Guid.NewGuid();
            Guid guidSewingDO         = Guid.NewGuid();
            Guid guidSewingDOItem     = Guid.NewGuid();
            Guid guidCuttingIn        = Guid.NewGuid();
            Guid guidCuttingInItem    = Guid.NewGuid();
            Guid guidFinishingIn      = Guid.NewGuid();
            Guid guidFinishingInItem  = Guid.NewGuid();
            Guid guidAdjustment       = Guid.NewGuid();
            Guid guidAdjustmentItem   = Guid.NewGuid();
            GetMonitoringProductionFlowQuery getMonitoring = new GetMonitoringProductionFlowQuery(1, 25, "{}", 1, DateTime.Now, null, "token");

            _mockGarmentLoadingItemRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentLoadingItemReadModel>
            {
                new GarmentLoadingItem(guidLoadingItem, guidLoading, new Guid(), new SizeId(1), "", new ProductId(1), "", "", "", 0, 0, 0, new UomId(1), "", "", 10).GetReadModel()
            }.AsQueryable());

            _mockGarmentLoadingRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentLoadingReadModel>
            {
                new GarmentLoading(guidLoading, "", new Guid(), "", new UnitDepartmentId(1), "", "", "ro", "", new UnitDepartmentId(1), "", "", DateTimeOffset.Now, new GarmentComodityId(1), "", "").GetReadModel()
            }.AsQueryable());

            _mockGarmentCuttingOutDetailRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentCuttingOutDetailReadModel>
            {
                new GarmentCuttingOutDetail(new Guid(), guidCuttingOutItem, new SizeId(1), "", "", 100, 100, new UomId(1), "", 10, 10).GetReadModel()
            }.AsQueryable());

            _mockGarmentCuttingOutItemRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentCuttingOutItemReadModel>
            {
                new GarmentCuttingOutItem(guidCuttingOutItem, new Guid(), new Guid(), guidCuttingOut, new ProductId(1), "", "", "", 100).GetReadModel()
            }.AsQueryable());
            _mockGarmentCuttingOutRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentCuttingOutReadModel>
            {
                new GarmentCuttingOut(guidCuttingOut, "", "", new UnitDepartmentId(1), "", "", DateTime.Now.AddDays(-1), "ro", "", new UnitDepartmentId(1), "", "", new GarmentComodityId(1), "", "").GetReadModel()
            }.AsQueryable());

            _mockGarmentFinishingOutDetailRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentFinishingOutDetailReadModel>
            {
                new GarmentFinishingOutDetail(new Guid(), guidFinishingOutItem, new SizeId(1), "", 10, new UomId(1), "").GetReadModel()
            }.AsQueryable());

            _mockGarmentFinishingOutItemRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentFinishingOutItemReadModel>
            {
                new GarmentFinishingOutItem(guidFinishingOutItem, guidFinishingOut, new Guid(), new Guid(), new ProductId(1), "", "", "", new SizeId(1), "", 10, new UomId(1), "", "", 10, 10, 10).GetReadModel()
            }.AsQueryable());

            _mockGarmentFinishingOutRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentFinishingOutReadModel>
            {
                new GarmentFinishingOut(guidFinishingOut, "", new UnitDepartmentId(1), "", "", "GUDANG JADI", DateTimeOffset.Now, "ro", "", new UnitDepartmentId(1), "", "", new GarmentComodityId(1), "", "", false).GetReadModel()
            }.AsQueryable());

            _mockGarmentSewingOutDetailRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentSewingOutDetailReadModel>
            {
                new GarmentSewingOutDetail(new Guid(), guidSewingOutItem, new SizeId(1), "", 0, new UomId(1), "").GetReadModel()
            }.AsQueryable());
            _mockGarmentSewingOutItemRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentSewingOutItemReadModel>
            {
                new GarmentSewingOutItem(guidSewingOutItem, guidSewingOut, new Guid(), new Guid(), new ProductId(1), "", "", "", new SizeId(1), "", 0, new UomId(1), "", "", 10, 100, 100).GetReadModel()
            }.AsQueryable());

            _mockGarmentSewingOutRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentSewingOutReadModel>
            {
                new GarmentSewingOut(guidSewingOut, "", new BuyerId(1), "", "", new UnitDepartmentId(1), "", "", "FINISHING", DateTimeOffset.Now, "ro", "", new UnitDepartmentId(1), "", "", new GarmentComodityId(1), "", "", true).GetReadModel()
            }.AsQueryable());
            // Act
            var result = await unitUnderTest.Handle(getMonitoring, cancellationToken);

            // Assert
            result.Should().NotBeNull();
        }