public GetAccountProviderQueryHandlerTestsFixture SetAccountProviders() { Account = EntityActivator.CreateInstance <Account>().Set(a => a.Id, Query.AccountId); Provider = EntityActivator.CreateInstance <Provider>().Set(p => p.Ukprn, 12345678).Set(p => p.Name, "Foo"); AccountProvider = EntityActivator.CreateInstance <AccountProvider>().Set(ap => ap.Id, Query.AccountProviderId).Set(ap => ap.AccountId, Account.Id).Set(ap => ap.ProviderUkprn, Provider.Ukprn); AccountLegalEntity = EntityActivator.CreateInstance <AccountLegalEntity>().Set(ale => ale.Id, 3).Set(ale => ale.Name, "Bar").Set(ale => ale.AccountId, Account.Id); AccountProviderLegalEntity = EntityActivator.CreateInstance <AccountProviderLegalEntity>().Set(aple => aple.Id, 4).Set(aple => aple.AccountProviderId, AccountProvider.Id).Set(aple => aple.AccountLegalEntityId, AccountLegalEntity.Id); Permission = EntityActivator.CreateInstance <Permission>().Set(p => p.Id, 5).Set(p => p.AccountProviderLegalEntityId, AccountProviderLegalEntity.Id).Set(p => p.Operation, Operation.CreateCohort); Db.Accounts.Add(Account); Db.Providers.Add(Provider); Db.AccountProviders.Add(AccountProvider); Db.AccountLegalEntities.Add(AccountLegalEntity); Db.AccountProviderLegalEntities.Add(AccountProviderLegalEntity); Db.Permissions.Add(Permission); Db.SaveChanges(); return(this); }
public GetUpdatedAccountProviderLegalEntityQueryHandlerTestsFixture SetAccountProviderLegalEntity() { Account = EntityActivator.CreateInstance <Account>().Set(a => a.Id, Query.AccountId); Provider = EntityActivator.CreateInstance <Provider>() .Set(p => p.Ukprn, 12345678) .Set(p => p.Name, "Provider"); AccountProvider = EntityActivator.CreateInstance <AccountProvider>() .Set(ap => ap.Id, Query.AccountProviderId) .Set(ap => ap.AccountId, Account.Id) .Set(ap => ap.Provider, Provider); AccountLegalEntity = EntityActivator.CreateInstance <AccountLegalEntity>() .Set(ale => ale.Id, Query.AccountLegalEntityId) .Set(ale => ale.Name, "Account legal entity A") .Set(ale => ale.AccountId, Account.Id); AccountLegalEntities = new List <AccountLegalEntity> { AccountLegalEntity, EntityActivator.CreateInstance <AccountLegalEntity>() .Set(ale => ale.Id, 5) .Set(ale => ale.Name, "Account legal entity B") .Set(ale => ale.AccountId, Account.Id), EntityActivator.CreateInstance <AccountLegalEntity>() .Set(ale => ale.Id, 6) .Set(ale => ale.Name, "Account legal entity C") .Set(ale => ale.AccountId, 2) }; AccountProviderLegalEntity = EntityActivator.CreateInstance <AccountProviderLegalEntity>() .Set(aple => aple.Id, 7) .Set(aple => aple.AccountProvider, AccountProvider) .Set(aple => aple.AccountLegalEntity, AccountLegalEntity); Db.AccountLegalEntities.AddRange(AccountLegalEntities); Db.AccountProviderLegalEntities.Add(AccountProviderLegalEntity); Db.SaveChanges(); return(this); }
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)); }
private void CreateDefaultEntities() { Account = new Account( id: 1, hashedId: "HashedId", publicHashedId: "PublicHashedId", name: "Account", created: DateTime.UtcNow); Db.Add(Account); AccountLegalEntity = new AccountLegalEntity( account: Account, id: 12345, publicHashedId: "ALE1", name: "Account legal entity 1", created: DateTime.UtcNow); Db.Add(AccountLegalEntity); Provider = EntityActivator .CreateInstance <Provider>() .Set(x => x.Ukprn, 299792458); Db.Add(Provider); User = new User(Guid.NewGuid(), "*****@*****.**", "Bill", "Gates"); Db.Add(User); AccountProvider = new AccountProvider(Account, Provider, User, null); AccountProvider.Set(x => x.Id, 23); Db.Add(AccountProvider); AccountProviderLegalEntity = new AccountProviderLegalEntity( accountProvider: AccountProvider, accountLegalEntity: AccountLegalEntity, user: User, grantedOperations: new HashSet <Operation>(new[] { Operation.CreateCohort, Operation.Recruitment })); AccountProviderLegalEntity.Set(x => x.Id, 34); Db.Add(AccountProviderLegalEntity); Db.SaveChanges(); }
public HealthCheckTestsFixture SetHealthCheck() { HealthCheck = EntityActivator.CreateInstance <HealthCheck>().Set(h => h.Id, 1); return(this); }