public void Create_ShouldExecuteCorrectly() { var user = UserCreator.Create("test"); var list = new List <Topic>(); var topicRepo = DeletableEntityRepositoryMock.Get <Topic>(list); var service = new TopicService(topicRepo.Object); service.CreateAsync(user.Id, string.Empty, string.Empty).Wait(); Assert.Single(list); }
public void TestOfInvalidTimeIntervals() { User user = UserCreator.TakeStaticCredentials(); HomePage homePage = (HomePage) new HomePage(driver).OpenPage(HOMEPAGE_URL); SearchPage sp = (SearchPage)homePage.Login(user); CarSummaryPage csp = sp .SearchForTerms("9th Avenue, New York, NY, USA", false) .SelectCar(); Assert.AreEqual(INVALID_TIMERANGE_MSG, csp.PickDate("26/12/2019")); }
public void AmountOfCarsUserCanRent(int money, int durationHours) { User user = UserCreator.TakeStaticCredentials(); //return how many cars can user afford to rent HomePage homePage = (HomePage) new HomePage(driver).OpenPage(HOMEPAGE_URL); SearchPage sp = (SearchPage)homePage.Login(user); // /html/body/div[5]/div[5]/div[2]/div[1]/div[2]/div/div[1]/div[1]/div[2]/div/div/div/div/div/div/ul/li[1] Start time // /html/body/div[5]/div[5]/div[2]/div[1]/div[2]/div/div[1]/div[2]/div[2]/div/div/div/div/div/div/ul/li[5] End time // //div[@id="search-results-list"]/div[i]/div/div[2]/div i-th price }
public void SearchByEnteringTheWrongInformationInCheckIn() { UserCreator userCreator = new UserCreator(); RouteCreator route = new RouteCreator(); HomePage home = new HomePage(Driver) .CookieAcceptClick() .GoToCheckIn() .InputLastNameBookingReferenceAndOriginSurrogateCheckIn(userCreator.LastNameAndBookingReferenceProperties(), route.WithAllProperties()) .CheckInButtonClick(); Assert.IsTrue(home.ErrorFormIsDisplayed()); }
public void TestDeleteUser() { // given: User user = UserCreator.Create(); // when: UserService.Delete(user); User actualUser = UserService.GetByBusinessId(user.BusinessId); // then: Assert.IsNull(actualUser); }
private void Signal_Click(object sender, RoutedEventArgs e) { if (UserCreator.AuthStatus()) { FrameContent.Content = new Trading(); } else { FrameContent.Content = new SignalNoAuth(mainwin); login.Style = (Style)FindResource("PinkLogin"); } }
public async Task GetUser_AllPropertiesFilled_RepositoryUsernameEqualsRequestedAsync(NewUserDto data) { await UserCreator.CreateUserAsync(Factory, _contentProvider, data, Client); var currentUserPath = GetControllerActionPath(data.Username); var response = await Client.GetAsync(currentUserPath); var result = await response.Content.ReadAsAsync <UserDto>(); Assert.Equal(data.Username, result.Username); }
[Fact] // async Task<string> CreateAsync(string recipientId, OwnerTransactionRequestsCreateInputServiceModel model) public async void CreateAsync_WithGivenRecipientIdAndRequestModel_ShouldCreateTransactionRequest() { // Arrange var id = 1; var country = CountryCreator.Create(); var city = CityCreator.Create(country.Id); var tenant = UserCreator.Create("Shunko", "Svinski", "shunkata", "*****@*****.**"); var owner = UserCreator.Create("Suzdurma", "Saturov", "satura", "*****@*****.**"); var home = HomeCreator.CreateOwnerHome(owner.Id, city.Id); var contract = ContractCreator.CreateRentalContract(id); var rental = RentalCreator.Create(id, country, city, tenant, home, contract); await this.Context.Countries.AddAsync(country); await this.Context.Cities.AddAsync(city); await this.Context.Users.AddRangeAsync(owner, tenant); await this.Context.Homes.AddAsync(home); await this.Context.Contracts.AddAsync(contract); await this.Context.Rentals.AddRangeAsync(rental); await this.Context.SaveChangesAsync(); var recipientId = Guid.NewGuid().ToString(); var model = new OwnerTransactionRequestsCreateInputServiceModel { Id = Guid.NewGuid().ToString(), Reason = Guid.NewGuid().ToString(), RecurringSchedule = RecurringScheduleType.Monthly, IsRecurring = true, RentalId = id, }; var service = new OwnerTransactionRequestService(this.Context); // Act var result = await service.CreateAsync(owner.Id, model); var expected = await this.Context.TransactionRequests .Where(x => x.RecipientId == owner.Id) .FirstOrDefaultAsync(); // Assert result.Should().BeOfType <string>(); result.Should().Equals(expected.Id); }
public void CountPickupsByMakeAndCityTest(string carMake, string loc) { User user = UserCreator.TakeStaticCredentials(); //For example to test that there are more than 1 Toyota pickups in New York for renting HomePage homePage = (HomePage) new HomePage(driver).OpenPage(HOMEPAGE_URL); SearchPage sp = (SearchPage)homePage.Login(user); int expectedSearchResultsNumber = sp .SearchForTerms(loc, true) .CountSearchResultsCategory(carMake); Assert.AreEqual(0, expectedSearchResultsNumber); }
public void CheckSearchResultsAmount() { User user = UserCreator.TakeStaticCredentials(); HomePage homePage = (HomePage) new HomePage(driver).OpenPage(HOMEPAGE_URL); SearchPage sp = (SearchPage)homePage.Login(user); int expectedSearchResultsNumber = sp .SearchForTerms("9th Avenue, New York, NY, USA", false) .CountSearchResults(); Assert.IsTrue(expectedSearchResultsNumber > 0, "Search results are empty!"); }
public async Task GetAllUsers_AllPropertiesFilled_RepositoryUsernameEqualsRequestedAsync(NewUserDto data) { await UserCreator.CreateUserAsync(Factory, _contentProvider, data, Client); var path = GetControllerActionPath(); var response = await Client.GetAsync(path); response.EnsureSuccessStatusCode(); var result = await response.Content.ReadAsAsync <IEnumerable <UserDto> >(); Assert.Contains(data.Username, result.Select(dto => dto.Username)); }
private void InitializeAdmin() { var roles = new List <string>(); foreach (var role in Enum.GetValues(typeof(UserRoles))) { roles.Add(role.ToString()); } RoleCreator.CreateIfDontExsist(roles); UserCreator.CreateUserIfDontExists("admin", "P1p1K4k4", null, roles); }
public void Update_ShouldThrowExceptionWhenTopicDoesNotExists() { var user = UserCreator.Create("test"); var topic = TopicCreator.Create(user); var list = new List <Topic>(); var topicRepo = DeletableEntityRepositoryMock.Get <Topic>(list); var service = new TopicService(topicRepo.Object); Exception ex = Assert.Throws <AggregateException>(() => service.UpdateAsync(topic.Id, user.Id, string.Empty, string.Empty).Wait()); Assert.Contains("Topic does not exist", ex.Message); }
private async void Converter(object sender, RoutedEventArgs e) { if (TextCounttoken.Text == "0.00" || TextCounttoken.Text == "" || TextCounttoken.Text.Contains("-") || TextCounttoken.Text.Contains("!")) { MessageBox.Show("Error!"); return; } string result = TextCounttoken.Text.ToString().Replace('.', ','); TextCounttoken1.Text = await UserCreator.ConverterResult("kil", CryptoText.Text, CryptoText2.Text, float.Parse(result)); USDTFirst.Text = await UserCreator.USDAsyncPrice(CryptoText.Text, float.Parse(result)); }
public void SearchByEnteringTheWrongBookingReferenceTest() { UserCreator userCreator = new UserCreator(); string PageDialogText = new HomePage(Driver) .CookieAcceptClick() .GoToMyBooking() .InputLastNameAndBookingReference(userCreator.LastNameAndBookingReferenceProperties()) .RetrieveButtonOnMyBookingsClick() .GetPageDialogText(); Assert.AreEqual(PageDialogText, ErrorTextForSearchByEnteringTheWrongBookingReference); }
public void Add_ShouldThrowErrorWhenPhotoDoesNotExist() { var user = UserCreator.Create("test"); var photo = PhotoCreator.Create(user, false, true); var photosRepo = DeletableEntityRepositoryMock.Get <Photo>(new List <Photo>()); var commentsRepo = EfRepositoryMock.Get <Comment>(new List <Comment>()); var service = new CommentService(photosRepo.Object, commentsRepo.Object); Exception ex = Assert.Throws <AggregateException>(() => service.AddAsync(photo.Id, user.Id, "comment").Wait()); Assert.Contains("Photo does not exists!", ex.Message); }
public void When_GetUser_is_called_with_an_Id_and_there_is_no_User_in_the_collection_with_that_Id_then_an_InvalidOperationException_is_thrown() { var users = UserCreator.CreateCollection(); var userId = Guid.NewGuid(); BandCatalog .Expect(catalog => catalog.Users) .Return(users) .Repeat.Once(); BandCatalog.Replay(); Repository.GetUser(userId); }
public void ErrorWhenRegistrationWithEmptyField() { MakeScreenshotWhenFail(() => { Driver.Navigate().GoToUrl("https://21vek.by/"); string ErrorEmailString = "Неправильный формат электронной почты."; MainPage mainPage = new MainPage(Driver); var registationForm = mainPage.ClickOnAccountField().ClickToRegistrationButton(); registationForm.InputIncorrectEmail(UserCreator.WithAllIncorrectProperties()).ClickToRegistrationConfirmButton(); Assert.AreEqual(ErrorEmailString, registationForm.ErrorMessage.Text); }); }
public void IsUserExists() { var user = UserCreator.WithAllProperties(); BookingTrainTicketsPage register = new BookingTrainTicketsPage(Driver) .GoToPage(StartPage) .Login() .Register() .InputUserData(user) .SubmitReg(); Assert.IsTrue(register.IsUserExists()); }
public void TestDeleteUser() { // given: User user = UserCreator.Create(); // when: User actualUser = UserDao.Get(user.Id); UserDao.Delete(actualUser); UserDao.FlushAndClear(); // then: Exception Assert.Throws <ObjectNotFoundException>(() => UserDao.Get(user.Id)); }
private static bool AdminMainMenu() { bool logout = false; do { Console.Clear(); Console.WriteLine("Tiger Board!"); Console.WriteLine("Admin-meny"); Console.WriteLine(); Console.WriteLine("0. Logga ut"); Console.WriteLine("1. Skapa användare"); Console.WriteLine("2. Redigera användarinfo"); Console.WriteLine("3. Byt lösenord för användare"); Console.WriteLine(); Console.Write("Ditt val: "); string menuChoice = UserInput.GetInput <string>(); switch (menuChoice) { case "0": logout = LogoutConfirmation(); break; case "1": UserStore userStore = new UserStore(); UserCreator creator = new UserCreator(); creator.Create(userStore); break; case "2": UserManagerPresenter.ChangeUser(UserLevel.Admin); break; case "3": AdminPresenter.ChangeUserPassword(); break; case "4": var ds = new EducationClassStore(); EducationClassCreator edCreator = new EducationClassCreator(); edCreator.Create(ds); break; case "5": ClassListPresenter.MainMenu(); break; } } while (!logout); return(false); }
public async Task Delete_DeleteExistingUser_GetAfterDeleteReturnNotFoundAsync(NewUserDto data) { await UserCreator.CreateUserAsync(Factory, new ContentProvider(), data, Client); var currentUserPath = GetControllerActionPath(data.Username); var response = await Client.DeleteAsync(currentUserPath); response.EnsureSuccessStatusCode(); response = await Client.GetAsync(currentUserPath); Assert.Equal(HttpStatusCode.NotFound, response.StatusCode); }
public void LoginTest() { Test(() => { var user = UserCreator.CreateUser(_configuration); var homePage = new HomePage(_driver); var userName = homePage .GoTo() .GoToLoginPage(user) .GoToProfilePage() .GetLoggedUser(); Assert.AreEqual(user.Name, userName); }); }
public void When_Index_is_called_GetBlogArticles_on_IBlogProcess_is_called_and_the_result_is_mapped_with_BlogArticleMapper() { var user = UserCreator.CreateSingle(); var blogArticles = BlogArticleCreator.CreateCollection(); foreach (var blogArticle in blogArticles) { blogArticle.AuthorId = user.Id; } UserProcess .Expect(process => process.GetUser(user.Id)) .Return(user) .Repeat.Once(); UserProcess.Replay(); BlogProcess .Expect(process => process.GetBlogArticles()) .Return(blogArticles) .Repeat.Once(); BlogProcess.Replay(); var blogArticleDetailsModelcollection = CreateBlogArticleDetailsModelCollection(); BlogArticleMapper .Expect(mapper => mapper.Map( Arg <IEnumerable <BlogArticle> > .Matches(articles => blogArticles.All(blogArticle => articles.Any(article => article.Id == blogArticle.Id))), Arg <IEnumerable <User> > .Matches(users => users.Any(u => u == user)))) .Return(blogArticleDetailsModelcollection) .Repeat.Once(); BlogArticleMapper.Replay(); var result = Controller.Index().Result as ViewResult; Assert.IsNotNull(result); var model = result.Model as ItemListModel <BlogArticleDetailsModel>; Assert.IsNotNull(model); UserProcess.VerifyAllExpectations(); BlogProcess.VerifyAllExpectations(); BlogArticleMapper.VerifyAllExpectations(); }
public IActionResult SignUp([FromForm] User user) { UserCreator creator = new UserCreator(_userRepository); string error; if (creator.ValidateCreation(user, out error)) { creator.CreateUser(user); creator.SendActivationEmailAsync(user); return(RedirectToAction("Login")); } return(View()); }
public void Toggle_ShouldThrowErrorWhenPhotoDoesNotExists() { var user = UserCreator.Create("test"); var photo = PhotoCreator.Create(user, false, false); var favorites = new List <PhotoFavorite>(); var photosRepo = DeletableEntityRepositoryMock.Get <Photo>(new List <Photo>()); var favoritesRepo = EfRepositoryMock.Get <PhotoFavorite>(favorites); var service = new FavoritesService(favoritesRepo.Object, photosRepo.Object); Exception ex = Assert.Throws <AggregateException>(() => service.ToggleAsync(photo.Id, user.Id).Wait()); Assert.Contains("Photo does not exist", ex.Message); }
public void TestDeleteUserWithoutIssueReferences() { //Given: Ein Nutzer der nicht mit Vorgängen verbunden ist. User userToDelete = UserCreator.Create(); User userCreatedByUserToDelete = UserCreator.Create(creationDto: new EntityCreatedDto(userToDelete, new DateTime(2017, 01, 01))); User userEditedByUserToDelete = UserCreator.Create(latestChangeDto: new EntityChangedDto(userToDelete, new DateTime(2017, 01, 01))); //When: Der Nutzer gelöscht wird UserService.Delete(userToDelete); UserService.UserDao.FlushAndClear(); //Then: Darf er in der Anwendung nicht mehr vorhanden sein. Assert.Throws <ObjectNotFoundException>(() => UserService.GetById(userToDelete.Id)); }
[Fact] // 7. async Task<OwnerRequestDetailsServiceModel> GetRequestDetailsAsync(string requestId) public async void GetRequestDetailsAsync_WithGivenRequestId_ShouldReturnServiceModel() { // Arrange var country = CountryCreator.Create(); var city = CityCreator.Create(country.Id); var owner = UserCreator.Create("Suzdurma", "Saturov", "satura", "*****@*****.**"); var home = HomeCreator.CreateOwnerHome(owner.Id, city.Id); var request = RequestCreator.Create(home); var doc = new byte[1024]; request.Document = doc; await this.Context.Countries.AddAsync(country); await this.Context.Cities.AddAsync(city); await this.Context.Users.AddAsync(owner); await this.Context.Homes.AddAsync(home); await this.Context.Requests.AddAsync(request); await this.Context.SaveChangesAsync(); var model = new OwnerRequestDetailsServiceModel { Id = request.Id, Date = request.Date.ToString("dd/MM/yyyy h:mm tt"), UserFirstName = request.User.FirstName, UserLastName = request.User.LastName, Email = request.User.Email, Phone = request.User.PhoneNumber, RequestType = request.Type.ToString(), Document = doc, }; var service = new OwnerRequestService(this.Context); // Act var result = await service.GetRequestDetailsAsync(request.Id); var expected = model; // Assert result.Should().BeOfType <OwnerRequestDetailsServiceModel>(); result.Should().Equals(expected); }
public void TestFindByFirstname() { //Given: Mehrere Nutzer mit unterschiedlichen Vornamen const string SEARCH_TERM = "xyz"; User userFirstnameStartsWith = UserCreator.Create(firstname: SEARCH_TERM + "irgendwas"); User userFirstnameEndsWith = UserCreator.Create(firstname: "irgendwas" + SEARCH_TERM); User userFirstnameContains = UserCreator.Create(firstname: "irgend" + SEARCH_TERM + "was"); User userFirstnameDoesNotContain = UserCreator.Create(firstname: "irgendwas"); //When: Nach Nutzern mit einer bestimmten Zeichenfolge in ihrem Vornamen gesucht wird IPage <User> foundUsers = UserDao.FindUser(PageRequest.All, SEARCH_TERM); //Then: Dürfen nur Nutzer gefunden werden die diese Zeichenfolge in ihrem Vornamen haben foundUsers.ShouldAllBeEquivalentTo(new[] { userFirstnameContains, userFirstnameEndsWith, userFirstnameStartsWith }); }
public void TestFindByEmail() { //Given: Mehrere Nutzer mit unterschiedlichen E-Mail-Adressen const string SEARCH_TERM = "web"; User emailStartsWith = UserCreator.Create(email: SEARCH_TERM + "@gmx.net"); User emailEndsWith = UserCreator.Create(email: "info@online." + SEARCH_TERM); User emailContains = UserCreator.Create(email: "irgendwas@" + SEARCH_TERM + ".de"); User emailDoesNotContain = UserCreator.Create(email: "*****@*****.**"); //When: Nach Nutzern mit einer bestimmten Zeichenfolge in ihrem Nutzernamen gesucht wird IPage <User> foundUsers = UserDao.FindUser(PageRequest.All, SEARCH_TERM); //Then: Dürfen nur Nutzer gefunden werden die diese Zeichenfolge in ihrem Nutzernamen haben foundUsers.ShouldAllBeEquivalentTo(new[] { emailContains, emailEndsWith, emailStartsWith }); }