Пример #1
0
        public async void OnGet_VerifyAllHtmlElementsExist()
        {
            //Arrange
            var client = _appFactory.CreateAuthorizedClient();

            var response = await client.GetAsync("/NewPoem");

            var pageContent = await ResponseHelper.GetDocumentAsync(response);

            var selectors = new SelectorHelper(pageContent, PageElements.NewPoemPageSelectors);

            //Act
            var confirmationMessage        = selectors.Get <IHtmlElement>((int)PageElements.NewPoemElementEnum.ConfirmationMessage);
            var nameInput                  = selectors.Get <IHtmlElement>((int)PageElements.NewPoemElementEnum.NameInputField);
            var nameValidationMsg          = selectors.Get <IHtmlElement>((int)PageElements.NewPoemElementEnum.NameValidationMsg);
            var noteInput                  = selectors.Get <IHtmlElement>((int)PageElements.NewPoemElementEnum.NotesInputField);
            var conceivedDateInput         = selectors.Get <IHtmlElement>((int)PageElements.NewPoemElementEnum.ConceivedDateInputField);
            var conceivedDateValidationMsg = selectors.Get <IHtmlElement>((int)PageElements.NewPoemElementEnum.ConceivedDateValidationMsg);
            var titleInput                 = selectors.Get <IHtmlElement>((int)PageElements.NewPoemElementEnum.TitleInputField);
            var bodyInput                  = selectors.Get <IHtmlElement>((int)PageElements.NewPoemElementEnum.BodyInputField);

            //Assert
            Assert.NotNull(confirmationMessage);
            Assert.NotNull(nameInput);
            Assert.NotNull(nameValidationMsg);
            Assert.NotNull(noteInput);
            Assert.NotNull(conceivedDateInput);
            Assert.NotNull(conceivedDateValidationMsg);
            Assert.NotNull(titleInput);
            Assert.NotNull(bodyInput);
        }
Пример #2
0
        private HttpClient CreateClientAndTestData(Poem poem)
        {
            var client = _appFactory.CreateAuthorizedClient();

            _appFactory.DbContext.Add(poem);
            _appFactory.DbContext.SaveChanges();

            return(client);
        }
Пример #3
0
        public async void OnGet_WithMockAuth_ExpectSignoutWidget()
        {
            //Arrange
            var client = _appFactory.CreateAuthorizedClient();

            //Act
            var response = await client.GetAsync("/");

            var pageContent = await ResponseHelper.GetDocumentAsync(response);

            var selectors = new SelectorHelper(pageContent, PageElements.LoginPartialSelectors);

            //Assert
            var signoutWidget = selectors.Get <IHtmlAnchorElement>((int)PageElements.LoginPartialElementEnum.SignOutWidget);

            Assert.NotNull(signoutWidget);
        }
Пример #4
0
        public async void OnGet_ExpectReturnCurrentVersionNumber()
        {
            //Arrange
            var client          = _appFactory.CreateAuthorizedClient();
            var assembly        = Assembly.Load("Workshop.Web");
            var expectedVersion = assembly.GetName().Version.ToString();

            //Action
            var response = await client.GetAsync("/GetVersion");

            var pageContent = await ResponseHelper.GetDocumentAsync(response);

            var selectors = new SelectorHelper(pageContent, PageElements.GetVersionPageSelectors);

            var versionReturned = selectors.Get <IHtmlElement>(
                (int)PageElements.GetVersionPageElementEnum.VersionNumber);

            //Assert
            Assert.NotNull(versionReturned);
            Assert.Equal(expectedVersion, versionReturned.TextContent);
        }
Пример #5
0
        public async Task OnGet_SinglePoem_ExpectEditPoemLinks()
        {
            //Arrange
            var client = _appFactory.CreateAuthorizedClient();

            var testPoem = new PoemBuilder().Default().Build();

            _appFactory.DbContext.Add(testPoem);
            _appFactory.DbContext.SaveChanges();

            var response = await client.GetAsync("/ListPoemsByLastModifiedDate");

            var pageContent = await ResponseHelper.GetDocumentAsync(response);

            var selectors = new SelectorHelper(pageContent, PageElements.ListPoemsPageSelectors);

            //Action
            var link = selectors.Get <IHtmlAnchorElement>(
                (int)PageElements.ListPoemsPageElementEnum.EditLink,
                testPoem.Id.ToString());
            var name = selectors.Get <IHtmlElement>((int)PageElements.ListPoemsPageElementEnum.PoemName);

            //Assert
            Assert.NotNull(name);
            Assert.Equal(testPoem.Name, name.TextContent);

            Assert.NotNull(link);
            //Make sure link actually works
            response = await client.GetAsync(link.Href);

            pageContent = await ResponseHelper.GetDocumentAsync(response);

            var pageSelector = new SelectorHelper(pageContent, PageElements.EditPoemPageSelectors);
            var form         = pageSelector.Get <IHtmlFormElement>((int)PageElements.EditPoemElementEnum.EditPoemForm);

            Assert.NotNull(form);
        }