Ejemplo n.º 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 DeleteTransferConnectionInvitationTestFixture()
 {
     EmployerAccountRepositoryMock = new Mock <IEmployerAccountRepository>();
     TransferConnectionInvitationRepositoryMock = new Mock <ITransferConnectionInvitationRepository>();
     UserRepositoryMock = new Mock <IUserAccountRepository>();
     UnitOfWorkContext  = new UnitOfWorkContext();
 }
Ejemplo n.º 3
0
            public WhenCohortIsCreatedTestFixture()
            {
                UnitOfWorkContext = new UnitOfWorkContext();

                ReservationId = _autoFixture.Create <Guid>();
                UserInfo      = _autoFixture.Create <UserInfo>();

                var cohort = new CommitmentsV2.Models.Cohort();

                cohort.SetValue(x => x.ProviderId, _autoFixture.Create <long>());

                ContinuedApprenticeship = new CommitmentsV2.Models.Apprenticeship();
                ContinuedApprenticeship.SetValue(x => x.Id, _autoFixture.Create <long>());
                ContinuedApprenticeship.SetValue(x => x.Cohort, cohort);
                ContinuedApprenticeship.SetValue(x => x.CommitmentId, cohort.Id);
                ContinuedApprenticeship.SetValue(x => x.FirstName, _autoFixture.Create <string>());
                ContinuedApprenticeship.SetValue(x => x.LastName, _autoFixture.Create <string>());
                ContinuedApprenticeship.SetValue(x => x.DateOfBirth, _autoFixture.Create <DateTime>());
                ContinuedApprenticeship.SetValue(x => x.Uln, _autoFixture.Create <string>());
                ContinuedApprenticeship.SetValue(x => x.StartDate, _autoFixture.Create <DateTime?>());
                ContinuedApprenticeship.SetValue(x => x.EndDate, _autoFixture.Create <DateTime?>());
                ContinuedApprenticeship.SetValue(x => x.StartDate, _autoFixture.Create <DateTime?>());
                ContinuedApprenticeship.SetValue(x => x.CourseCode, _autoFixture.Create <string>());
                ContinuedApprenticeship.SetValue(x => x.CourseName, _autoFixture.Create <string>());
                ContinuedApprenticeship.SetValue(x => x.ProgrammeType, _autoFixture.Create <ProgrammeType>());
                ContinuedApprenticeship.SetValue(x => x.EmployerRef, _autoFixture.Create <string>());
                ContinuedApprenticeship.SetValue(x => x.ProviderRef, _autoFixture.Create <string>());

                Request = new CommitmentsV2.Models.ChangeOfPartyRequest();
                Request.SetValue(x => x.Apprenticeship, ContinuedApprenticeship);
                Request.SetValue(x => x.ApprenticeshipId, ContinuedApprenticeship.Id);
                Request.SetValue(x => x.StartDate, _autoFixture.Create <DateTime?>());
                Request.SetValue(x => x.Price, _autoFixture.Create <int?>());
                Request.SetValue(x => x.OriginatingParty, _autoFixture.Create <Party>());
            }
        public ProcessLevyDeclarationsCommandHandlerTestsFixture()
        {
            Fixture           = new Fixture();
            Now               = DateTime.UtcNow;
            UnitOfWorkContext = new UnitOfWorkContext();

            EmployerReferenceNumbers = new List <string>
            {
                "AAA111",
                "BBB222",
                "CCC333"
            };

            Accounts = new List <Account>
            {
                Fixture.Create <Account>(),
                Fixture.Create <Account>()
            };

            AccountPayeSchemes = new List <AccountPayeScheme>
            {
                new AccountPayeScheme(Accounts[0], EmployerReferenceNumbers[0], Now).Set(aps => aps.Id, 1),
                new AccountPayeScheme(Accounts[0], EmployerReferenceNumbers[1], Now).Set(aps => aps.Id, 2),
                new AccountPayeScheme(Accounts[1], EmployerReferenceNumbers[2], Now).Set(aps => aps.Id, 3)
            };

            Command = new ProcessLevyDeclarationsCommand(Now);
            Db      = new EmployerFinanceDbContext(new DbContextOptionsBuilder <EmployerFinanceDbContext>().UseInMemoryDatabase(Guid.NewGuid().ToString()).Options);

            Db.AccountPayeSchemes.AddRange(AccountPayeSchemes);
            Db.SaveChanges();

            Handler = new ProcessLevyDeclarationsCommandHandler(Db);
        }
        public UnitOfWorkContextTestsFixture SetEvents()
        {
            var fooEvent = new FooEvent {
                Created = Now
            };
            var barEvent = new BarEvent {
                Created = Now
            };

            Events.Add(fooEvent);
            Events.Add(barEvent);

            UnitOfWorkContextInstance.AddEvent(fooEvent);
            UnitOfWorkContextInstance.AddEvent(() => new FooEvent {
                Created = Now
            });
            UnitOfWorkContext.AddEvent(barEvent);
            UnitOfWorkContext.AddEvent(() => new BarEvent {
                Created = Now
            });

            Now = DateTime.UtcNow;

            return(this);
        }
