Пример #1
0
        public AddAccountLegalEntityCommandHandlerTestsFixture()
        {
            Db      = new ProviderRelationshipsDbContext(new DbContextOptionsBuilder <ProviderRelationshipsDbContext>().UseInMemoryDatabase(Guid.NewGuid().ToString()).ConfigureWarnings(warnings => warnings.Throw(RelationalEventId.QueryClientEvaluationWarning)).Options);
            Account = EntityActivator.CreateInstance <Account>().Set(a => a.Id, 1);

            Db.Accounts.Add(Account);
            Db.SaveChanges();

            Command = new AddAccountLegalEntityCommand(Account.Id, 2, "ALE123", "Foo", DateTime.UtcNow);
            Handler = new AddAccountLegalEntityCommandHandler(new Lazy <ProviderRelationshipsDbContext>(() => Db));
        }
Пример #2
0
        public UpdateAccountNameCommandHandlerTestsFixture()
        {
            OriginalAccountName = "Foo";
            Now     = DateTime.UtcNow;
            Account = EntityActivator.CreateInstance <Account>().Set(a => a.Id, 1).Set(a => a.Name, OriginalAccountName);
            Command = new UpdateAccountNameCommand(Account.Id, "Bar", Now.AddHours(-1));
            Db      = new ProviderRelationshipsDbContext(new DbContextOptionsBuilder <ProviderRelationshipsDbContext>().UseInMemoryDatabase(Guid.NewGuid().ToString()).ConfigureWarnings(warnings => warnings.Throw(RelationalEventId.QueryClientEvaluationWarning)).Options);

            Db.Accounts.Add(Account);
            Db.SaveChanges();

            Handler           = new UpdateAccountNameCommandHandler(new Lazy <ProviderRelationshipsDbContext>(() => Db));
            UnitOfWorkContext = new UnitOfWorkContext();
        }
Пример #3
0
        public SendDeletedPermissionsNotificationCommandHandlerTestsFixture()
        {
            Ukprn = 228876542;
            AccountLegalEntityId = 116;
            OrganisationName     = "TestOrg";

            Db      = new ProviderRelationshipsDbContext(new DbContextOptionsBuilder <ProviderRelationshipsDbContext>().UseInMemoryDatabase(Guid.NewGuid().ToString()).Options);
            Command = new SendDeletedPermissionsNotificationCommand(Ukprn, AccountLegalEntityId);
            Client  = new Mock <IPasAccountApiClient>();

            Db.AccountLegalEntities.Add(EntityActivator.CreateInstance <AccountLegalEntity>().Set(a => a.Id, AccountLegalEntityId).Set(a => a.Name, OrganisationName));
            Db.SaveChanges();

            Handler = new SendDeletedPermissionsNotificationCommandHandler(Client.Object, new Lazy <ProviderRelationshipsDbContext>(() => Db));
        }
        public ReceiveProviderRelationshipsHealthCheckEventCommandHandlerTestsFixture()
        {
            HealthChecks = new List <HealthCheck>
            {
                EntityActivator.CreateInstance <HealthCheck>().Set(h => h.Id, 1),
                EntityActivator.CreateInstance <HealthCheck>().Set(h => h.Id, 2)
            };

            Command = new ReceiveProviderRelationshipsHealthCheckEventCommand(HealthChecks[1].Id);
            Db      = new ProviderRelationshipsDbContext(new DbContextOptionsBuilder <ProviderRelationshipsDbContext>().UseInMemoryDatabase(Guid.NewGuid().ToString()).ConfigureWarnings(warnings => warnings.Throw(RelationalEventId.QueryClientEvaluationWarning)).Options);

            Db.HealthChecks.AddRange(HealthChecks);
            Db.SaveChanges();

            Handler = new ReceiveProviderRelationshipsHealthCheckEventCommandHandler(new Lazy <ProviderRelationshipsDbContext>(() => Db));
        }
Пример #5
0
        public RemoveAccountLegalEntityCommandHandlerTestsFixture()
        {
            Now                = DateTime.UtcNow;
            Account            = EntityActivator.CreateInstance <Account>().Set(a => a.Id, 1);
            AccountLegalEntity = EntityActivator.CreateInstance <AccountLegalEntity>().Set(ale => ale.Id, 2).Set(ale => ale.AccountId, Account.Id);
            AccountProvider    = EntityActivator.CreateInstance <AccountProvider>().Set(ap => ap.Id, 3).Set(ap => ap.AccountId, Account.Id).Set(ap => ap.ProviderUkprn, 12345678);
            Command            = new RemoveAccountLegalEntityCommand(Account.Id, AccountLegalEntity.Id, Now.AddHours(-1));
            Db = new ProviderRelationshipsDbContext(new DbContextOptionsBuilder <ProviderRelationshipsDbContext>().UseInMemoryDatabase(Guid.NewGuid().ToString()).ConfigureWarnings(warnings => warnings.Throw(RelationalEventId.QueryClientEvaluationWarning)).Options);

            Db.Accounts.Add(Account);
            Db.AccountLegalEntities.Add(AccountLegalEntity);
            Db.AccountProviders.Add(AccountProvider);
            Db.SaveChanges();

            Handler           = new RemoveAccountLegalEntityCommandHandler(new Lazy <ProviderRelationshipsDbContext>(() => Db));
            UnitOfWorkContext = new UnitOfWorkContext();
        }
