Esempio n. 1
0
        public async Task Handle_Success()
        {
            // Arrange
            var command = new CreateLabelCommand
            {
                Name        = "test-name",
                Description = "test-description",
                Color       = new CreateLabelCommanColor()
            };

            var expectedLabelId = Guid.NewGuid();

            _labelRepository
            .Setup(x => x.CreateAsync(It.IsAny <Label>()))
            .ReturnsAsync(expectedLabelId);

            // Act
            var response = await _handler.Handle(command, CancellationToken.None);

            // Assert
            _labelRepository.Verify(x => x.CreateAsync(It.IsAny <Label>()), Times.Once);
            _unitOfWork.Verify(x => x.CommitAsync(), Times.Once);

            Assert.That(response.Id, Is.EqualTo(expectedLabelId));
        }
Esempio n. 2
0
        public async Task <ActionResult> CreateLabel([FromBody] LabelCreateDTO labelDto)
        {
            var request = new CreateLabelCommand(User.Identity?.Name, labelDto);
            var readDto = await _mediator.Send(request);

            return(CreatedAtRoute(nameof(GetLabelById), new { Id = readDto.Id }, readDto));
        }
Esempio n. 3
0
        public async Task <IActionResult> CreateLabel([FromBody] NewLabelModel newLabel)
        {
            // TODO Add User Uid
            var command = new CreateLabelCommand
            {
                Name = newLabel.Title,
            };

            var result = await Mediator.Send(command).ConfigureAwait(false);

            return(CreateResponse(result));
        }