Ejemplo n.º 6
0
        public CohortAssignedToEmployerEventHandlerForLegacyTaskCounterTestsFixture()
        {
            _fixture          = new Fixture();
            UnitOfWorkContext = new UnitOfWorkContext();

            Db = new ProviderCommitmentsDbContext(new DbContextOptionsBuilder <ProviderCommitmentsDbContext>()
                                                  .UseInMemoryDatabase(Guid.NewGuid().ToString())
                                                  .ConfigureWarnings(w => w.Throw(RelationalEventId.QueryClientEvaluationWarning))
                                                  .Options);
            CohortId = _fixture.Create <long>();
            Now      = DateTime.UtcNow;

            LegacyTopicMessagePublisher = new Mock <ILegacyTopicMessagePublisher>();
            Logger  = new FakeLogger <CohortAssignedToEmployerEventHandlerForLegacyTaskCounter>();
            Handler = new CohortAssignedToEmployerEventHandlerForLegacyTaskCounter(new Lazy <ProviderCommitmentsDbContext>(() => Db), LegacyTopicMessagePublisher.Object, Logger);

            Cohort = new Cohort(
                _fixture.Create <long>(),
                _fixture.Create <long>(),
                _fixture.Create <long>(),
                null,
                Party.Employer,
                "",
                new UserInfo())
            {
                Id = CohortId, EmployerAccountId = 100, TransferSenderId = 99
            };
            Cohort.WithParty = Party.Employer;
        }
 public void VerifyApprenticeshipTracking()
 {
     Assert.IsNotNull(UnitOfWorkContext.GetEvents().SingleOrDefault(x => x is EntityStateChangedEvent @event &&
                                                                    @event.EntityType == nameof(Apprenticeship) &&
                                                                    @event.ProviderId == Apprenticeship.Cohort.ProviderId &&
                                                                    @event.EmployerAccountId == Apprenticeship.Cohort.EmployerAccountId));
 }
        public TransferRequestRejectedEventHandlerTestsFixture()
        {
            _fixture          = new Fixture();
            UnitOfWorkContext = new UnitOfWorkContext();
            Db = new ProviderCommitmentsDbContext(new DbContextOptionsBuilder <ProviderCommitmentsDbContext>()
                                                  .UseInMemoryDatabase(Guid.NewGuid().ToString())
                                                  .ConfigureWarnings(w => w.Throw(RelationalEventId.QueryClientEvaluationWarning))
                                                  .Options);

            TransferRequestRejectedEvent = _fixture.Create <TransferRequestRejectedEvent>();

            Logger = new FakeLogger <TransferRequestRejectedEvent>();
            LegacyTopicMessagePublisher = new Mock <ILegacyTopicMessagePublisher>();
            Handler = new TransferRequestRejectedEventHandler(new Lazy <ProviderCommitmentsDbContext>(() => Db), LegacyTopicMessagePublisher.Object, Logger);

            Cohort = new Cohort(
                _fixture.Create <long>(),
                _fixture.Create <long>(),
                _fixture.Create <long>(),
                null,
                Party.Employer,
                "",
                new UserInfo())
            {
                Id = TransferRequestRejectedEvent.CohortId, EmployerAccountId = 100, TransferSenderId = 99
            };

            ExistingApprenticeshipDetails = new DraftApprenticeship(_fixture.Build <DraftApprenticeshipDetails>().Create(), Party.Provider);
            Cohort.Apprenticeships.Add(ExistingApprenticeshipDetails);
            Cohort.WithParty = Party.TransferSender;
            Cohort.TransferApprovalStatus = TransferApprovalStatus.Pending;
        }
