示例#1
0
        public DeleteCohortHandlerTestsFixture()
        {
            _autoFixture = new Fixture();

            CohortId = _autoFixture.Create <long>();
            UserInfo = _autoFixture.Create <UserInfo>();
            Logger   = new Mock <ILogger <DeleteCohortHandler> >();
            AuthenticationService = new Mock <IAuthenticationService>();

            Command = new DeleteCohortCommand {
                CohortId = CohortId, UserInfo = UserInfo
            };
            Db = new ProviderCommitmentsDbContext(new DbContextOptionsBuilder <ProviderCommitmentsDbContext>()
                                                  .UseInMemoryDatabase(Guid.NewGuid().ToString()).ConfigureWarnings(warnings =>
                                                                                                                    warnings.Throw(RelationalEventId.QueryClientEvaluationWarning)).Options);

            Sut = new DeleteCohortHandler(new Lazy <ProviderCommitmentsDbContext>(() => Db), Logger.Object, AuthenticationService.Object);
            UnitOfWorkContext = new UnitOfWorkContext();

            DraftApprenticeship = new DraftApprenticeship
            {
                Id            = _autoFixture.Create <long>(),
                FirstName     = "Test",
                LastName      = "Test",
                ReservationId = _autoFixture.Create <Guid>()
            };
        }
        public async Task <IActionResult> Delete(long cohortId, [FromBody] UserInfo userInfo, CancellationToken cancellationToken)
        {
            var command = new DeleteCohortCommand {
                CohortId = cohortId, UserInfo = userInfo
            };
            await _mediator.Send(command, cancellationToken);

            return(NoContent());
        }