本文整理汇总了C#中Core.ToDomainEnumeration方法的典型用法代码示例。如果您正苦于以下问题:C# Core.ToDomainEnumeration方法的具体用法?C# Core.ToDomainEnumeration怎么用?C# Core.ToDomainEnumeration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Core
的用法示例。
在下文中一共展示了Core.ToDomainEnumeration方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OrganisationUser
GetOrganisationBySimpleSearchTerm_SearchIsValid_AndNoConflictingOrganisationUserExists_ReturnsOrganisation(
string existingUserId, string userId, Core.Shared.UserStatus userStatus, Core.Shared.OrganisationStatus organisationStatus)
{
var organisation = A.Fake<Organisation>();
A.CallTo(() => organisation.TradingName).Returns("A Company");
A.CallTo(() => organisation.OrganisationStatus).Returns(organisationStatus.ToDomainEnumeration<OrganisationStatus>());
A.CallTo(() => context.Organisations)
.Returns(dbContextHelper.GetAsyncEnabledDbSet(new List<Organisation> { organisation }));
var organisationUser = new OrganisationUser(new Guid(userId), new Guid(existingUserId), userStatus.ToDomainEnumeration<UserStatus>());
A.CallTo(() => context.OrganisationUsers)
.Returns(dbContextHelper.GetAsyncEnabledDbSet(new List<OrganisationUser>
{
organisationUser
}));
var result = await FindMatchingOrganisationsDataAccess().GetOrganisationsBySimpleSearchTerm("A", new Guid(userId));
Assert.Single(result);
Assert.Equal(organisation, result.Single());
}
示例2: ChangeOrganisationUserStatus
public async Task<int> ChangeOrganisationUserStatus(OrganisationUser organisationUser, Core.Shared.UserStatus status)
{
organisationUser.UpdateUserStatus(status.ToDomainEnumeration<UserStatus>());
return await context.SaveChangesAsync();
}
示例3: ValidOrganisationUser
private OrganisationUser ValidOrganisationUser(Guid userId, Guid organisationId, Core.Shared.UserStatus userStatus)
{
return new OrganisationUser(userId, organisationId, userStatus.ToDomainEnumeration<UserStatus>());
}
示例4: using
public async void GetOrganisationUsers_SameUserRejectedMultipleTimesForOneOrganisation_ButAlsoHasAnotherStatus_ReturnsTheOtherStatus(Core.Shared.UserStatus status)
{
using (var dbWrapper = new DatabaseWrapper())
{
// Add AspNet user user
var modelHelper = new ModelHelper(dbWrapper.Model);
var aspNetUser = modelHelper.CreateUser("My username", IdType.Guid);
dbWrapper.Model.SaveChanges();
// Add organisation
var uniqueOrgName = "Test Org " + Guid.NewGuid();
var country = dbWrapper.WeeeContext.Countries.First();
var organisation = Domain.Organisation.Organisation.CreateSoleTrader(uniqueOrgName);
organisation.AddOrUpdateMainContactPerson(new Domain.Organisation.Contact("First name", "Last name", "Developer"));
organisation.AddOrUpdateAddress(AddressType.OrganisationAddress, new Domain.Organisation.Address(
"Address line 1",
string.Empty,
"Town",
string.Empty,
string.Empty,
country,
"01234567890",
"[email protected]"));
organisation.CompleteRegistration();
dbWrapper.WeeeContext.Organisations.Add(organisation);
dbWrapper.WeeeContext.SaveChanges();
// Add same organisation user multiple times, rejected
var rejectedOrganisationUsers = new List<Domain.Organisation.OrganisationUser>
{
new Domain.Organisation.OrganisationUser(Guid.Parse(aspNetUser.Id),
organisation.Id,
UserStatus.Rejected),
new Domain.Organisation.OrganisationUser(Guid.Parse(aspNetUser.Id),
organisation.Id,
UserStatus.Rejected),
new Domain.Organisation.OrganisationUser(Guid.Parse(aspNetUser.Id),
organisation.Id,
UserStatus.Rejected)
};
var otherOrganisationUser = new Domain.Organisation.OrganisationUser(Guid.Parse(aspNetUser.Id),
organisation.Id,
status.ToDomainEnumeration<UserStatus>());
dbWrapper.WeeeContext.OrganisationUsers.AddRange(rejectedOrganisationUsers);
dbWrapper.WeeeContext.OrganisationUsers.Add(otherOrganisationUser);
dbWrapper.WeeeContext.SaveChanges();
var dataAccess = new FindMatchingUsersDataAccess(dbWrapper.WeeeContext);
var result = (await dataAccess.GetOrganisationUsers())
.Where(ou => ou.OrganisationName == uniqueOrgName);
Assert.Single(result);
var organisationUser = result.Single();
Assert.Equal(status, organisationUser.Status);
}
}