Ejemplo n.º 9
0
        public UnitOfWorkContextTestsFixture SetEventsOnSeparateThreads()
        {
            var fooEvent = new FooEvent {
                Created = Now
            };
            var barEvent = new BarEvent {
                Created = Now
            };

            Events.Add(fooEvent);
            Events.Add(barEvent);

            var tasks = new List <Task>
            {
                Task.Run(() =>
                {
                    UnitOfWorkContextInstance.AddEvent(fooEvent);
                    UnitOfWorkContextInstance.AddEvent <FooEvent>(e => e.Created = Now);
                }),
                Task.Run(() =>
                {
                    UnitOfWorkContext.AddEvent(barEvent);
                    UnitOfWorkContext.AddEvent <BarEvent>(e => e.Created = Now);
                })
            };

            Task.WhenAll(tasks).GetAwaiter().GetResult();

            Now = DateTime.UtcNow;

            return(this);
        }
        public RejectTransferRequestCommandHandlerTestsFixture()
        {
            _transferRequestId = 235;
            _userInfo          = new UserInfo
            {
                UserDisplayName = "TestName",
                UserEmail       = "*****@*****.**",
                UserId          = "23432"
            };
            _transferRequest = new TransferRequest {
                Id = _transferRequestId
            };
            _cohort = new Cohort
            {
                TransferRequests     = { _transferRequest },
                EmployerAccountId    = 8787,
                AccountLegalEntityId = 234,
                //AccountLegalEntityPublicHashedId = "sfs1",
                ProviderId       = 234234,
                TransferSenderId = 8999
            };
            _db = new ProviderCommitmentsDbContext(new DbContextOptionsBuilder <ProviderCommitmentsDbContext>()
                                                   .UseInMemoryDatabase(Guid.NewGuid().ToString())
                                                   .ConfigureWarnings(w => w.Throw(RelationalEventId.QueryClientEvaluationWarning))
                                                   .Options);

            _logger = new FakeLogger <RejectTransferRequestCommandHandler>();
            _mockMessageHandlerContext = new Mock <IMessageHandlerContext>();
            _rejectedOnDate            = new DateTime(2020, 01, 30, 14, 22, 00);
            _command           = new RejectTransferRequestCommand(_transferRequestId, _rejectedOnDate, _userInfo);
            _unitOfWorkContext = new UnitOfWorkContext();
            _sut = new RejectTransferRequestCommandHandler(new Lazy <ProviderCommitmentsDbContext>(() => _db), _logger);
        }
