本文整理汇总了C#中ModelHelper.CreateUser方法的典型用法代码示例。如果您正苦于以下问题:C# ModelHelper.CreateUser方法的具体用法?C# ModelHelper.CreateUser怎么用?C# ModelHelper.CreateUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModelHelper
的用法示例。
在下文中一共展示了ModelHelper.CreateUser方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FetchSumissions_ForYearandScheme_ReturnsSubmittedSubmissionsWithCorrectnumberOfWarnings
public async Task FetchSumissions_ForYearandScheme_ReturnsSubmittedSubmissionsWithCorrectnumberOfWarnings()
{
using (DatabaseWrapper database = new DatabaseWrapper())
{
ModelHelper helper = new ModelHelper(database.Model);
// Arrange
Scheme scheme1 = helper.CreateScheme();
Scheme scheme2 = helper.CreateScheme();
var user1 = helper.CreateUser("[email protected]");
var user2 = helper.CreateUser("[email protected]");
MemberUpload memberUpload1 = helper.CreateMemberUpload(scheme1);
memberUpload1.ComplianceYear = 2006;
memberUpload1.IsSubmitted = true;
memberUpload1.SubmittedDate = new DateTime(2015, 09, 23, 10, 45, 45);
memberUpload1.SubmittedByUserId = user1.Id;
MemberUpload memberUpload2 = helper.CreateMemberUpload(scheme1);
memberUpload2.ComplianceYear = 2006;
memberUpload2.IsSubmitted = true;
memberUpload2.SubmittedDate = new DateTime(2015, 08, 4, 12, 24, 35);
memberUpload2.SubmittedByUserId = user1.Id;
MemberUpload memberUpload3 = helper.CreateMemberUpload(scheme1);
memberUpload3.ComplianceYear = 2006;
memberUpload3.IsSubmitted = false;
memberUpload3.SubmittedDate = new DateTime(2015, 08, 10, 12, 25, 32);
memberUpload3.SubmittedByUserId = user1.Id;
MemberUpload memberUpload4 = helper.CreateMemberUpload(scheme2);
memberUpload4.ComplianceYear = 2006;
memberUpload4.IsSubmitted = true;
memberUpload4.SubmittedDate = new DateTime(2015, 07, 31, 10, 25, 45);
memberUpload4.SubmittedByUserId = user2.Id;
helper.CreateMemberUploadError(memberUpload2);
helper.CreateMemberUploadError(memberUpload2);
database.Model.SaveChanges();
// Act
GetSubmissionsHistoryResultsDataAccess dataAccess = new GetSubmissionsHistoryResultsDataAccess(database.WeeeContext);
var results = await dataAccess.GetSubmissionsHistory(scheme1.Id, 2006);
// Assert
Assert.NotNull(results.Data);
Assert.Equal(2, results.Data.Count);
Assert.Collection(results.Data,
r1 => Assert.Equal(0, r1.NoOfWarnings),
r2 => Assert.Equal(2, r2.NoOfWarnings));
}
}
示例2: FetchSumissions_ForYearandScheme_ReturnsSubmittedSubmissions
public async Task FetchSumissions_ForYearandScheme_ReturnsSubmittedSubmissions()
{
using (DatabaseWrapper database = new DatabaseWrapper())
{
ModelHelper helper = new ModelHelper(database.Model);
// Arrange
Scheme scheme1 = helper.CreateScheme();
Scheme scheme2 = helper.CreateScheme();
var user1 = helper.CreateUser("[email protected]");
var user2 = helper.CreateUser("[email protected]");
MemberUpload memberUpload1 = helper.CreateMemberUpload(scheme1);
memberUpload1.ComplianceYear = 2005;
memberUpload1.IsSubmitted = true;
memberUpload1.SubmittedDate = new DateTime(2015, 09, 22, 10, 45, 45);
memberUpload1.SubmittedByUserId = user1.Id;
MemberUpload memberUpload2 = helper.CreateMemberUpload(scheme1);
memberUpload2.ComplianceYear = 2006;
memberUpload2.IsSubmitted = true;
memberUpload2.SubmittedDate = new DateTime(2015, 08, 10, 12, 25, 35);
memberUpload2.SubmittedByUserId = user1.Id;
MemberUpload memberUpload3 = helper.CreateMemberUpload(scheme1);
memberUpload3.ComplianceYear = 2006;
memberUpload3.IsSubmitted = false;
memberUpload3.SubmittedDate = new DateTime(2015, 09, 10, 12, 25, 35);
memberUpload3.SubmittedByUserId = user1.Id;
MemberUpload memberUpload4 = helper.CreateMemberUpload(scheme2);
memberUpload4.ComplianceYear = 2006;
memberUpload4.IsSubmitted = true;
memberUpload4.SubmittedDate = new DateTime(2015, 07, 22, 10, 45, 45);
memberUpload4.SubmittedByUserId = user2.Id;
database.Model.SaveChanges();
// Act
GetSubmissionsHistoryResultsDataAccess dataAccess =
new GetSubmissionsHistoryResultsDataAccess(database.WeeeContext);
var results = await dataAccess.GetSubmissionsHistory(scheme1.Id, 2006);
// Assert
Assert.NotNull(results.Data);
Assert.Equal(1, results.Data.Count);
var result1 = results.Data.SingleOrDefault(r => r.Year == 2006);
Assert.NotNull(result1);
Assert.Equal("08/10/2015 12:25:35", result1.DateTime.ToString(CultureInfo.InvariantCulture));
Assert.Equal("Test LastName", result1.SubmittedBy);
}
}
示例3: 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);
}
}
示例4: GetSubmissionHistory_WitValidSchemeIdAndYear2015_ReturnsOnly2015YearSubmissionHistoryData
public async void GetSubmissionHistory_WitValidSchemeIdAndYear2015_ReturnsOnly2015YearSubmissionHistoryData()
{
using (var database = new DatabaseWrapper())
{
Guid organisationId = new Guid("72BB14DF-DCD5-4DBB-BBA9-4CFC26AD80F9");
GetSubmissionsHistoryResultsDataAccess dataAccess = new GetSubmissionsHistoryResultsDataAccess(database.WeeeContext);
// Arrange
ModelHelper modelHelper = new ModelHelper(database.Model);
var user1 = modelHelper.CreateUser("Test");
database.Model.SaveChanges();
var scheme1 = modelHelper.CreateScheme();
scheme1.Organisation.Id = organisationId;
database.Model.SaveChanges();
var mu1 = modelHelper.CreateMemberUpload(scheme1);
mu1.ComplianceYear = 2015;
mu1.IsSubmitted = true;
mu1.SubmittedDate = new DateTime(2015, 1, 1);
var mu2 = modelHelper.CreateMemberUpload(scheme1);
mu2.ComplianceYear = 2015;
mu2.IsSubmitted = true;
mu2.SubmittedDate = new DateTime(2015, 1, 1);
var mu3 = modelHelper.CreateMemberUpload(scheme1);
mu3.ComplianceYear = 2016;
mu3.IsSubmitted = true;
mu3.SubmittedDate = new DateTime(2015, 1, 1);
database.Model.SaveChanges();
// Act
var result = await dataAccess.GetSubmissionsHistory(scheme1.Id, 2015);
// Assert
Assert.NotNull(result.Data);
Assert.Equal(2, result.Data.Count);
Assert.Collection(result.Data,
r1 => Assert.Equal(r1.Year, 2015),
r2 => Assert.Equal(r2.Year, 2015));
}
}