public async Task FlushPointsAreExecutedForPagesWithComponentsPartialsAndSections(string action, string title) { var waitService = new WaitService(); var serviceProvider = GetServiceProvider(waitService); var server = TestServer.Create(serviceProvider, _app); var client = server.CreateClient(); // Act var stream = await client.GetStreamAsync("http://localhost/FlushPoint/" + action); // Assert - 1 Assert.Equal(string.Join(Environment.NewLine, "<title>" + title + "</title>", "", "RenderBody content"), GetTrimmedString(stream)); waitService.WaitForServer(); // Assert - 2 Assert.Equal(string.Join( Environment.NewLine, "partial-content", "", "Value from TaskReturningString", "<p>section-content</p>"), GetTrimmedString(stream)); waitService.WaitForServer(); // Assert - 3 Assert.Equal(string.Join( Environment.NewLine, "component-content", " <span>Content that takes time to produce</span>", "", "More content from layout"), GetTrimmedString(stream)); }
public async Task FlushPointsAreExecutedForPagesWithoutLayouts() { var waitService = new WaitService(); var serviceProvider = GetServiceProvider(waitService); var server = TestServer.Create(serviceProvider, _app); var client = server.CreateClient(); // Act var stream = await client.GetStreamAsync("http://localhost/FlushPoint/PageWithoutLayout"); // Assert - 1 Assert.Equal("Initial content", GetTrimmedString(stream)); waitService.WaitForServer(); // Assert - 2 Assert.Equal("Secondary content", GetTrimmedString(stream)); waitService.WaitForServer(); // Assert - 3 Assert.Equal("Inside partial", GetTrimmedString(stream)); waitService.WaitForServer(); // Assert - 4 Assert.Equal(@"After flush inside partial <form action=""/FlushPoint/PageWithoutLayout"" method=""post""><input id=""Name1"" name=""Name1"" type=""text"" value="""" />", GetTrimmedString(stream)); waitService.WaitForServer(); // Assert - 5 Assert.Equal(@"<input id=""Name2"" name=""Name2"" type=""text"" value="""" /></form>", GetTrimmedString(stream)); }
public async Task CreateAndCloseTabTest() { var window = AvaloniaApp.GetMainWindow(); await FocusFilePanelStep.FocusFilePanelAsync(window); var initialCount = GetTabsCount(window); for (var i = 0; i < 2; i++) { CreateNewTabStep.CreateNewTab(window); var isNewTabOpened = await WaitService.WaitForConditionAsync(() => initialCount + 1 == GetTabsCount(window)); Assert.True(isNewTabOpened); CloseCurrentTabStep.CloseCurrentTab(window); var isTabClosed = await WaitService.WaitForConditionAsync(() => initialCount == GetTabsCount(window)); Assert.True(isTabClosed); Keyboard.PressKey(window, Key.Tab); } ReopenClosedTabStep.ReopenClosedTab(window); var isTabReopened = await WaitService.WaitForConditionAsync(() => initialCount + 1 == GetTabsCount(window)); Assert.True(isTabReopened); CloseCurrentTabStep.CloseCurrentTab(window); }
public async Task FlushPointsNestedLayout() { // Arrange var waitService = new WaitService(); var server = TestHelper.CreateServer(_app, SiteName, services => { _configureServices(services); services.AddInstance(waitService); }); var client = server.CreateClient(); // Act var stream = await client.GetStreamAsync("http://localhost/FlushPoint/PageWithNestedLayout"); // Assert - 1 Assert.Equal(@"Inside Nested Layout <title>Nested Page With Layout</title>", GetTrimmedString(stream)); waitService.WaitForServer(); // Assert - 2 Assert.Equal("<span>Nested content that takes time to produce</span>", GetTrimmedString(stream)); }
public async Task FlushPointsAreExecutedForPagesWithLayouts() { var waitService = new WaitService(); var server = TestHelper.CreateServer(_app, SiteName, services => { _configureServices(services); services.AddInstance(waitService); }); var client = server.CreateClient(); // Act var stream = await client.GetStreamAsync("http://localhost/FlushPoint/PageWithLayout"); // Assert - 1 Assert.Equal(@"<title>Page With Layout</title>", GetTrimmedString(stream)); waitService.WaitForServer(); // Assert - 2 Assert.Equal(@"RenderBody content", GetTrimmedString(stream)); waitService.WaitForServer(); // Assert - 3 Assert.Equal(@"<span>Content that takes time to produce</span>", GetTrimmedString(stream)); }
public async Task FlushBeforeCallingLayout() { var waitService = new WaitService(); var server = TestHelper.CreateServer(_app, SiteName, services => { _configureServices(services); services.AddInstance(waitService); }); var client = server.CreateClient(); var expectedMessage = "Layout page '/Views/FlushPoint/PageWithFlushBeforeLayout.cshtml'" + " cannot be rendered after 'FlushAsync' has been invoked."; // Act var stream = await client.GetStreamAsync("http://localhost/FlushPoint/PageWithFlushBeforeLayout"); // Assert - 1 Assert.Equal("Initial content", GetTrimmedString(stream)); waitService.WaitForServer(); //Assert - 2 try { GetTrimmedString(stream); } catch (Exception ex) { Assert.Equal(expectedMessage, ex.InnerException.Message); } }
public async Task FlushPointsAreExecutedForPagesWithComponentsAndPartials() { var waitService = new WaitService(); var serviceProvider = GetServiceProvider(waitService); var server = TestServer.Create(serviceProvider, _app); var client = server.CreateClient(); // Act var stream = await client.GetStreamAsync("http://localhost/FlushPoint/PageWithPartialsAndViewComponents"); // Assert - 1 Assert.Equal( @"<title>Page With Components and Partials</title> RenderBody content", GetTrimmedString(stream)); waitService.WaitForServer(); // Assert - 2 Assert.Equal("partial-content", GetTrimmedString(stream)); waitService.WaitForServer(); // Assert - 3 Assert.Equal( @"component-content <span>Content that takes time to produce</span>", GetTrimmedString(stream)); }
private IServiceProvider GetServiceProvider(WaitService waitService) { var services = new ServiceCollection(); services.AddInstance(waitService); return(services.BuildServiceProvider(_provider)); }
public UIElement(IWebDriver webDriver, IWebElement webElement) { _webElementImplementation = webElement; _driver = webDriver; _waitService = new WaitService(webDriver); _actions = new Actions(webDriver); }
private IServiceProvider GetServiceProvider(WaitService waitService) { var services = new ServiceCollection(); services.AddInstance(waitService); return(TestHelper.CreateServices("RazorWebSite", services)); }
public async Task FlushBeforeCallingLayout() { var waitService = new WaitService(); var serviceProvider = GetServiceProvider(waitService); var server = TestServer.Create(serviceProvider, _app); var client = server.CreateClient(); var expectedMessage = "A layout page cannot be rendered after 'FlushAsync' has been invoked."; // Act var stream = await client.GetStreamAsync("http://localhost/FlushPoint/PageWithFlushBeforeLayout"); // Assert - 1 Assert.Equal("Initial content", GetTrimmedString(stream)); waitService.WaitForServer(); //Assert - 2 try { GetTrimmedString(stream); } catch (Exception ex) { Assert.Equal(expectedMessage, ex.InnerException.Message); } }
public UIElement(IWebDriver webDriver, By @by) { _selector = by; _driver = webDriver; _waitService = new WaitService(webDriver); _actions = new Actions(webDriver); _webElementImplementation = webDriver.FindElement(by); }
public async Task TestCopyFile() { var window = AvaloniaApp.GetMainWindow(); await FocusFilePanelStep.FocusFilePanelAsync(window); CreateNewTabStep.CreateNewTab(window); var viewModel = ActiveFilePanelProvider.GetActiveFilePanelViewModel(window); _directoryFullPath = Path.Combine(viewModel.CurrentDirectory, DirectoryName); Directory.CreateDirectory(_directoryFullPath); _fileFullPath = Path.Combine(viewModel.CurrentDirectory, FileName); await File.WriteAllTextAsync(_fileFullPath, FileContent); ChangeActiveFilePanelStep.ChangeActiveFilePanel(window); CreateNewTabStep.CreateNewTab(window); FocusDirectorySelectorStep.FocusDirectorySelector(window); var textSet = SetDirectoryTextStep.SetDirectoryText(window, _directoryFullPath); Assert.True(textSet); await Task.Delay(1000); ChangeActiveFilePanelStep.ChangeActiveFilePanel(window); await Task.Delay(100); ToggleSearchPanelStep.ToggleSearchPanelVisibility(window); await Task.Delay(100); SearchNodeStep.SearchNode(window, FileName); await Task.Delay(300); ChangeActiveFilePanelStep.ChangeActiveFilePanel(window); ChangeActiveFilePanelStep.ChangeActiveFilePanel(window); Keyboard.PressKey(window, Key.Down); Keyboard.PressKey(window, Key.Down); CopySelectedNodesStep.CopySelectedNodes(window); ToggleSearchPanelStep.ToggleSearchPanelVisibility(window); await Task.Delay(1000); var copiedFullPath = Path.Combine(_directoryFullPath, FileName); var fileExists = await WaitService.WaitForConditionAsync(() => File.Exists(copiedFullPath)); Assert.True(fileExists); var fileContent = await File.ReadAllTextAsync(copiedFullPath); Assert.Equal(FileContent, fileContent); Assert.True(File.Exists(_fileFullPath)); }
public void Test2() { var loginSteps = new LoginSteps(Driver); loginSteps.Login(); var element = WaitService.GetVisibleElement(By.Id("sidebar-projects-add")); Console.Out.WriteLine(element.Displayed); }
public async Task TestCreateDirectoryDialog() { var app = AvaloniaApp.GetApp(); var window = AvaloniaApp.GetMainWindow(); await FocusFilePanelStep.FocusFilePanelAsync(window); OpenCreateDirectoryDialogStep.OpenCreateDirectoryDialog(window); var isDialogOpened = await DialogOpenedCondition.CheckIfDialogIsOpenedAsync <CreateDirectoryDialog>(app); Assert.True(isDialogOpened); _dialog = app .Windows .OfType <CreateDirectoryDialog>() .Single(); var buttons = _dialog .GetVisualDescendants() .OfType <Button>() .ToArray(); Assert.Equal(2, buttons.Length); var createButton = buttons.SingleOrDefault(b => !b.Classes.Contains("transparentDialogButton")); Assert.NotNull(createButton); Assert.False(createButton.Command.CanExecute(null)); Assert.True(createButton.IsDefault); var directoryNameTextBox = _dialog .GetVisualDescendants() .OfType <TextBox>() .SingleOrDefault(); Assert.NotNull(directoryNameTextBox); Assert.True(string.IsNullOrEmpty(directoryNameTextBox.Text)); Assert.True(directoryNameTextBox.IsFocused); directoryNameTextBox.SendText("DirectoryName"); await WaitService.WaitForConditionAsync(() => createButton.Command.CanExecute(null)); var closeButton = buttons.SingleOrDefault(b => b.Classes.Contains("transparentDialogButton")); Assert.NotNull(closeButton); Assert.True(closeButton.Command.CanExecute(null)); Assert.False(closeButton.IsDefault); closeButton.Command.Execute(null); var isDialogClosed = await DialogClosedCondition.CheckIfDialogIsClosedAsync <CreateDirectoryDialog>(app); Assert.True(isDialogClosed); }
public void SubmitLogin() { var displayed = WaitService.WaitTillElementisDisplayed(_driver, _submitLocator, Config.ExplicitWait); if (displayed) { var actions = new Actions(_driver); _buttonSubmit = _driver.FindElement(_submitLocator); actions.MoveToElement(_buttonSubmit).Click().Build().Perform(); } }
public DropDownMenu(IWebDriver driver, By @by) { _waits = new WaitService(driver); _by = by; _uiElement = new UiElement(driver, by); // _dropDown = new Button(driver, By.("//span[contains(@class, 'caret')]//parent::a")); foreach (var option in _uiElement.FindElements(By.TagName("li"))) { _options.Add(new DropDownOption(driver, option)); } }
public BasePage(IWebDriver driver, bool openPageByUrl) { Driver = driver; WaitService = new WaitService(Driver); if (openPageByUrl) { OpenPage(); } WaitForOpen(); }
/// <summary> /// Marks the wait context as finished. /// </summary> public async Task <bool> FinishAsync() { if (WaitService.RemoveWaitContext(this)) { await endedEvent.InvokeAsync(this).ConfigureAwait(false); await finishedEvent.InvokeAsync(this).ConfigureAwait(false); return(true); } return(false); }
public void SetUp() { var productsPageSteps = new ProductsPageSteps(Driver); productsPageSteps.AddFirstProductToCart(); var cartPage = new CartPage(Driver, true); cartPage.CheckoutButton.Click(); _checkoutPage = new CheckoutPage(Driver); _detailsFormSteps = new DetailsFormSteps(Driver); _wait = new WaitService(Driver); }
/// <summary> /// Initializes a new instance of the <see cref="EventHandler"/> class. /// </summary> /// <param name="client"> /// The client. /// </param> /// <param name="homeService"> /// The home Service. /// </param> /// <param name="config"> /// The config. /// </param> /// <param name="service"> /// The service. /// </param> /// <param name="levels"> /// The levels. /// </param> /// <param name="channelHelper"> /// The channel Helper. /// </param> /// <param name="commandService"> /// The command service. /// </param> /// <param name="prefixService"> /// The prefix Service. /// </param> public EventHandler(DiscordShardedClient client, TranslateLimitsNew limits, WaitService waits, DBLApiService dblService, TranslateMethodsNew translationMethods, TranslationService translationService, HomeService homeService, ConfigModel config, IServiceProvider service, LevelHelper levels, ChannelHelper channelHelper, CommandService commandService, PrefixService prefixService) { Client = client; Config = config; Provider = service; CommandService = commandService; prefixOverride = DatabaseHandler.Settings.UsePrefixOverride; PrefixService = prefixService; _ChannelHelper = channelHelper; _LevelHelper = levels; _HomeService = homeService; _Translate = translationService; Limits = limits; Waits = waits; TranslationMethods = translationMethods; DBLApi = dblService; CancellationToken = new CancellationTokenSource(); }
public async Task ToggleFavouriteDirectoryTest() { var window = AvaloniaApp.GetMainWindow(); await FocusFilePanelStep.FocusFilePanelAsync(window); Assert.Equal(1, GetFavouriteDirectoriesCount(window)); Assert.Equal(2, GetFavouriteDirectoriesActiveIconsCount(window)); ToggleFavouriteDirectoryStep.ToggleFavouriteDirectory(window); await WaitService.WaitForConditionAsync(() => GetFavouriteDirectoriesCount(window) == 0); await WaitService.WaitForConditionAsync(() => GetFavouriteDirectoriesActiveIconsCount(window) == 0); ToggleFavouriteDirectoryStep.ToggleFavouriteDirectory(window); await WaitService.WaitForConditionAsync(() => GetFavouriteDirectoriesCount(window) == 1); await WaitService.WaitForConditionAsync(() => GetFavouriteDirectoriesActiveIconsCount(window) == 2); }
public async Task FlushPointsAreExecutedForPagesWithComponentsPartialsAndSections(string action, string title) { var waitService = new WaitService(); var server = TestHelper.CreateServer(_app, SiteName, services => { _configureServices(services); services.AddInstance(waitService); }); var client = server.CreateClient(); // Act var stream = await client.GetStreamAsync("http://localhost/FlushPoint/" + action); // Assert - 1 Assert.Equal( $@"<title>{ title }</title> RenderBody content", GetTrimmedString(stream), ignoreLineEndingDifferences: true); waitService.WaitForServer(); // Assert - 2 Assert.Equal( @"partial-content Value from TaskReturningString <p>section-content</p>", GetTrimmedString(stream), ignoreLineEndingDifferences: true); waitService.WaitForServer(); // Assert - 3 Assert.Equal( @"component-content <span>Content that takes time to produce</span> More content from layout", GetTrimmedString(stream), ignoreLineEndingDifferences: true); }
public async Task FlushPointsAreExecutedForPagesWithoutLayouts() { var waitService = new WaitService(); var serviceProvider = GetServiceProvider(waitService); var server = TestServer.Create(serviceProvider, _app); var client = server.CreateClient(); // Act var stream = await client.GetStreamAsync("http://localhost/FlushPoint/PageWithoutLayout"); // Assert - 1 Assert.Equal("Initial content", GetTrimmedString(stream)); waitService.WaitForServer(); // Assert - 2 Assert.Equal("Secondary content", GetTrimmedString(stream)); waitService.WaitForServer(); // Assert - 3 Assert.Equal("Final content", GetTrimmedString(stream)); }
public async Task FlushPointsAreExecutedForPagesWithoutLayouts() { var waitService = new WaitService(); var server = TestHelper.CreateServer(_app, SiteName, services => { _configureServices(services); services.AddInstance(waitService); }); var client = server.CreateClient(); // Act var stream = await client.GetStreamAsync("http://localhost/FlushPoint/PageWithoutLayout"); // Assert - 1 Assert.Equal("Initial content", GetTrimmedString(stream)); waitService.WaitForServer(); // Assert - 2 Assert.Equal("Secondary content", GetTrimmedString(stream)); waitService.WaitForServer(); // Assert - 3 Assert.Equal("Inside partial", GetTrimmedString(stream)); waitService.WaitForServer(); // Assert - 4 Assert.Equal( @"After flush inside partial <form action=""/FlushPoint/PageWithoutLayout"" method=""post""><input id=""Name1"" name=""Name1"" type=""text"" value="""" />", GetTrimmedString(stream), ignoreLineEndingDifferences: true); waitService.WaitForServer(); // Assert - 5 Assert.Equal( @"<input id=""Name2"" name=""Name2"" type=""text"" value="""" /></form>", GetTrimmedString(stream)); }
public async Task FlushPointsNestedLayout() { // Arrange var waitService = new WaitService(); var serviceProvider = GetServiceProvider(waitService); var server = TestServer.Create(serviceProvider, _app); var client = server.CreateClient(); // Act var stream = await client.GetStreamAsync("http://localhost/FlushPoint/PageWithNestedLayout"); // Assert - 1 Assert.Equal(@"Inside Nested Layout <title>Nested Page With Layout</title>", GetTrimmedString(stream)); waitService.WaitForServer(); // Assert - 2 Assert.Equal("<span>Nested content that takes time to produce</span>", GetTrimmedString(stream)); }
public async Task SetSubAsync(IRole role, SocketGuildUser user, TimeSpan time) { try { if (role.Position >= Context.Guild.GetUser(Context.Client.CurrentUser.Id).Hierarchy) { await SimpleEmbedAsync("Role level is higher than the bot and cannot be applied to another user."); return; } await user.AddRoleAsync(role); var roleModel = WaitService.AddTempRole(Context.Guild.Id, user.Id, role.Id, time); await SimpleEmbedAsync($"{user.Mention} will have the role {role.Mention} until: {roleModel.ExpiresOn.ToShortDateString()} {roleModel.ExpiresOn.ToShortTimeString()}"); } catch (Exception e) { await SimpleEmbedAsync("There was an error adding the role to the user"); Console.WriteLine(e.ToString()); } }
public MiniCartComponent(IWebDriver driver) : base(driver) { _waitService = new WaitService(Driver); }
public void Setup() { Driver = new BrowserService().WebDriver; WaitService = new WaitService(Driver); }
public Reminders(WaitService remind) { Remind = remind; }