public void CreateRandom_InstanceOf_with_MaximumDepth_should_work() { int?maximumDepth = null; var result = CreateRandom.InstanceOf <Depth1>(maximumDepth: maximumDepth); Assert.IsNotNull(result.Depth2.Depth3.Depth4, "No maximum depth"); maximumDepth = 3; result = CreateRandom.InstanceOf <Depth1>(maximumDepth: maximumDepth); Assert.IsNull(result.Depth2.Depth3.Depth4, $"Maximum depth {maximumDepth}"); maximumDepth = 2; result = CreateRandom.InstanceOf <Depth1>(maximumDepth: maximumDepth); Assert.IsNull(result.Depth2.Depth3, $"Maximum depth {maximumDepth}"); maximumDepth = 1; result = CreateRandom.InstanceOf <Depth1>(maximumDepth: maximumDepth); Assert.IsNull(result.Depth2, $"Maximum depth {maximumDepth}"); }
public void ValidUserCanLoginSuccesfully() { var testUser = new User { AuthType = AuthTypes.Administrator, Description = CreateRandom.String(), Id = 4, LoggedIn = false, LoginFailedCount = 2, Name = "SuperUser", Password = "******" }; _userManager.AddUser(testUser); Assert.That(_userManager.CanLogin(testUser), Is.True); _userManager.RemoveUser(testUser); }
public void MultipleUsersCanLoginAtTheSameTime() { var password1 = CreateRandom.String(); var user1 = CreateRandomUser(); var password2 = CreateRandom.String(); var user2 = CreateRandomUser(); _userManagement.AddUser(user1, password1); _userManagement.AddUser(user2, password2); Assert.DoesNotThrow(() => _userManagement.Login(user1.UserName, password1)); Assert.DoesNotThrow(() => _userManagement.Login(user2.UserName, password2)); Assert.IsTrue(_userManagement.CurrentUser.UserName == user1.UserName); Assert.IsFalse(_userManagement.CurrentUser.UserName == user2.UserName); _userManagement.RemoveUser(user1.UserName); _userManagement.RemoveUser(user2.UserName); }
public void SameUserCanNotLoginMoreThanOnce() { var testUser = new User { AuthType = AuthTypes.Administrator, Description = CreateRandom.String(), Id = 4, LoggedIn = false, LoginFailedCount = 0, Name = "SuperUser", Password = "******" }; _userManager.AddUser(testUser); Assert.That(_userManager.CanLogin(testUser), Is.True); _userManager.LogIn(testUser); Assert.That(_userManager.CanLogin(testUser), Is.False); _userManager.RemoveUser(testUser); }
public void UserLoginAfterHeIntroducedMultipleTimesTheWrongPasswordFails() { var testUser = new User { AuthType = AuthTypes.Other, Description = CreateRandom.String(), Id = 10, LoggedIn = false, LoginFailedCount = 0, Name = CreateRandom.String(), Password = CreateRandom.String() }; _userManager.AddUser(testUser); Assert.That(_userManager.CanLogin(testUser), Is.True); for (int i = 0; i < 5; i++) { _userManager.CheckCredentials(testUser.Name, "testpassword"); } Assert.That(_userManager.CanLogin(testUser), Is.False); _userManager.RemoveUser(testUser); }
public IActionResult Add(Models.Student student) { if (student == null) { return(NotFound("student is null")); } var allStudentEmail = _diaryDbContext.Students.FirstOrDefault(user => user.Email == student.Email); var allStudentPhone = _diaryDbContext.Students.FirstOrDefault(user => user.Phone == student.Phone); if (allStudentEmail == null && allStudentPhone == null && !string.IsNullOrWhiteSpace(student.FirstName) && !string.IsNullOrWhiteSpace(student.LastName) && !string.IsNullOrWhiteSpace(student.Age.ToString()) ) { var group = _diaryDbContext.Groups.FirstOrDefault(x => x.Id == student.Group.Id); _diaryDbContext.Students.Add(new Models.Student { FirstName = student.FirstName, LastName = student.LastName, Age = student.Age, Email = student.Email, Phone = student.Phone, Password = CreateRandom.Password(), Group = group }); _diaryDbContext.SaveChanges(); return(RedirectToAction("Students", "Student")); } return(NotFound("Error Data")); }
protected KeyValueChange RandomKeyValueChange() { string randomName = CreateRandom.String(); return(new KeyValueChange(string.Empty, randomName, 1, 2, typeof(Int32))); }
private User CreateRandomUser() { var user = new User(CreateRandom.String(), CreateRandom.String(), CreateRandom.String(), CreateRandom.String(), CreateRandom.String(), false, CreateRandom.String(), CreateRandom.String()); return(user); }
public void CreateRandom_Guid_should_work() { Guid randomValue = CreateRandom.Guid(); Assert.IsNotNull(randomValue); }
public void CreateRandom_DateTime_should_work() { DateTime randomValue = CreateRandom.DateTime(); Assert.IsNotNull(randomValue); }
public void CreateRandom_Byte_should_work() { byte randomValue = CreateRandom.Byte(); Assert.IsNotNull(randomValue); }
public void CreateRandom_Char_should_work() { char randomValue = CreateRandom.Char(); Assert.IsNotNull(randomValue); }
protected static Alarm CreateRandomAlarm() { return(new Alarm { AlarmId = CreateRandom.Int(), Source = CreateRandom.String() }); }
public void CreateRandom_Float_should_work() { float randomValue = CreateRandom.Float(); Assert.IsNotNull(randomValue); }
public void CreateRandom_UShort_should_work() { ushort randomValue = CreateRandom.UShort(); Assert.IsNotNull(randomValue); }
public void CreateRandom_ULong_should_work() { ulong randomValue = CreateRandom.ULong(); Assert.IsNotNull(randomValue); }
public void CreateRandom_UInt_should_work() { uint randomValue = CreateRandom.UInt(); Assert.IsNotNull(randomValue); }
public void CreateRandom_String_with_prefix_should_work() { string randomValue = CreateRandom.String("testPrefix"); StringAssert.StartsWith(randomValue, "testPrefix"); }
public void CreateRandom_String_should_work() { string randomValue = CreateRandom.String(); Assert.IsNotNull(randomValue); }
public void CreateRandom_Double_should_work() { double randomValue = CreateRandom.Double(); Assert.IsNotNull(randomValue); }
public void CreateRandom_EnumValue_should_work() { StringComparison randomValue = CreateRandom.EnumValue <StringComparison>(); Assert.IsNotNull(randomValue); }
public void CreateRandom_Bool_should_work() { bool randomValue = CreateRandom.Bool(); Assert.IsNotNull(randomValue); }
public void CreateRandom_Decimal_should_work() { decimal randomValue = CreateRandom.Decimal(); Assert.IsNotNull(randomValue); }