Ejemplo n.º 1
0
        public async Task <IActionResult> Delete([FromBody] Guid id)
        {
            var user = await _userManagerWrapper.FindByNameAsync(User.Identity.Name);

            var deleteCalendarEventCommand = new DeleteCalendarEventCommand {
                Id = id, UserId = user.Id
            };
            await _endpointInstance.Send("LifeManager.Calendar", deleteCalendarEventCommand).ConfigureAwait(false);

            return(Ok());
        }
        public async Task HandleDelete_ShouldCallDeleteOnService()
        {
            // Data
            var deleteCalendarEventCommand = new DeleteCalendarEventCommand {
                Id = Guid.NewGuid(), UserId = "test"
            };

            // Setup
            _mockCalendarService.Setup(x => x.DeleteEvent(It.Is <Guid>(y => y == deleteCalendarEventCommand.Id), It.Is <string>(y => y == "test")))
            .Returns(Task.CompletedTask).Verifiable();

            // Test
            var handler = new CalendarEventHandler(_mockCalendarService.Object);
            await handler.Handle(deleteCalendarEventCommand, _mockMessageHandlerContext.Object);

            // Analysis
            _mockCalendarService.Verify();
        }
Ejemplo n.º 3
0
 public async Task Handle(DeleteCalendarEventCommand message, IMessageHandlerContext context)
 {
     await _calendarService.DeleteEvent(message.Id, message.UserId);
 }