コード例 #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);
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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();
        }