private Agency BuildAgency(AgencyType agencyType, string legalName, string displayName = null) { Agency agency = new AgencyBuilder().WithAgencyProfile( new AgencyProfileBuilder().WithAgencyType(agencyType).WithAgencyName( new AgencyNameBuilder().WithLegalName(legalName).WithDisplayName(displayName))); Session.SaveOrUpdate(agency); return(agency); }
public void ReviseAgencyProfile_LegalNameChangeSuccessful() { using (var serviceLocatorFixture = new ServiceLocatorFixture()) { //Setup SetupServiceLocatorFixture(serviceLocatorFixture); const string newName = "ADifferentName"; var agencyType = new Mock <AgencyType>(); Agency agency = new AgencyBuilder().WithAgencyProfile( new AgencyProfileBuilder().WithAgencyType(agencyType.Object).WithAgencyName(new AgencyNameBuilder().WithLegalName("SomeName"))); agency.ReviseAgencyProfile( new AgencyProfileBuilder().WithAgencyType(agencyType.Object).WithAgencyName( new AgencyNameBuilder().WithLegalName(newName))); Assert.AreEqual(agency.AgencyProfile.AgencyName.LegalName, newName); } }
public async Task GrantAccessRoles() { // Arrange // Default budget region of the cost is AsiaPacific ("AAK (Asia)") await CreateCostEntity(User); var budgetRegionName = plugins.Constants.BudgetRegion.AsiaPacific; var pgBuName = $"pg_bu_userAccess_{Guid.NewGuid()}"; var pgBu = new AgencyBuilder() .WithName(pgBuName) .WithGdamAgencyId() .WithPrimaryCurrency(_defaultCurrecy.Id) .WithCountry(_country) .MakePrime(_module) .Build(); EFContext.Agency.Add(pgBu); var agencyName = $"pg_agency_userAccess_{Guid.NewGuid()}"; var agency = new AgencyBuilder() .WithName(agencyName) .WithGdamAgencyId() .WithPrimaryCurrency(_defaultCurrecy.Id) .WithCountry(_country) .Build(); EFContext.Agency.Add(agency); // Create users var name = $"{Guid.NewGuid()}bob_userAccess_1"; var user = new CostUser { FirstName = name, LastName = name, FullName = name, AgencyId = agency.Id, GdamUserId = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 24), Email = name, AbstractType = _root }; EFContext.CostUser.Add(user); await EFContext.SaveChangesAsync(); // Act var model = new UpdateUserModel { AccessDetails = new List <AccessDetail> { new AccessDetail { BusinessRoleId = _agencyAdmin.Id, ObjectType = Constants.AccessObjectType.Region, LabelName = budgetRegionName } } }; var response = await GrantAccess(user.Id, model); // Assert response.Success.Should().BeTrue(); var userUserGroup = await EFContext.UserUserGroup .Include(uug => uug.UserGroup) .FirstOrDefaultAsync(uug => uug.UserId == user.Id && uug.UserGroup.Label == budgetRegionName ); userUserGroup.Should().Should().NotBeNull(); userUserGroup.UserGroup.Label.Should().NotBeNull(); userUserGroup.UserGroup.Label.Should().Be(budgetRegionName); }
public void SetUp() { _agencyBuilder = new AgencyBuilder(); _agencyBuilder.ReadEntityMappings( "agency_id,agency_name,agency_url,agency_timezone,agency_phone,agency_lang"); }