Ejemplo n.º 11
0
 public HealthCheckTestsFixture()
 {
     User = EntityActivator.CreateInstance <User>().Set(u => u.Ref, Guid.NewGuid());
     UnitOfWorkContext = new UnitOfWorkContext();
     ApprenticeshipInfoServiceApiRequest = () => Task.CompletedTask;
     ProviderRelationshipsApiRequest     = () => Task.CompletedTask;
 }
        public AddTransferRequestCommandHandlerTestFixture()
        {
            Fixture           = new Fixture();
            CancellationToken = new CancellationToken();

            FundingCapCourseSummary1 = new FundingCapCourseSummary
            {
                ActualCap = 1000, ApprenticeshipCount = 1, CappedCost = 1200, CourseTitle = "C1Title"
            };
            FundingCapCourseSummary2 = new FundingCapCourseSummary
            {
                ActualCap = 1100, ApprenticeshipCount = 2, CappedCost = 1300, CourseTitle = "C2Title"
            };
            FundingService = new Mock <IFundingCapService>();
            FundingService.Setup(x => x.FundingCourseSummary(It.IsAny <IEnumerable <ApprenticeshipBase> >()))
            .ReturnsAsync(new List <FundingCapCourseSummary> {
                FundingCapCourseSummary1, FundingCapCourseSummary2
            });

            Db = new ProviderCommitmentsDbContext(new DbContextOptionsBuilder <ProviderCommitmentsDbContext>()
                                                  .UseInMemoryDatabase(Guid.NewGuid().ToString())
                                                  .ConfigureWarnings(w => w.Throw(RelationalEventId.QueryClientEvaluationWarning))
                                                  .Options);

            Handler = new AddTransferRequestCommandHandler(
                new Lazy <ProviderCommitmentsDbContext>(() => Db),
                FundingService.Object,
                Mock.Of <ILogger <AddTransferRequestCommandHandler> >());

            UnitOfWorkContext   = new UnitOfWorkContext();
            LastApprovedByParty = Party.Employer;
        }
Ejemplo n.º 13
0
            public ChangeTrackingSessionTestsFixture()
            {
                UnitOfWorkContext = new UnitOfWorkContext();

                var autoFixture = new Fixture();

                ProviderId        = autoFixture.Create <long>();
                EmployerAccountId = autoFixture.Create <long>();
                UserInfo          = autoFixture.Create <UserInfo>();
                UserAction        = autoFixture.Create <UserAction>();
                Party             = autoFixture.Create <Party>();

                TestUpdateTrackableEntity = new TestTrackableEntity(autoFixture.Create <long>());
                TestInsertTrackableEntity = new TestTrackableEntity(autoFixture.Create <long>());
                TestDeleteTrackableEntity = new TestTrackableEntity(autoFixture.Create <long>());

                TestUpdateInitialState = autoFixture.Create <Dictionary <string, object> >();
                TestDeleteInitialState = autoFixture.Create <Dictionary <string, object> >();
                TestInsertUpdatedState = autoFixture.Create <Dictionary <string, object> >();
                TestUpdateUpdatedState = autoFixture.Create <Dictionary <string, object> >();

                StateService = new Mock <IStateService>();
                StateService.Setup(x => x.GetState(It.Is <object>(o => o == TestUpdateTrackableEntity))).Returns(TestUpdateInitialState);
                StateService.Setup(x => x.GetState(It.Is <object>(o => o == TestDeleteTrackableEntity))).Returns(TestDeleteInitialState);

                ChangeTrackingSession = new ChangeTrackingSession(StateService.Object, UserAction, Party, EmployerAccountId, ProviderId, UserInfo);
            }
Ejemplo n.º 14
0
        public ChangeOfPartyRequestCreationTestFixture()
        {
            var autoFixture = new Fixture();

            UnitOfWorkContext = new UnitOfWorkContext();

            Now = DateTime.UtcNow;

            Apprenticeship = new CommitmentsV2.Models.Apprenticeship
            {
                Id     = autoFixture.Create <long>(),
                Cohort = new CommitmentsV2.Models.Cohort
                {
                    EmployerAccountId = autoFixture.Create <long>(),
                    ProviderId        = autoFixture.Create <long>()
                }
            };

            RequestType      = ChangeOfPartyRequestType.ChangeEmployer;
            OriginatingParty = Party.Provider;
            NewPartyId       = autoFixture.Create <long>();
            Price            = autoFixture.Create <int>();
            StartDate        = autoFixture.Create <DateTime>();
            EndDate          = autoFixture.Create <DateTime?>();
            UserInfo         = new UserInfo();
        }
        /// <summary>
        ///  删除指定编号的记录
        /// </summary>
        /// <param name="id"> 实体记录编号 </param>
        /// <param name="isSave"> 是否执行保存 </param>
        /// <returns> 操作影响的行数 </returns>
        public virtual async Task <int> DeleteAsync(object id, bool isSave = true)
        {
            PublicHelper.CheckArgument(id, "id");
            TEntity entity = UnitOfWorkContext.Set <TEntity>().Find(id);

            return(entity != null ? await SaveAsync() : 0);
        }
