Example #1
0
        public async Task Handle_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            GetAllGarmentAvalComponentsQueryHandler unitUnderTest = CreateGetAllGarmentAvalComponentsQueryHandler();
            CancellationToken cancellationToken = CancellationToken.None;

            Guid avalComponentGuid = Guid.NewGuid();

            GetAllGarmentAvalComponentsQuery query = new GetAllGarmentAvalComponentsQuery(1, 25, "{}", null, "{}");

            _mockGarmentAvalComponentRepository
            .Setup(s => s.ReadList(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()))
            .Returns(new List <GarmentAvalComponentReadModel>()
            {
                new GarmentAvalComponentReadModel(avalComponentGuid)
            }.AsQueryable());

            _mockGarmentAvalComponentRepository
            .Setup(s => s.Find(It.IsAny <IQueryable <GarmentAvalComponentReadModel> >()))
            .Returns(new List <GarmentAvalComponent>()
            {
                new GarmentAvalComponent(Guid.Empty, null, new UnitDepartmentId(1), null, null, null, null, null, new GarmentComodityId(1), null, null, DateTimeOffset.Now)
            });

            _mockGarmentAvalComponentItemRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentAvalComponentItemReadModel>().AsQueryable());

            // Act
            var result = await unitUnderTest.Handle(query, cancellationToken);

            // Assert
            result.Should().NotBeNull();
        }
        public async Task <IActionResult> Get(int page = 1, int size = 25, string order = "{}", [Bind(Prefix = "Select[]")] List <string> select = null, string keyword = null, string filter = "{}")
        {
            VerifyUser();

            GetAllGarmentAvalComponentsQuery query = new GetAllGarmentAvalComponentsQuery(page, size, order, keyword, filter);
            var viewModel = await Mediator.Send(query);

            return(Ok(viewModel.GarmentAvalComponents, info: new
            {
                page,
                size,
                viewModel.count
            }));
        }