本文整理汇总了C#中IUDICO.Common.Models.Shared.User类的典型用法代码示例。如果您正苦于以下问题:C# User类的具体用法?C# User怎么用?C# User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
User类属于IUDICO.Common.Models.Shared命名空间,在下文中一共展示了User类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InvalidateUser
public void InvalidateUser()
{
// original caching
//this.tests.Storage.GetUsers();
tests = UserManagementTests.Update();
var temp = new User { Username = "name", Email = "[email protected]", Password = "pass123" };
this.tests.Storage.CreateUser(temp);
var user = this.tests.Storage.GetUsers().SingleOrDefault(u => u.Username == temp.Username);
Assert.IsNotNull(user);
temp = this.tests.Storage.GetUser("name");
var expected = new User
{
Username = "name",
Email = "[email protected]",
Password = "pass123",
Id = temp.Id,
OpenId = "openid"
};
this.tests.Storage.EditUser(temp.Id, new EditUserModel(expected));
user = this.tests.Storage.GetUsers().SingleOrDefault(u => u.Username == temp.Username);
Assert.IsTrue(this.tests.TestUsers(this.tests.Storage.GetUser("name"), expected));
Assert.IsTrue(this.tests.TestUsers(user, expected));
this.tests.Storage.DeleteUser(u => u.Id == temp.Id);
Assert.IsNull(this.tests.Storage.GetUser("name"));
}
示例2: CreateUserInvalid
public void CreateUserInvalid()
{
User temp = new User {Username = "name", Email = "[email protected]"};
_Tests.MockStorage.Setup(s => s.GetCurrentUser()).Returns(_Tests.Storage.GetUser(u => u.Username == "panza"));
_Tests.Storage.CreateUser(temp);
}
示例3: CalculateSpecializedResultTest
public void CalculateSpecializedResultTest()
{
User usr = new User() { Username = "Bob" };
Topic thm = new Topic() { Name = "Topic One" };
AttemptResult AR = new AttemptResult(1, usr, thm, CompletionStatus.Completed, AttemptStatus.Completed, SuccessStatus.Passed, DateTime.Now, 0.5f);
TopicResult topicRes = new TopicResult(usr, thm);
List<AttemptResult> ARL = new List<AttemptResult>();
ARL.Add(AR);
topicRes.AttemptResults = ARL;
topicRes.GetTopicResultScore();
DisciplineResult currRes = new DisciplineResult();
currRes.TopicResult.Add(topicRes);
Discipline curr = null;
currRes.CalculateSumAndMax(usr, curr);
SpecializedResult target = new SpecializedResult();
target.DisciplineResult.Add(currRes);
target.CalculateSpecializedResult(usr);
double? ExpectedSum = 50.0;
double? ExpectedMax = 100.0;
double? ExpectedPercent = 50.0;
char ExpextedECTS = 'F';
Assert.AreEqual(ExpectedSum, target.Sum);
Assert.AreEqual(ExpectedMax, target.Max);
Assert.AreEqual(ExpectedPercent, target.Percent);
Assert.AreEqual(ExpextedECTS, target.ECTS);
}
示例4: ChangePasswordWithBlankDataTest
public void ChangePasswordWithBlankDataTest()
{
this.tests = UserManagementTests.Update();
var model = new ChangePasswordModel { OldPassword = string.Empty, ConfirmPassword = "321", NewPassword = "321" };
var temp = new User { Username = "name", Email = "[email protected]", Password = "123" };
this.tests.ChangeCurrentUser("panza");
this.tests.Storage.CreateUser(temp);
this.tests.ChangeCurrentUser("name");
try
{
this.tests.Storage.ChangePassword(model);
}
catch (Exception e)
{
this.tests.Storage.DeleteUser(u => u.Username == "name");
if (e.Message == "Old password can't be empty.")
{
Assert.Pass();
}
Assert.Fail();
}
this.tests.Storage.DeleteUser(u => u.Username == "name");
Assert.Fail();
}
示例5: EditUserValid
public void EditUserValid()
{
tests = new UserManagementTests();
var temp = new User { Username = "name", Email = "[email protected]", Password = "pass123" };
this.tests.Storage.CreateUser(temp);
temp = this.tests.Storage.GetUser("name");
var expected = new User
{
Username = "name",
Email = "[email protected]",
Password = "pass123",
Id = temp.Id,
OpenId = "openid"
};
var model = new EditUserModel(expected);
this.tests.Storage.EditUser(temp.Id, model);
var compare = this.tests.Storage.GetUser("name");
Assert.IsTrue(this.tests.TestUsers(compare, expected) && compare.OpenId == expected.OpenId);
this.tests.Storage.DeleteUser(u => u.Username == "name");
}
示例6: UpdateUserAverage
public void UpdateUserAverage()
{
tests = UserManagementTests.Update();
var user = new User { Username = "name1", Email = "[email protected]", Password = "123" };
this.tests.Storage.CreateUser(user);
var attemptResult = new AttemptResult
{
AttemptId = 1,
AttemptStatus = AttemptStatus.Completed,
CompletionStatus = CompletionStatus.Completed,
FinishTime = DateTime.Now,
StartTime = DateTime.Now,
Score = new Score(0, 50, 45, 0.9F),
SuccessStatus = SuccessStatus.Passed,
TopicType = TopicTypeEnum.Test,
User = this.tests.Storage.GetUser(user.Username)
};
this.tests.Storage.UpdateUserAverage(attemptResult);
var testUser = this.tests.Storage.GetUser(user.Username);
Assert.IsTrue(testUser.TestsTotal == 1);
Assert.IsTrue(testUser.TestsSum == 90);
this.tests.Storage.DeleteUser(u => u.Username == "name1");
}
示例7: CreateUserInvalid
public void CreateUserInvalid()
{
tests = new UserManagementTests();
var temp = new User { Username = "name", Email = "[email protected]" };
this.tests.Storage.CreateUser(temp);
}
示例8: EditUserValid
public void EditUserValid()
{
User temp = new User {Username = "name", Email = "[email protected]", Password = "pass123"};
_Tests.MockStorage.Setup(s => s.GetCurrentUser()).Returns(_Tests.Storage.GetUser(u => u.Username == "panza"));
_Tests.Storage.CreateUser(temp);
temp = _Tests.Storage.GetUser(u => u.Username == "name");
User expected = new User
{
Username = "name",
Email = "[email protected]",
Password = "pass123",
Id = temp.Id,
OpenId = "openid"
};
var model = new EditUserModel(expected);
_Tests.Storage.EditUser(temp.Id, model);
var compare = _Tests.Storage.GetUser(u => u.Username == "name");
Assert.IsTrue(_Tests.TestUsers(compare, expected) && compare.OpenId == expected.OpenId);
_Tests.Storage.DeleteUser(u => u.Username == "name");
}
示例9: AddUserStats
public void AddUserStats(User user,
int totalNumberOfRequests,
int todayNumberOfRequests,
DateTime lastActivityTime)
{
_stats.Add(new UserActivityStats(
user, totalNumberOfRequests, todayNumberOfRequests, lastActivityTime));
}
示例10: GetUser
public void GetUser()
{
User temp = new User { Username = "iper", Email = "[email protected]", Password = "pass123" };
_Tests.MockStorage.Setup(s => s.GetCurrentUser()).Returns(_Tests.Storage.GetUser(u => u.Username == "panza"));
_Tests.Storage.CreateUser(temp);
Assert.IsTrue(_Tests.TestUsers(temp, _Tests.Storage.GetUser(u => u.Username == "iper")));
}
示例11: ChangePasswordSuccess
public void ChangePasswordSuccess()
{
var model = new ChangePasswordModel {OldPassword = "123", ConfirmPassword = "123", NewPassword = "321"};
User temp = new User { Username = "ipepp", Email = "[email protected]", Password = "123" };
_Tests.MockStorage.Setup(s => s.GetCurrentUser()).Returns(_Tests.Storage.GetUser(u => u.Username == "panza"));
_Tests.Storage.CreateUser(temp);
_Tests.MockStorage.Setup(s => s.GetCurrentUser()).Returns(_Tests.Storage.GetUser(u => u.Username == "ipepp"));
_Tests.Storage.ChangePassword(model);
Assert.AreEqual(_Tests.Storage.GetUser(u => u.Username == "ipepp").Password, _Tests.Storage.EncryptPassword("321"));
}
示例12: DeleteUserExisting
public void DeleteUserExisting()
{
tests = new UserManagementTests();
var temp = new User { Username = "Username", Email = "[email protected]", Password = "123" };
this.tests.Storage.CreateUser(temp);
this.tests.Storage.DeleteUser(u => u.Username == "Username");
Assert.IsTrue(this.tests.Storage.GetUser(u => u.Username == "Username") == null);
}
示例13: UserActivityStats
public UserActivityStats(
User user,
int totalNumberOfRequests,
int todayNumberOfRequests,
DateTime lastActivityTime)
{
this.User = user;
this.TotalNumberOfRequests = totalNumberOfRequests;
this.TodayNumberOfRequests = todayNumberOfRequests;
this.LastActivityTime = lastActivityTime;
}
示例14: EditUserNonExisting
public void EditUserNonExisting()
{
User temp = new User { Username = "name", Email = "[email protected]", Password = "pass123" };
_Tests.MockStorage.Setup(s => s.GetCurrentUser()).Returns(_Tests.Storage.GetUser(u => u.Username == "panza"));
User expected = new User { Username = "name", Email = "[email protected]", Password = "pass123", Id = temp.Id, OpenId = "openid" };
var model = new EditUserModel(expected);
_Tests.Storage.EditUser(temp.Id, model);
}
示例15: AddNonExistingUserToNonExistingGroup
public void AddNonExistingUserToNonExistingGroup()
{
tests = UserManagementTests.Update();
var group = new Group { Id = 12366, Name = "pmp51" };
var temp = new User { Username = "name", Email = "[email protected]", Password = "123" };
this.tests.Storage.AddUserToGroup(group, temp);
Assert.IsFalse(this.tests.Storage.GetUsersInGroup(group).Contains(temp));
Assert.AreEqual(0, this.tests.Storage.GetGroupsByUser(temp).Count());
}