Ejemplo n.º 16
0
        public CohortCreationWithOtherPartyTestFixture()
        {
            UnitOfWorkContext = new UnitOfWorkContext();
            Provider          = new CommitmentsV2.Models.Provider(_autoFixture.Create <long>(), _autoFixture.Create <string>(),
                                                                  _autoFixture.Create <DateTime>(), _autoFixture.Create <DateTime>());

            var account = new Account(_autoFixture.Create <long>(), _autoFixture.Create <string>(),
                                      _autoFixture.Create <string>(), _autoFixture.Create <string>(), _autoFixture.Create <DateTime>());

            UserInfo = _autoFixture.Create <UserInfo>();

            AccountLegalEntity = new AccountLegalEntity(account,
                                                        _autoFixture.Create <long>(),
                                                        _autoFixture.Create <long>(),
                                                        _autoFixture.Create <string>(),
                                                        _autoFixture.Create <string>(),
                                                        _autoFixture.Create <string>(),
                                                        _autoFixture.Create <OrganisationType>(),
                                                        _autoFixture.Create <string>(),
                                                        _autoFixture.Create <DateTime>());

            TransferSenderId   = _autoFixture.Create <long>();
            TransferSenderName = _autoFixture.Create <string>();
            TransferSender     = new Account(TransferSenderId.Value, "XXX", "ZZZ", TransferSenderName, new DateTime());
        }
        /// <summary>
        ///  删除指定编号的记录
        /// </summary>
        /// <param name="id"> 实体记录编号 </param>
        /// <param name="isSave"> 是否执行保存 </param>
        /// <returns> 操作影响的行数 </returns>
        public virtual int Delete(object id, bool isSave = true)
        {
            PublicHelper.CheckArgument(id, "id");
            TEntity entity = UnitOfWorkContext.Set <TEntity>().Find(id);

            return(entity != null?Delete(entity, isSave) : 0);
        }
        public WhenResumingAnApprenticeshipFixture(PaymentStatus paymentStatus)
        {
            var fixture = new Fixture();

            fixture.Behaviors.Add(new OmitOnRecursionBehavior());

            Now = DateTime.UtcNow;

            CurrentDateTime = new Mock <ICurrentDateTime>();
            CurrentDateTime.Setup(x => x.UtcNow).Returns(Now);
            PauseDate         = Now;
            EndDate           = Now;
            UnitOfWorkContext = new UnitOfWorkContext();

            Cohort = new CommitmentsV2.Models.Cohort()
                     .Set(c => c.Id, 111)
                     .Set(c => c.EmployerAccountId, 222)
                     .Set(c => c.ProviderId, 333);

            UserInfo = fixture.Create <UserInfo>();

            Apprenticeship = fixture.Build <CommitmentsV2.Models.Apprenticeship>()
                             .With(s => s.Cohort, Cohort)
                             .With(s => s.PaymentStatus, paymentStatus)
                             .With(s => s.PauseDate, PauseDate)
                             .Without(s => s.EndDate)
                             .Without(s => s.DataLockStatus)
                             .Without(s => s.EpaOrg)
                             .Without(s => s.ApprenticeshipUpdate)
                             .Without(s => s.Continuation)
                             .Without(s => s.PreviousApprenticeship)
                             .Create();
        }
