Пример #1
0
        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));
        }
Пример #2
0
        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));
        }
Пример #3
0
        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);
        }
Пример #4
0
        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));
        }
Пример #5
0
        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));
        }
Пример #6
0
        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);
            }
        }
Пример #7
0
        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));
        }
Пример #8
0
        private IServiceProvider GetServiceProvider(WaitService waitService)
        {
            var services = new ServiceCollection();

            services.AddInstance(waitService);
            return(services.BuildServiceProvider(_provider));
        }
Пример #9
0
 public UIElement(IWebDriver webDriver, IWebElement webElement)
 {
     _webElementImplementation = webElement;
     _driver      = webDriver;
     _waitService = new WaitService(webDriver);
     _actions     = new Actions(webDriver);
 }
Пример #10
0
        private IServiceProvider GetServiceProvider(WaitService waitService)
        {
            var services = new ServiceCollection();

            services.AddInstance(waitService);
            return(TestHelper.CreateServices("RazorWebSite", services));
        }
Пример #11
0
        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);
            }
        }
Пример #12
0
 public UIElement(IWebDriver webDriver, By @by)
 {
     _selector    = by;
     _driver      = webDriver;
     _waitService = new WaitService(webDriver);
     _actions     = new Actions(webDriver);
     _webElementImplementation = webDriver.FindElement(by);
 }
Пример #13
0
    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));
    }
Пример #14
0
        public void Test2()
        {
            var loginSteps = new LoginSteps(Driver);

            loginSteps.Login();

            var element = WaitService.GetVisibleElement(By.Id("sidebar-projects-add"));

            Console.Out.WriteLine(element.Displayed);
        }
Пример #15
0
    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);
    }
Пример #16
0
        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();
            }
        }
Пример #17
0
 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));
     }
 }
Пример #18
0
        public BasePage(IWebDriver driver, bool openPageByUrl)
        {
            Driver      = driver;
            WaitService = new WaitService(Driver);

            if (openPageByUrl)
            {
                OpenPage();
            }

            WaitForOpen();
        }
Пример #19
0
        /// <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);
        }
Пример #20
0
        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);
        }
Пример #21
0
        /// <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();
        }
Пример #22
0
    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);
    }
Пример #23
0
        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);
        }
Пример #24
0
        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));
        }
Пример #25
0
        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));
        }
Пример #26
0
        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));
        }
Пример #27
0
        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());
            }
        }
Пример #28
0
 public MiniCartComponent(IWebDriver driver) : base(driver)
 {
     _waitService = new WaitService(Driver);
 }
Пример #29
0
 public void Setup()
 {
     Driver      = new BrowserService().WebDriver;
     WaitService = new WaitService(Driver);
 }
Пример #30
0
 public Reminders(WaitService remind)
 {
     Remind = remind;
 }