public void UserCreator_UserAlreadyExists_NoUserIsCreated() { var context = new AlvTimeDbContextBuilder() .WithUsers() .CreateDbContext(); var storage = new UserStorage(context); var creator = new UserCreator(storage, new AlvHoursCalculator()); creator.CreateUser(new CreateUserDto { Email = "*****@*****.**", Name = "Someone", StartDate = DateTime.UtcNow }); Assert.True(context.User.Count() == 2); }
public void RemoveWishlistTest() { Test(() => { var user = UserCreator.CreateUser(_configuration); var wishlist = WishlistCreator.CreateWishlist(_configuration); var homePage = new HomePage(_driver); var wishlistsCount = homePage .GoTo() .GoToLoginPage() .WriteCredentials(user) .GoToProfilePage() .GoToWishlistPage() .CreateWishlist(wishlist) .RemoveWishlist() .CountWishlists(); Assert.Zero(wishlistsCount); }); }
public void ChangeNameTest() { Test(() => { var user = UserCreator.CreateUser(_configuration); var homePage = new HomePage(_driver); var userName = homePage .GoTo() .GoToLoginPage(user) .GoToProfilePage() .ChangeName(user.NameChange) .GetLoggedUser(); homePage .GoTo() .GoToProfilePage() .ChangeName(user.Name); Assert.AreEqual(user.NameChange, userName); }); }
public void CreateWishlistTest() { Test(() => { var user = UserCreator.CreateUser(_configuration); var wishlist = WishlistCreator.CreateWishlist(_configuration); var homePage = new HomePage(_driver); var wishlistTitle = homePage .GoTo() .GoToLoginPage() .WriteCredentials(user) .GoToProfilePage() .GoToWishlistPage() .CreateWishlist(wishlist) .GetWishlistTitle(); var wishlistPage = new WishlisthPage(_driver); wishlistPage.RemoveWishlist(); Assert.IsTrue(wishlistTitle.Contains(wishlist.Title)); }); }
private void Button_Click(object sender, RoutedEventArgs e) { bool result = UserCreator.CreateUser(Text1.Text, Text3.Text, Text2.Text); UserCreator.Deposit("kil1", 100); UserCreator.Withdraw("kil", 20); if (result) { GoodLogin.Visibility = Visibility.Visible; mainwin.Effect = null; Button obj = (Button)mainwin.FindName("login"); obj.Visibility = Visibility.Hidden; Button obj2 = (Button)mainwin.FindName("Profile"); obj2.Visibility = Visibility.Visible; auth.Close(); } else { BadLogin.Visibility = Visibility.Visible; } }
public IUser CreateUser(int id, int flag) { return(_creator.CreateUser(this, id, flag)); }
public void DoHandshake() { Writer.WriteLine(VersionString); string email = Reader.ReadLine(); string password = Reader.ReadLine(); if (string.IsNullOrWhiteSpace(email) || string.IsNullOrWhiteSpace(password)) { Writer.WriteLine("Missing credentials."); Dispose(); return; } User = DatabaseContext.Instance.Users.FirstOrDefault(u => u.Email == email); if (email.StartsWith("+", StringComparison.Ordinal)) { email = email.Substring(1); User = DatabaseContext.Instance.Users.FirstOrDefault(u => u.Email == email); if (User == null) { try { new DnsStubResolver().Resolve <MxRecord>(new MailAddress(email).Host, RecordType.Mx).First(); } catch { Writer.WriteLine("Invalid email."); Dispose(); return; } User = new User { Email = email, PasswordHash = BCryptHelper.HashPassword(password, BCryptHelper.GenerateSalt()) }; UserCreator.CreateUser(User); Writer.WriteLine("Account created."); } else { Writer.WriteLine("Email taken."); } Dispose(); return; } else if (User != null) { if (BCryptHelper.CheckPassword(password, User.PasswordHash)) { Writer.WriteLine("Authentication successful."); Server.ConnectedUsers[User] = this; Reader.ReadLineAsync().ContinueWith(ReadCallback); LoadModel(); Timer.Start(); } else { Writer.WriteLine("Invalid password."); Dispose(); return; } } else { Writer.WriteLine("Invalid email."); Dispose(); return; } }