public async Task Handle_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            Guid          guid = Guid.NewGuid();
            List <string> Ids  = new List <string>();

            Ids.Add(guid.ToString());
            UpdateDatesGarmentFinishingOutCommandHandler unitUnderTest = CreateUpdateDatesGarmentFinishingOutCommandHandler();
            CancellationToken cancellationToken = CancellationToken.None;
            UpdateDatesGarmentFinishingOutCommand UpdateGarmentFinishingOutCommand = new UpdateDatesGarmentFinishingOutCommand(
                Ids, DateTimeOffset.Now);

            _mockFinishingOutRepository
            .Setup(s => s.Query)
            .Returns(new List <GarmentFinishingOutReadModel>()
            {
                new GarmentFinishingOutReadModel(guid)
            }.AsQueryable());

            _mockFinishingOutRepository
            .Setup(s => s.Update(It.IsAny <GarmentFinishingOut>()))
            .Returns(Task.FromResult(It.IsAny <GarmentFinishingOut>()));

            _MockStorage
            .Setup(x => x.Save())
            .Verifiable();

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

            // Assert
            result.Should().BeGreaterThan(0);
        }
        public async Task Put_Dates_StateUnderTest_ExpectedBehavior_BadRequest()
        {
            // Arrange
            var           unitUnderTest = CreateGarmentFinishingOutController();
            Guid          sewingOutGuid = Guid.NewGuid();
            List <string> ids           = new List <string>();

            ids.Add(sewingOutGuid.ToString());

            UpdateDatesGarmentFinishingOutCommand command = new UpdateDatesGarmentFinishingOutCommand(ids, DateTimeOffset.Now.AddDays(3));

            // Act
            var result = await unitUnderTest.UpdateDates(command);

            // Assert
            Assert.Equal((int)HttpStatusCode.BadRequest, GetStatusCode(result));

            UpdateDatesGarmentFinishingOutCommand command2 = new UpdateDatesGarmentFinishingOutCommand(ids, DateTimeOffset.MinValue);

            // Act
            var result1 = await unitUnderTest.UpdateDates(command2);

            // Assert
            Assert.Equal((int)HttpStatusCode.BadRequest, GetStatusCode(result1));
        }
        public async Task <IActionResult> UpdateDates([FromBody] UpdateDatesGarmentFinishingOutCommand command)
        {
            VerifyUser();

            if (command.Date == null || command.Date == DateTimeOffset.MinValue)
            {
                return(BadRequest(new
                {
                    code = HttpStatusCode.BadRequest,
                    error = "Tanggal harus diisi"
                }));
            }
            else if (command.Date.Date > DateTimeOffset.Now.Date)
            {
                return(BadRequest(new
                {
                    code = HttpStatusCode.BadRequest,
                    error = "Tanggal tidak boleh lebih dari hari ini"
                }));
            }

            var order = await Mediator.Send(command);

            return(Ok());
        }
        public async Task Put_Dates_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            var           unitUnderTest = CreateGarmentFinishingOutController();
            Guid          sewingOutGuid = Guid.NewGuid();
            List <string> ids           = new List <string>();

            ids.Add(sewingOutGuid.ToString());

            UpdateDatesGarmentFinishingOutCommand command = new UpdateDatesGarmentFinishingOutCommand(ids, DateTimeOffset.Now);

            _MockMediator
            .Setup(s => s.Send(command, It.IsAny <CancellationToken>()))
            .ReturnsAsync(1);

            // Act
            var result = await unitUnderTest.UpdateDates(command);

            // Assert
            Assert.Equal((int)HttpStatusCode.OK, GetStatusCode(result));
        }