Ejemplo n.º 19
0
        public TransferRequestCreatedEventHandlerTestsFixture()
        {
            var fixture = new Fixture();

            UnitOfWorkContext           = new UnitOfWorkContext();
            MessageHandlerContext       = new Mock <IMessageHandlerContext>();
            LegacyTopicMessagePublisher = new Mock <ILegacyTopicMessagePublisher>();

            Db = new ProviderCommitmentsDbContext(new DbContextOptionsBuilder <ProviderCommitmentsDbContext>()
                                                  .UseInMemoryDatabase(Guid.NewGuid().ToString())
                                                  .ConfigureWarnings(w => w.Throw(RelationalEventId.QueryClientEvaluationWarning))
                                                  .Options);

            Sut = new TransferRequestCreatedEventHandler(LegacyTopicMessagePublisher.Object, Mock.Of <ILogger <TransferRequestCreatedEvent> >(), new Lazy <ProviderCommitmentsDbContext>(() => Db));

            Cohort = new Cohort(
                fixture.Create <long>(),
                fixture.Create <long>(),
                fixture.Create <long>(),
                null,
                Party.Employer,
                "",
                new UserInfo())
            {
                EmployerAccountId = 100, TransferSenderId = 99
            };

            TransferRequest = new TransferRequest
            {
                Status = TransferApprovalStatus.Pending, Cost = 1000, Cohort = Cohort
            };
        }
        public void CompleteTrackingSession()
        {
            foreach (var item in _trackedItems)
            {
                UnitOfWorkContext.AddEvent(() =>
                {
                    var updated = item.Operation == ChangeTrackingOperation.Delete ? null : _stateService.GetState(item.TrackedEntity);

                    var result = new EntityStateChangedEvent
                    {
                        CorrelationId     = _correlationId,
                        StateChangeType   = _userAction,
                        EntityType        = item.TrackedEntity.GetType().Name,
                        EntityId          = item.TrackedEntity.Id,
                        ProviderId        = _providerId,
                        EmployerAccountId = _employerAccountId,
                        InitialState      = item.InitialState == null ? null : JsonConvert.SerializeObject(item.InitialState),
                        UpdatedState      = updated == null ? null : JsonConvert.SerializeObject(updated),
                        UpdatedOn         = DateTime.UtcNow,
                        UpdatingParty     = _party,
                        UpdatingUserId    = _userInfo?.UserId ?? "Unknown",
                        UpdatingUserName  = _userInfo?.UserDisplayName ?? "Unknown"
                    };

                    return(result);
                });
            }

            _trackedItems.Clear();
        }
Ejemplo n.º 21
0
            public WhenAddingDraftApprenticeshipTestsFixture()
            {
                Now     = DateTime.UtcNow;
                Fixture = new Fixture();

                Cohort = Fixture.Build <CommitmentsV2.Models.Cohort>()
                         .OmitAutoProperties()
                         .With(c => c.Id)
                         .With(c => c.ProviderId, 1)
                         .With(c => c.EditStatus, EditStatus.ProviderOnly)
                         .Create();

                DraftApprenticeshipDetails = Fixture.Build <DraftApprenticeshipDetails>()
                                             .Without(d => d.StartDate)
                                             .Without(d => d.EndDate)
                                             .Without(d => d.DateOfBirth)
                                             .Without(d => d.Uln)
                                             .Create();

                ExistingApprenticeshipDetails = new DraftApprenticeship(Fixture.Build <DraftApprenticeshipDetails>().Create(), Party.Provider);

                Party             = Party.Provider;
                UnitOfWorkContext = new UnitOfWorkContext();
                UserInfo          = Fixture.Create <UserInfo>();
            }
Ejemplo n.º 22
0
 public async void Save()
 {
     using (_unitOfWork = new UnitOfWorkContext())
     {
         _unitOfWork.Save();
     }
 }