Пример #6
0
        public AddAccountProviderCommandHandlerTestsFixture()
        {
            Db       = new ProviderRelationshipsDbContext(new DbContextOptionsBuilder <ProviderRelationshipsDbContext>().UseInMemoryDatabase(Guid.NewGuid().ToString()).ConfigureWarnings(warnings => warnings.Throw(RelationalEventId.QueryClientEvaluationWarning)).Options);
            Account  = EntityActivator.CreateInstance <Account>().Set(a => a.Id, 1);
            User     = EntityActivator.CreateInstance <User>().Set(u => u.Ref, Guid.NewGuid());
            Provider = EntityActivator.CreateInstance <Provider>().Set(p => p.Ukprn, 12345678);

            Db.Accounts.Add(Account);
            Db.Users.Add(User);
            Db.Providers.Add(Provider);
            Db.SaveChanges();

            Command           = new AddAccountProviderCommand(Account.Id, Provider.Ukprn, User.Ref);
            Now               = DateTime.UtcNow;
            UnitOfWorkContext = new UnitOfWorkContext();
            Handler           = new AddAccountProviderCommandHandler(new Lazy <ProviderRelationshipsDbContext>(() => Db));
        }
Пример #7
0
        public GetHealthCheckQueryHandlerTestsFixture()
        {
            GetHealthCheckQuery = new GetHealthCheckQuery();
            Db = new ProviderRelationshipsDbContext(new DbContextOptionsBuilder <ProviderRelationshipsDbContext>().UseInMemoryDatabase(Guid.NewGuid().ToString()).ConfigureWarnings(warnings => warnings.Throw(RelationalEventId.QueryClientEvaluationWarning)).Options);
            ConfigurationProvider = new MapperConfiguration(c => c.AddProfiles(typeof(HealthCheckMappings)));

            HealthChecks = new List <HealthCheck>
            {
                EntityActivator.CreateInstance <HealthCheck>().Set(h => h.Id, 1),
                EntityActivator.CreateInstance <HealthCheck>().Set(h => h.Id, 2)
            };

            Db.HealthChecks.AddRange(HealthChecks);
            Db.SaveChanges();

            Handler = new GetHealthCheckQueryHandler(new Lazy <ProviderRelationshipsDbContext>(() => Db), ConfigurationProvider);
        }
        public RunHealthCheckCommandHandlerTestsFixture()
        {
            Db   = new ProviderRelationshipsDbContext(new DbContextOptionsBuilder <ProviderRelationshipsDbContext>().UseInMemoryDatabase(Guid.NewGuid().ToString()).ConfigureWarnings(warnings => warnings.Throw(RelationalEventId.QueryClientEvaluationWarning)).Options);
            User = EntityActivator.CreateInstance <User>().Set(u => u.Ref, Guid.NewGuid());
            RunHealthCheckCommand          = new RunHealthCheckCommand(User.Ref);
            UnitOfWorkContext              = new UnitOfWorkContext();
            ProviderApiClient              = new Mock <IRoatpService>();
            ProviderRelationshipsApiClient = new Mock <IProviderRelationshipsApiClient>();
            CancellationToken              = new CancellationToken();

            Db.Users.Add(User);
            Db.SaveChanges();

            ProviderApiClient.Setup(c => c.Ping()).ReturnsAsync(true);
            ProviderRelationshipsApiClient.Setup(c => c.Ping(CancellationToken)).Returns(Task.CompletedTask);

            Handler = new RunHealthCheckCommandHandler(new Lazy <ProviderRelationshipsDbContext>(() => Db), ProviderApiClient.Object, ProviderRelationshipsApiClient.Object);
        }
Пример #9
0
        public UpdatePermissionsCommandHandlerTestsFixture()
        {
            Now = DateTime.UtcNow;;
            UnitOfWorkContext = new UnitOfWorkContext();
            Db      = new ProviderRelationshipsDbContext(new DbContextOptionsBuilder <ProviderRelationshipsDbContext>().UseInMemoryDatabase(Guid.NewGuid().ToString()).Options);
            Command = new UpdatePermissionsCommand(1, 2, 3, Guid.NewGuid(), new HashSet <Operation> {
                Operation.CreateCohort
            });
            Account            = EntityActivator.CreateInstance <Account>().Set(a => a.Id, Command.AccountId);
            AccountProvider    = EntityActivator.CreateInstance <AccountProvider>().Set(ap => ap.Id, Command.AccountProviderId).Set(ap => ap.AccountId, Account.Id);
            AccountLegalEntity = EntityActivator.CreateInstance <AccountLegalEntity>().Set(ale => ale.Id, Command.AccountLegalEntityId).Set(ale => ale.AccountId, Account.Id);
            User = EntityActivator.CreateInstance <User>().Set(u => u.Ref, Command.UserRef);

            Db.Accounts.Add(Account);
            Db.AccountProviders.Add(AccountProvider);
            Db.AccountLegalEntities.Add(AccountLegalEntity);
            Db.Users.Add(User);
            Db.SaveChanges();

            Handler = new UpdatePermissionsCommandHandler(new Lazy <ProviderRelationshipsDbContext>(() => Db));
        }