本文整理汇总了C#中TestUser类的典型用法代码示例。如果您正苦于以下问题:C# TestUser类的具体用法?C# TestUser怎么用?C# TestUser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestUser类属于命名空间,在下文中一共展示了TestUser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StoreUserWithOneUniqueConstraint
public void StoreUserWithOneUniqueConstraint()
{
var ravenSession = DocumentStore.OpenSession();
var testUser1 = new TestUser
{
Name = "Test User",
Username = "[email protected]",
EmailAddres = null
};
ravenSession.Store(testUser1);
ravenSession.SaveChanges();
var testUser2 = new TestUser
{
Name = "Test User2",
Username = "[email protected]",
EmailAddres = null
};
//this line throws a null reference exception
var checkResult = ravenSession.CheckForUniqueConstraints(testUser2);
Assert.False(checkResult.ConstraintsAreFree());
ravenSession.Dispose();
}
示例2: CreateUser
public async Task CreateUser()
{
// Create a session and user store for this test.
var session = SessionFactory.OpenSession();
var userStore = new TestUserStore<TestUser>(session);
// Create and save a user.
var user = new TestUser { UserName = "CreateUserTest" };
using (var transaction = session.BeginTransaction())
{
await userStore.CreateAsync(user);
transaction.Commit();
}
// Check the user has an id.
Assert.IsNotNull(user.Id);
// Create a new session and user store for this test, so that we actually hit the database and not the cache.
userStore.Dispose();
session.Dispose();
session = SessionFactory.OpenSession();
userStore = new TestUserStore<TestUser>(session);
// Load the user.
TestUser loadUser;
using (var transaction = session.BeginTransaction())
{
loadUser = await userStore.FindByIdAsync(user.Id);
transaction.Commit();
}
// Check we have the same user.
Assert.AreEqual(user.Id, loadUser.Id);
Assert.AreEqual(user.UserName, loadUser.UserName);
}
示例3: ComplexTypeReader
public void ComplexTypeReader()
{
var user = new TestUser
{
Contact = new Contact { Address = new Address { City = "Tallinn", Country = "Estonia"}, PhoneNumber = "1234567"},
FirstName = "Max",
LastName = "Lego",
Id = Guid.NewGuid()
};
var emptyUser = new TestUser();
using (var ctx = new TestContext())
{
var tableMapping = ctx.Db<TestUser>();
var tableMappings = new Dictionary<Type, IEntityMap>
{
{typeof (TestUser), tableMapping}
};
using (var reader = new MappedDataReader<TestUser>(new[] { user, emptyUser }, tableMappings))
{
Assert.AreEqual(9, reader.FieldCount);
while (reader.Read())
{
for (int i = 0; i < reader.FieldCount; ++i)
{
Console.WriteLine("{0}: {1}", i, reader.GetValue(i));
}
}
}
}
}
示例4: OnValidateIdentityRejectsWhenValidateSecurityStampFails
public async Task OnValidateIdentityRejectsWhenValidateSecurityStampFails()
{
var user = new TestUser("test");
var userManager = MockHelpers.MockUserManager<TestUser>();
var claimsManager = new Mock<IUserClaimsPrincipalFactory<TestUser>>();
var identityOptions = new IdentityOptions { SecurityStampValidationInterval = TimeSpan.Zero };
var options = new Mock<IOptions<IdentityOptions>>();
options.Setup(a => a.Value).Returns(identityOptions);
var httpContext = new Mock<HttpContext>();
var contextAccessor = new Mock<IHttpContextAccessor>();
contextAccessor.Setup(a => a.HttpContext).Returns(httpContext.Object);
var signInManager = new Mock<SignInManager<TestUser>>(userManager.Object,
contextAccessor.Object, claimsManager.Object, options.Object, null);
signInManager.Setup(s => s.ValidateSecurityStampAsync(It.IsAny<ClaimsPrincipal>())).ReturnsAsync(null).Verifiable();
var services = new ServiceCollection();
services.AddSingleton(options.Object);
services.AddSingleton(signInManager.Object);
services.AddSingleton<ISecurityStampValidator>(new SecurityStampValidator<TestUser>(options.Object, signInManager.Object));
httpContext.Setup(c => c.RequestServices).Returns(services.BuildServiceProvider());
var id = new ClaimsIdentity(identityOptions.Cookies.ApplicationCookieAuthenticationScheme);
id.AddClaim(new Claim(ClaimTypes.NameIdentifier, user.Id));
var ticket = new AuthenticationTicket(new ClaimsPrincipal(id),
new AuthenticationProperties { IssuedUtc = DateTimeOffset.UtcNow },
identityOptions.Cookies.ApplicationCookieAuthenticationScheme);
var context = new CookieValidatePrincipalContext(httpContext.Object, ticket, new CookieAuthenticationOptions());
Assert.NotNull(context.Properties);
Assert.NotNull(context.Options);
Assert.NotNull(context.Principal);
await SecurityStampValidator.ValidatePrincipalAsync(context);
Assert.Null(context.Principal);
signInManager.VerifyAll();
}
示例5: CT_ET_Validation_OnClient
public void CT_ET_Validation_OnClient()
{
var user = new TestUser();
var brokenRules = user.Validate();
Assert.AreEqual(brokenRules.Count, 1);
Assert.AreEqual(brokenRules[0].Description, "编码 里没有输入值。");
}
示例6: Button1_Click
protected void Button1_Click(object sender, EventArgs e)
{
TestUser user=new TestUser();
WebFormHelper.GetDataFromForm(this, user);
FT.DAL.Orm.SimpleOrmOperator.Create(user);
WebTools.Alert("添加成功!");
WebTools.CloseSelf(this);
}
示例7: NavigateToUserSettings
public void NavigateToUserSettings()
{
var user = new TestUser();
AcademyLoginProvider.Instance.LoginUser(user);
this.LoginPage.WaitForUserName();
this.LoginPage.Validator.ValidateUserName(user.Username);
this.SettingsPage.Navigate();
this.SettingsPage.Validator.UsernameLabel(user.Username);
}
示例8: PrepareOneOrderData
private static Order PrepareOneOrderData(string orderNumber, TestUser creator)
{
Order order = new Order();
order.OrderNumber = orderNumber;
order.Creator = creator;
return order;
}
示例9: SetTestUser
public ActionResult SetTestUser()
{
TestUser user = new TestUser
{
Identity = (User as GeneralUser).Identity,
Token = (User as GeneralUser).Token
};
LoggedinPersonsCache.Current.UpdatePerson(user);
return RedirectToAction("Index");
}
示例10: Init
public virtual void Init()
{
store = new TestUserStore();
manager = new TestIdentityRebootUserManager(store, 100);
user = new TestUser()
{
UserName = username
};
var result = manager.Create(user, password);
Assert.IsTrue(result.Succeeded);
}
示例11: ThenItIsAddedToTheList
async public Task ThenItIsAddedToTheList()
{
var store = new UserStore<TestUser>();
var user = new TestUser() { Id = "1", UserName = "FStallone" };
await store.CreateAsync(user);
var output = await store.FindByIdAsync("1");
Assert.IsNotNull(output);
Assert.AreEqual("FStallone", output.UserName);
}
示例12: ValidateFailsWithTooShortUserNames
public async Task ValidateFailsWithTooShortUserNames(string input)
{
// Setup
var manager = MockHelpers.TestUserManager(new NoopUserStore());
var validator = new UserValidator<TestUser>();
var user = new TestUser {UserName = input};
// Act
var result = await validator.ValidateAsync(manager, user);
// Assert
IdentityResultAssert.IsFailure(result, new IdentityErrorDescriber().InvalidUserName(input));
}
示例13: ET_AutoCollect
public void ET_AutoCollect()
{
//创建对象
var user = new TestUser();
var list = user.TestTreeTaskList;
var taskRoot = list.AddNew();
var task1 = list.AddNew();
var task11 = list.AddNew();
var task111 = list.AddNew();
var task112 = list.AddNew();
var task12 = list.AddNew();
var task2 = list.AddNew();
var taskRoot2 = list.AddNew();
//关系
task1.TreeParent = taskRoot;
task11.TreeParent = task1;
task111.TreeParent = task11;
task112.TreeParent = task11;
task12.TreeParent = task1;
task2.TreeParent = taskRoot;
Assert.AreEqual(taskRoot.AllTimeByAutoCollect, 0);
task111.AllTimeByAutoCollect += 1;
Assert.AreEqual(task11.AllTimeByAutoCollect, 1);
Assert.AreEqual(task1.AllTimeByAutoCollect, 1);
Assert.AreEqual(taskRoot.AllTimeByAutoCollect, 1);
Assert.AreEqual(user.TasksTimeByAutoCollect, 1);
task12.AllTimeByAutoCollect += 1;
Assert.AreEqual(task1.AllTimeByAutoCollect, 2);
Assert.AreEqual(taskRoot.AllTimeByAutoCollect, 2);
Assert.AreEqual(user.TasksTimeByAutoCollect, 2);
task2.AllTimeByAutoCollect += 1;
Assert.AreEqual(task1.AllTimeByAutoCollect, 2);
Assert.AreEqual(taskRoot.AllTimeByAutoCollect, 3);
Assert.AreEqual(user.TasksTimeByAutoCollect, 3);
taskRoot2.AllTimeByAutoCollect += 1;
Assert.AreEqual(user.TasksTimeByAutoCollect, 4);
task111.AllTimeByAutoCollect -= 1;
Assert.AreEqual(task11.AllTimeByAutoCollect, 0);
Assert.AreEqual(task1.AllTimeByAutoCollect, 1);
Assert.AreEqual(taskRoot.AllTimeByAutoCollect, 2);
Assert.AreEqual(user.TasksTimeByAutoCollect, 3);
}
示例14: TET_Query_DefaultOrderBy_TreeIndex
public void TET_Query_DefaultOrderBy_TreeIndex()
{
var user = new TestUser
{
TestTreeTaskList =
{
new TestTreeTask
{
TreeChildren =
{
new TestTreeTask
{
TreeChildren =
{
new TestTreeTask(),
new TestTreeTask(),
}
},
new TestTreeTask(),
}
}
}
};
var repo = RF.Concrete<TestTreeTaskRepository>();
using (RF.TransactionScope(repo))
{
RF.Save(user);
var list = repo.GetByParentId(user.Id);
for (int i = 1, c = list.Count; i < c; i++)
{
var item1 = list[i - 1];
var item2 = list[i];
Assert.IsTrue(string.Compare(item1.TreeIndex, item2.TreeIndex) == -1, "默认应该按照 TreeIndex 正序排列。");
}
//按照 Id 排序的功能应该无效。
var success = false;
try
{
list = repo.GetAndOrderByIdDesc2();
success = true;
}
catch { }
Assert.IsFalse(success, "默认应该按照 TreeIndex 正序排列。");
}
}
示例15: BindModel
public object BindModel(ControllerContext controllerContext,
ModelBindingContext bindingContext)
{
HttpRequestBase request = controllerContext.HttpContext.Request;
TestUser obj = new TestUser();
obj.UserName = request.Form["UserName"];
obj.Company = request.Form["Company"];
String day = request.Form["day"];
String month = request.Form["month"];
String year = request.Form["year"];
obj.DOB = String.Format("{0}-{1}-{2}", day, month, year);
return obj;
}