Ejemplo n.º 23
0
        public void Init()
        {
            var databaseGuid = Guid.NewGuid().ToString();

            _dbContext = new ProviderCommitmentsDbContext(new DbContextOptionsBuilder <ProviderCommitmentsDbContext>()
                                                          .UseInMemoryDatabase(databaseGuid)
                                                          .ConfigureWarnings(warnings => warnings.Throw(RelationalEventId.QueryClientEvaluationWarning))
                                                          .Options);

            _confirmationDbContext = new ProviderCommitmentsDbContext(new DbContextOptionsBuilder <ProviderCommitmentsDbContext>()
                                                                      .UseInMemoryDatabase(databaseGuid)
                                                                      .ConfigureWarnings(warnings => warnings.Throw(RelationalEventId.QueryClientEvaluationWarning))
                                                                      .Options);

            _currentDateTime       = new Mock <ICurrentDateTime>();
            _authenticationService = new Mock <IAuthenticationService>();
            _nserviceBusContext    = new Mock <IMessageSession>();
            _encodingService       = new Mock <IEncodingService>();
            _logger            = new Mock <ILogger <StopApprenticeshipCommandHandler> >();
            _unitOfWorkContext = new UnitOfWorkContext();

            _handler = new StopApprenticeshipCommandHandler(new Lazy <ProviderCommitmentsDbContext>(() => _dbContext),
                                                            _currentDateTime.Object,
                                                            _authenticationService.Object,
                                                            _nserviceBusContext.Object,
                                                            _encodingService.Object,
                                                            _logger.Object);
        }
Ejemplo n.º 24
0
 public async Task <List <ProductModel> > GetAllProduct()
 {
     using (_unitOfWork = new UnitOfWorkContext())
     {
         var sel = _unitOfWork.ProductRepository.GetAll().ToProductModel();
         return(sel);
     }
 }
 public WhenDeletingDraftApprenticeshipFixture()
 {
     CohortSize = 10;
     // We need this to allow the UoW to initialise it's internal static events collection.
     UserInfo = _autoFixture.Create <UserInfo>();
     CreateCohort();
     UnitOfWorkContext = new UnitOfWorkContext();
 }
Ejemplo n.º 26
0
 public async Task <bool> UpdateProduct(ProductModel product)
 {
     using (_unitOfWork = new UnitOfWorkContext())
     {
         var sel = _unitOfWork.ProductRepository.Update(product.Cast <DomainClasses.Product.Product>());
         return(sel);
     }
 }
Ejemplo n.º 27
0
 public async Task <bool> DeleteById(long ProductId)
 {
     using (_unitOfWork = new UnitOfWorkContext())
     {
         var sel = _unitOfWork.ProductRepository.Delete(ProductId);
         return(sel);
     }
 }
Ejemplo n.º 28
0
 public async Task <ProductModel> Get(long ProductId)
 {
     using (_unitOfWork = new UnitOfWorkContext())
     {
         var sel = _unitOfWork.ProductRepository.GetByID(ProductId).Cast <ProductModel>();
         return(sel);
     }
 }
Ejemplo n.º 29
0
        public async Task <IActionResult> GenerateFixtures(Guid leagueId, Guid id, [FromBody] GenerateFixtureSettings settings)
        {
            var unitOfWork = new GenerateFixturesUnitOfWork(GeneratorService, settings, leagueId, id);

            var task = UnitOfWorkContext.Run(unitOfWork);

            return(await task.Handle <IActionResult, ServiceModel <IGenerateFixtureSettings, IEnumerable <Fixture> > >(s => new ObjectResult(s), e => new BadRequestObjectResult(e)));;
        }
        public void AssertTransferRequestCreatedEventWasPublished()
        {
            var @event = UnitOfWorkContext.GetEvents().OfType <TransferRequestCreatedEvent>().First();

            Assert.AreEqual(CohortId, @event.CohortId);
            Assert.AreEqual(LastApprovedByParty, @event.LastApprovedByParty);
            Assert.IsNotNull(@event.TransferRequestId);
        }