Exemple #1
0
        public async Task DeleteRoute(int customerId, int rideId, int id, [FromBody] DeleteRouteCommand command)
        {
            command.SetArguments(customerId, rideId);
            command.RouteId = id;

            await Mediator.Send(command);
        }
        public async Task Handle_GivenNotFoundException()
        {
            //Arrange
            const int invalidId = 40;
            var       command   = new DeleteRouteCommand {
                Id = invalidId
            };

            //Assert
            await Assert.ThrowsAsync <NotFoundException>(() => _handler.Handle(command, CancellationToken.None));
        }
        public async Task Handle_GivenValidResult()
        {
            //Arrange
            const int deleteId = 18;
            var       command  = new DeleteRouteCommand {
                Id = deleteId
            };

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

            var unit = await Context.Routes.FindAsync(deleteId);

            //Assert
            Assert.Null(unit);
        }
        public void DeleteRoute_CallIRouteRepositoryRemove(
            [Frozen] IRouteRepository routeRepository,
            [Frozen] IRouteFactory routeFactory,
            DeleteRouteCommand message,
            Route route,
            DeleteRouteCommandHandler deleteRouteCommandHandler)
        {
            //Information
            A.CallTo(() => routeRepository.GetById(message.RouteId)).Returns(route);

            //Act
            deleteRouteCommandHandler.ExecuteAsync(message);

            //Test
            A.CallTo(() => routeRepository.Remove(route)).MustHaveHappened();
        }