Ejemplo n.º 1
0
        public AutoCompleteOptionsTest(TestFixture fixture)
            : base(fixture)
        {
            var dashboard = this.Login();

            this.page = dashboard.Sidenav.NavigateToForm();
        }
Ejemplo n.º 2
0
        public DatetimepickerTest(TestFixture fixture)
            : base(fixture)
        {
            var dashboard = this.Login();

            this.page = dashboard.Sidenav.NavigateToForm();
        }
Ejemplo n.º 3
0
        public void CheckFormInputAndSubmitElements()
        {
            CustomLogs.startTestCase(System.Reflection.MethodBase.GetCurrentMethod().Name);

            try
            {
                HomePage homePage = HomePage;
                FormPage formPage = homePage.ClickOnFormBtn();
                Assert.IsTrue(formPage.CheckIfFormInputIsDisplayed());
                Assert.IsTrue(formPage.CheckIfSubmitBtnIsDisplayed());
            }
            catch (AssertFailedException afe)
            {
                CustomLogs.warn(afe.Message);
                throw new AssertFailedException(afe.Message);
            }
            catch (NoSuchElementException nsee)
            {
                CustomLogs.error(nsee.Message);
                throw new NoSuchElementException(nsee.Message);
            }
            catch (Exception exc)
            {
                CustomLogs.error(exc.Message + exc.StackTrace);
                throw new Exception(exc.Message);
            }
            finally
            {
                CustomLogs.endTestCase(System.Reflection.MethodBase.GetCurrentMethod().Name);
            }
        }
Ejemplo n.º 4
0
 public StepDefinitions()
 {
     chromeDriver = new ChromeDriver();
     formPage     = new FormPage(chromeDriver);
     homePage     = new HomePage(chromeDriver);
     navBar       = new NavBar(chromeDriver);
 }
Ejemplo n.º 5
0
        public void WhenIOpen(String Page)
        {
            switch (Page)
            {
            case "Home":
            {
                homePage    = new HomePage();
                currentPage = homePage;
                break;
            }

            case "Form":
            {
                formPage    = new FormPage();
                currentPage = formPage;
                break;
            }

            case "Error":
            {
                currentPage = new ErrorPage();
                break;
            }

            default:
            {
                homePage    = new HomePage();
                currentPage = homePage;
                break;
            }
            }
        }
Ejemplo n.º 6
0
        public SelectTest(TestFixture fixture)
            : base(fixture)
        {
            var dashboard = this.Login();

            this.page = dashboard.Sidenav.NavigateToForm();
        }
Ejemplo n.º 7
0
        //format the data from RecognizeContent into lines of strings
        private string[] formatResults(FormPage formPages)
        {
            List <string> lines = new List <string>();

            foreach (FormLine line in formPages.Lines)
            {
                string lineAsString = line.Text.Trim().ToLower();
                //not higher than 3 is seen as garbarge and will lower the quality of the result + easy to type for the user and most names start from 4+
                if (lineAsString.Length <= 3)
                {
                    continue;
                }
                if (lineAsString.Contains("@"))
                {
                    lineAsString = correctEmail(lineAsString);
                }
                string[] splitted = splitBigLine(lineAsString);
                foreach (string split in splitted)
                {
                    if (split.Length <= 3)
                    {
                        continue;
                    }
                    lines.Add(split);
                    Debug.WriteLine("--< tekst voor algoritme: " + split);
                }
                if (splitted.Length > 1)
                {
                    lines.Add(lineAsString);
                    Debug.WriteLine("--< tekst voor algoritme: " + lineAsString);
                }
            }
            return(lines.ToArray());
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Transforms provided <see cref="J400Claim"/> object to a collection of <see cref="FormPage"/>
        /// </summary>
        /// <param name="j400">Claim object to be transformed</param>
        /// <returns>Collection of <see cref="FormPage"/> objects</returns>
        public List <FormPage> TransformJ400ToFormPages(J400Claim j400)
        {
            var      pages = new List <FormPage>();
            FormPage page  = null;

            for (int i = 0; i < j400.ServiceLines.Count; i++)
            {
                if (i % 10 == 0)
                {
                    page = new FormPage();
                    pages.Add(page);
                    page.MasterReference = "j400";
                    page.ImagePath       = this.formImagePath;

                    AddBlock(page, 43, 8, 38, j400.Field12_SubscriberInformation.Line1);
                    AddBlock(page, 43, 9, 38, j400.Field12_SubscriberInformation.Line2);
                    AddBlock(page, 43, 10, 38, j400.Field12_SubscriberInformation.Line3);
                    AddBlock(page, 43, 11, 38, j400.Field12_SubscriberInformation.Line4);
                    AddBlock(page, 43, 13, 10, $"{j400.Field13_SubscriberDateOfBirth:MM/dd/yyyy}");
                    AddBlock(page, 57, 13, 1, j400.Field14_SubscriberGender_Female ? "X" : string.Empty);
                    AddBlock(page, 60, 13, 1, j400.Field14_SubscriberGender_Male ? "X" : string.Empty);
                    AddBlock(page, 65, 13, 15, j400.Field15_SubscriberId);
                    AddBlock(page, 43, 15, 11, j400.Field16_SubscriberGroupNumber);
                    AddBlock(page, 56, 15, 24, 'X'.Repeat(24));

                    AddBlock(page, 43, 18, 1, j400.Field18_PatientRelationshipToSubscriber_Self ? "X" : string.Empty);
                    AddBlock(page, 48, 18, 1, j400.Field18_PatientRelationshipToSubscriber_Spouse ? "X" : string.Empty);
                    AddBlock(page, 54, 18, 1, j400.Field18_PatientRelationshipToSubscriber_Dependent ? "X" : string.Empty);
                    AddBlock(page, 63, 18, 1, j400.Field04_OtherDentalOrMedicalCoverage ? "X" : string.Empty);
                    AddBlock(page, 43, 20, 38, j400.Field20_PatientInformation.Line1);
                    AddBlock(page, 43, 21, 38, j400.Field20_PatientInformation.Line2);
                    AddBlock(page, 43, 22, 38, j400.Field20_PatientInformation.Line3);
                    AddBlock(page, 43, 23, 38, j400.Field20_PatientInformation.Line4);
                    AddBlock(page, 43, 25, 10, $"{j400.Field21_PatientDateOfBirth:MM/dd/yyyy}");
                    AddBlock(page, 57, 25, 1, j400.Field22_PatientGender_Female ? "X" : string.Empty);
                    AddBlock(page, 60, 25, 1, j400.Field22_PatientGender_Male ? "X" : string.Empty);
                    AddBlock(page, 64, 25, 17, j400.Field23_PatientAccountNumber);
                }

                decimal y    = 29 + (i % 10);
                var     line = j400.ServiceLines[i];
                AddBlock(page, 2, y, 10, $"{line.Field24_ProcedureDate:MM/dd/yyyy}");
                AddBlock(page, 13, y, 2, line.Field25_AreaOfOralCavity);
                AddBlock(page, 16, y, 2, line.Field26_ToothSystem);
                AddBlock(page, 19, y, 11, line.Field27_ToothNumberOrLetter);
                AddBlock(page, 31, y, 5, line.Field28_ToothSurface);
                AddBlock(page, 37, y, 5, line.Field29_ProcedureCode);
                AddBlock(page, 43, y, 31, 'D'.Repeat(31));
                string amount = $"{line.Field31_Fee:0.00}".Replace(".", string.Empty);
                AddBlock(page, 81 - amount.Length, y, amount.Length, amount);

                // Footer
                if (i % 10 == 9 || i == j400.ServiceLines.Count - 1)
                {
                }
            }

            return(pages);
        }
Ejemplo n.º 9
0
 public FormSteps(IWebDriver driver, ExtentTest test, ScenarioContext scenarioContext)
 {
     _driver          = driver;
     _test            = test;
     _scenarioContext = scenarioContext;
     _commonPage      = new CommonPage(_driver, _test);
     _formPage        = new FormPage(_driver, _test, _commonPage);
 }
Ejemplo n.º 10
0
        public void CheckLogin(string username, string password, string expectedMessage)
        {
            var page = new FormPage(_driver);

            page.Open();
            var result = page.Login(username, password);

            Assert.IsTrue(result.Contains(expectedMessage));
        }
Ejemplo n.º 11
0
        public async Task StartRecognizeCustomFormsWithoutLabelsCanParseMultipageForm(bool useStream)
        {
            var client  = CreateFormRecognizerClient();
            var options = new RecognizeCustomFormsOptions()
            {
                IncludeFieldElements = true
            };
            RecognizeCustomFormsOperation operation;

            await using var trainedModel = await CreateDisposableTrainedModelAsync(useTrainingLabels : false, ContainerType.MultipageFiles);

            if (useStream)
            {
                using var stream = FormRecognizerTestEnvironment.CreateStream(TestFile.InvoiceMultipage);
                using (Recording.DisableRequestBodyRecording())
                {
                    operation = await client.StartRecognizeCustomFormsAsync(trainedModel.ModelId, stream, options);
                }
            }
            else
            {
                var uri = FormRecognizerTestEnvironment.CreateUri(TestFile.InvoiceMultipage);
                operation = await client.StartRecognizeCustomFormsFromUriAsync(trainedModel.ModelId, uri, options);
            }

            RecognizedFormCollection recognizedForms = await operation.WaitForCompletionAsync();

            Assert.AreEqual(2, recognizedForms.Count);

            for (int formIndex = 0; formIndex < recognizedForms.Count; formIndex++)
            {
                var recognizedForm     = recognizedForms[formIndex];
                var expectedPageNumber = formIndex + 1;

                ValidateModelWithNoLabelsForm(
                    recognizedForm,
                    trainedModel.ModelId,
                    includeFieldElements: true,
                    expectedFirstPageNumber: expectedPageNumber,
                    expectedLastPageNumber: expectedPageNumber);
            }

            // Basic sanity test to make sure pages are ordered correctly.

            FormPage  firstFormPage  = recognizedForms[0].Pages.Single();
            FormTable firstFormTable = firstFormPage.Tables.Single();

            Assert.True(firstFormTable.Cells.Any(c => c.Text == "Gold Sponsor"));

            FormField secondFormFieldInPage = recognizedForms[1].Fields.Values.Where(field => field.LabelData.Text.Contains("Company Name:")).FirstOrDefault();

            Assert.IsNotNull(secondFormFieldInPage);
            Assert.IsNotNull(secondFormFieldInPage.ValueData);
            Assert.AreEqual("Southridge Video", secondFormFieldInPage.ValueData.Text);
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Muestra la vista previa de un informe.
 /// </summary>
 /// <param name="pg"></param>
 /// <param name="withHeader"></param>
 public void ShowInforme(FormPage pg, bool withHeader = true)
 {
     SldTextSize.Value = pg.TextSize;
     SldImgWidth.Value = pg.ImgSize;
     page = pg;
     ChkConHeader.IsChecked   = withHeader;
     page.View.LayoutUpdated += UpdtLayout;
     FrmPreview.Navigate(pg);
     ShowDialog();
     page.View.LayoutUpdated -= UpdtLayout;
 }
Ejemplo n.º 13
0
        public void FillOutInfo()
        {
            PageLogin.GoTo();
            PageLogin.LoginAs(Inputs.email, Inputs.pass);

            //Go To Check Out Page and fill Out the Form
            FormPage.GoToCheckOut();
            FormPage.PersonalData(Inputs.name, Inputs.phone);
            FormPage.AddressData(Inputs.address, Inputs.zipcode);
            FormPage.LocationData(Inputs.city, Inputs.state, Inputs.country);
            //FormPage.SendData();
        }
Ejemplo n.º 14
0
        public void WhenISubmitFormWithNames()
        {
            formPage = homePage.OpenFormPage();

            foreach (string name in names)
            {
                helloPage = formPage.SubmitForm(name);
                helloPageResults.Add(helloPage.GetResultText());
                formPage = helloPage.ReturnToFormPage();
            }
            formPage.driver.Close();
        }
Ejemplo n.º 15
0
        public void WhenINavigateToEachPage()
        {
            pageTitles.Add("home page", homePage.GetTitle());
            pageLogos.Add("home page", homePage.IsCompanyLogoPresent());

            formPage = homePage.OpenFormPage();
            pageTitles.Add("form page", formPage.GetTitle());
            pageLogos.Add("form page", formPage.IsCompanyLogoPresent());

            errorPage = formPage.OpenErrorPage();
            pageTitles.Add("error page", errorPage.GetTitle());
            pageLogos.Add("error page", errorPage.IsCompanyLogoPresent());
        }
Ejemplo n.º 16
0
        private void BtnPrint_Click(object sender, RoutedEventArgs e)
        {
            PrintDialog dialog = new PrintDialog();

            if (!dialog.ShowDialog() ?? true)
            {
                return;
            }
            var sz       = new Size(dialog.PrintableAreaWidth, dialog.PrintableAreaHeight);
            var document = new FixedDocument();

            document.DocumentPaginator.PageSize = sz;
            for (int c = 1; c <= page.PgCount; c++)
            {
                var p = new FormPage(page.Data, page.Imgs, sz, page.Lang, false)
                {
                    ImgSize  = page.ImgSize,
                    TextSize = page.TextSize
                };
                if (c == page.PgCount)
                {
                    p.DoFirmas();
                }
                p.GotoPage(c);
                p.ShowPager(c, page.PgCount);
                p.Measure(sz);
                p.Arrange(new Rect(sz));
                p.UpdateLayout();
                p.FdpwContent.UpdateLayout();
                if (c == page.PgCount)
                {
                    MessageBox.Show("Imprimiendo documento...", "Imprimir", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                Grid pc = p.RootContent;
                p.Content = null;
                p         = null;
                pc.Measure(sz);
                pc.Arrange(new Rect(sz));
                pc.UpdateLayout();
                var fixedPage = new FixedPage
                {
                    Width  = sz.Width,
                    Height = sz.Height
                };
                fixedPage.Children.Add(pc);
                var pageContent = new PageContent();
                ((IAddChild)pageContent).AddChild(fixedPage);
                document.Pages.Add(pageContent);
            }
            dialog.PrintDocument(document.DocumentPaginator, $"Biopsia {page.TxtBiop.Text}");
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Updates this.Model.SerializedPages property
        /// </summary>
        private void TryUpdateModel(IList <FormDraftControl> pageBreakControls, out bool changesMade)
        {
            changesMade = false;
            var pageBreakControlIds = pageBreakControls.Select(c => c.Properties.First(p => p.Name == "ID").Value).ToList();
            var deserializedPages   = this.Model.DeserializePages().ToList();
            IList <FormPage> pages  = new List <FormPage>()
            {
                deserializedPages.First()
            };

            for (int i = 0; i < pageBreakControlIds.Count; i++)
            {
                var currentPage = deserializedPages.FirstOrDefault(p => p.PreviousPageBreakId == pageBreakControlIds[i].ToString());
                if (currentPage == null)
                {
                    string pageTitle = Res.Get <FieldResources>().PageName + (i + 2);
                    var    newPage   = new FormPage()
                    {
                        Title = pageTitle, PreviousPageBreakId = pageBreakControlIds[i].ToString(), Index = i + 1
                    };
                    pages.Add(newPage);

                    // A page has been added
                    changesMade = true;
                }
                else
                {
                    if (currentPage.Index != i + 1)
                    {
                        currentPage.Index = i + 1;
                        changesMade       = true;
                    }

                    pages.Add(currentPage);
                }
            }

            if (!changesMade)
            {
                // Check if a page has been deleted
                if (pages.Count != deserializedPages.Count)
                {
                    changesMade = true;
                }
            }

            if (changesMade)
            {
                this.Model.SerializedPages = JsonSerializer.SerializeToString(pages);
            }
        }
Ejemplo n.º 18
0
        public void SubmitQuestionUsingInvalidEmail()
        {
            //Arrange
            FormPage.OpenFormToShareYourCoronavirusStory();

            //Act
            FormDataPage.FillOutFormUsingInvalidEmail();
            FormToSubmitPage.SubmitYourStory();
            BasePage.ImplicitWait();

            //Assert
            Assert.AreEqual(expectegPageTitle, FormToSubmitPage.ActualPageTitle());
            Assert.AreEqual(1, FormToSubmitPage.AmountOfValidationErrors());
            Assert.AreEqual(errorEmailMessage, FormToSubmitPage.ValidationErrors[0].Text);
        }
Ejemplo n.º 19
0
        public void SubmitFormWithEmptyTextFieldForStory()
        {
            //Arrange
            FormPage.OpenFormToShareYourCoronavirusStory();

            //Act
            FormDataPage.FillOutFormWithoutEnteringStoryText();
            FormToSubmitPage.SubmitYourStory();
            BasePage.ImplicitWait();

            //Assert
            Assert.AreEqual(expectegPageTitle, FormToSubmitPage.ActualPageTitle());
            Assert.AreEqual(1, FormToSubmitPage.AmountOfValidationErrors());
            Assert.AreEqual(errorMessage, FormToSubmitPage.ValidationErrors[0].Text);
        }
Ejemplo n.º 20
0
        public void Test05()
        {
            ExReports.createTest("Automation Practice Form");
            FormPage f = new FormPage(BaseClass.getDriver);

            BaseClass.goToURL(FORM_URL);

            f.isElementPresent();
            f.selectLinks();
            f.fillUserFields();
            f.fillDate();
            f.selectSex();
            f.selectProfessionYearsAndTool();
            f.selectContinent();
            f.selectCommands();
        }
Ejemplo n.º 21
0
        public void SubmitEmptyFormForQuestion()
        {
            //Arrange
            FormPage.OpenFormToShareYourCoronavirusStory();

            //Act
            FormToSubmitPage.SubmitYourStory();
            BasePage.ImplicitWait();

            //Assert
            Assert.AreEqual(expectegPageTitle, FormToSubmitPage.ActualPageTitle());
            Assert.AreEqual(4, FormToSubmitPage.AmountOfValidationErrors());
            Assert.AreEqual(errorMessage, FormToSubmitPage.ValidationErrors[0].Text);
            Assert.AreEqual(errorNameMessage, FormToSubmitPage.ValidationErrors[1].Text);
            Assert.AreEqual(errorAcceptMessage, FormToSubmitPage.ValidationErrors[2].Text);
            Assert.AreEqual(errorAcceptMessage, FormToSubmitPage.ValidationErrors[3].Text);
        }
Ejemplo n.º 22
0
        //[Test]
        public void TheTestClass()
        {
            driver.Navigate().GoToUrl(baseURL + "/");
            driver.Manage().Window.Maximize();

            HomePage home = new HomePage(driver);

            home.InspectHomePages();

            FormPage form = new FormPage(driver);

            form.InspectFormPage();

            ErrorPage error = new ErrorPage(driver);

            error.InspectErrorPage();
        }
Ejemplo n.º 23
0
        private static FormBlock AddBlock(FormPage page, decimal x, decimal y, decimal width, string text, TextAlign textAlign = TextAlign.left)
        {
            const decimal XScale = 0.1m;
            const decimal YScale = 0.1685m;
            var           block  = new FormBlock
            {
                TextAlign = textAlign,
                Left      = -0.21m + XScale * x,
                Top       = 0.1m + YScale * y,
                Width     = XScale * width,
                Height    = YScale * 1.1m,
                Text      = text
            };

            page.Blocks.Add(block);
            return(block);
        }
Ejemplo n.º 24
0
        private FormBlock AddBlock(FormPage page, decimal x, decimal y, decimal width, string text, TextAlignEnum textAlign)
        {
            decimal xScale = 0.1m;
            decimal yScale = 0.1685m;
            var     block  = new FormBlock
            {
                TextAlign = textAlign,
                Left      = -0.21m + xScale * x,
                Top       = 0.1m + yScale * y,
                Width     = xScale * width,
                Height    = yScale * 1.1m,
                Text      = text
            };

            page.Blocks.Add(block);
            return(block);
        }
Ejemplo n.º 25
0
        private static FormBlock AddBlock(FormPage page, decimal x, decimal y, decimal width, string text, TextAlign textAlign = TextAlign.left)
        {
            decimal xScale = 0.100m;   // 0.0839m;
            decimal yScale = 0.16667m; // 0.1656m;
            var     block  = new FormBlock
            {
                LetterSpacing = "1.2px",
                TextAlign     = textAlign,
                Left          = 0.14m + xScale * x,
                Top           = 0.06m + yScale * y,
                Width         = xScale * width,
                Height        = yScale * 1.1m,
                Text          = text
            };

            page.Blocks.Add(block);
            return(block);
        }
Ejemplo n.º 26
0
        public FormPage GetFormPageModel(IPublishedContent content)
        {
            var result = new FormPage(content);

            result.ContactFormModel = new ContactFormModel()
            {
                LabelName      = result.LabelName,
                LabelFirstName = result.LabelFirstName,
                LabelAddress   = result.LabelAddress,
                LabelZipCity   = result.LabelZipCity,
                LabelPhone     = result.LabelPhone,
                LabelMail      = result.LabelMail,
                LabelMessage   = result.LabelMessage,
                Receiver       = result.ReceiverConfiguration,
                Customer       = result.CustomerConfiguration
            };

            return(result);
        }
Ejemplo n.º 27
0
        public void CheckTitleOfallPages()
        {
            CustomLogs.startTestCase(System.Reflection.MethodBase.GetCurrentMethod().Name);

            try
            {
                HomePage homePage = new HomePage(chrome, "home");
                Assert.IsTrue(homePage.checkPageName());

                homePage.ClickOnUITestingBtn();
                Assert.IsTrue(homePage.checkPageName());

                FormPage formPage = homePage.ClickOnFormBtn();
                Assert.IsTrue(formPage.checkPageName());

                homePage = formPage.ClickOnHomeBtn();
                Assert.IsTrue(homePage.checkPageName());
            }
            catch (AssertFailedException afe)
            {
                CustomLogs.warn(afe.Message);
                throw new AssertFailedException(afe.Message);
            }
            catch (NoSuchElementException nsee)
            {
                CustomLogs.error(nsee.Message);
                throw new NoSuchElementException(nsee.Message);
            }
            catch (Exception exc)
            {
                CustomLogs.error(exc.Message + exc.StackTrace);
                throw new Exception(exc.Message);
            }
            finally
            {
                CustomLogs.endTestCase(System.Reflection.MethodBase.GetCurrentMethod().Name);
            }
        }
Ejemplo n.º 28
0
        public void CheckHelloPage()
        {
            CustomLogs.startTestCase(System.Reflection.MethodBase.GetCurrentMethod().Name);

            try
            {
                HomePage homePage = HomePage;
                FormPage formPage = homePage.ClickOnFormBtn();

                foreach (string name in nameList)
                {
                    HelloPage hello = formPage.SetUpInputValueAndClickGo(name);
                    hello.checkIfCompanyLogoIsDisplayed();
                    hello.ReturnToFormPage();
                }
            }
            catch (AssertFailedException afe)
            {
                CustomLogs.warn(afe.Message);
                throw new AssertFailedException(afe.Message);
            }
            catch (NoSuchElementException nsee)
            {
                CustomLogs.error(nsee.Message);
                throw new NoSuchElementException(nsee.Message);
            }
            catch (Exception exc)
            {
                CustomLogs.error(exc.Message + exc.StackTrace);
                throw new Exception(exc.Message);
            }
            finally
            {
                CustomLogs.endTestCase(System.Reflection.MethodBase.GetCurrentMethod().Name);
            }
        }
Ejemplo n.º 29
0
        public HttpResponseMessage DeletePage(FormDataCollection Form)
        {
            HttpResponseMessage httpResponseMessage = Request.CreateResponse(HttpStatusCode.OK, "Some problem in delete master form page.");

            if (Form != null)
            {
                string PageNumber = Form["PageNumber"]?.ToString().Trim() ?? "";
                string FolderName = Form["FolderName"]?.ToString().Trim() ?? "";
                string result     = DBHelper.GetFileFriendlyName(FolderName);

                string workingDirectory = HttpContext.Current.Server.MapPath("~/" + RootFolderName + "/" + result);
                if (Directory.Exists(workingDirectory))
                {
                    using (RasterCodecs _codecs = new RasterCodecs())
                    {
                        RasterDefaults.DitheringMethod = RasterDitheringMethod.None;
                        ServiceHelper.SetLicense();

                        workingRepository = new DiskMasterFormsRepository(_codecs, workingDirectory);
                        var masterForm = workingRepository?.RootCategory?.MasterForms?.FirstOrDefault();
                        if (masterForm != null)
                        {
                            DiskMasterForm            currentMasterForm = (DiskMasterForm)masterForm;
                            FormRecognitionAttributes attributes        = currentMasterForm.ReadAttributes();

                            int currentPageIdx = Convert.ToInt32(PageNumber);

                            FormPages   formPages = currentMasterForm.ReadFields();
                            RasterImage formImage = currentMasterForm.ReadForm();

                            //Delete page from master form attaributes
                            DeletePageFromMasterForm(currentPageIdx + 1, attributes); //page number here is 1 based
                                                                                      //Delete fields page
                            formPages.RemoveAt(currentPageIdx);
                            //Delete the page from the image
                            if (formImage.PageCount == 1)
                            {
                                formImage = null; //You cannot remove the only page from a rasterimage, an exception will occur
                            }
                            else
                            {
                                formImage.RemovePageAt(currentPageIdx + 1);
                            }

                            //We need to recreate the FormPages to ensure the page numbers are updated correctly
                            for (int i = 0; i < formPages.Count; i++)
                            {
                                FormPage currentPage = formPages[i];
                                FormPage newPage     = new FormPage(i + 1, currentPage.DpiX, currentPage.DpiY);
                                newPage.AddRange(currentPage.GetRange(0, currentPage.Count));
                                formPages[i] = newPage;
                            }
                            //Write the updated masterform to disk. Delete it first just in case the entire image was deleted
                            DiskMasterFormsCategory parentCategory = (workingRepository.RootCategory) as DiskMasterFormsCategory;
                            parentCategory.DeleteMasterForm(currentMasterForm);
                            parentCategory.AddMasterForm(attributes, formPages, formImage);
                            httpResponseMessage = Request.CreateResponse(HttpStatusCode.OK, "Page deleted from master set sucessfully.");
                            DBHelper.UpdateTifPageCount(formPages.Count.ToString(), FolderName);
                        }
                    }
                }
            }
            return(httpResponseMessage);
        }
Ejemplo n.º 30
0
        protected void ValidateFormPage(FormPage formPage, bool includeFieldElements, int expectedPageNumber)
        {
            Assert.AreEqual(expectedPageNumber, formPage.PageNumber);

            Assert.Greater(formPage.Width, 0.0);
            Assert.Greater(formPage.Height, 0.0);

            Assert.That(formPage.TextAngle, Is.GreaterThan(-180.0).Within(0.01));
            Assert.That(formPage.TextAngle, Is.LessThanOrEqualTo(180.0).Within(0.01));

            Assert.NotNull(formPage.Lines);

            if (!includeFieldElements)
            {
                Assert.AreEqual(0, formPage.Lines.Count);
            }

            foreach (var line in formPage.Lines)
            {
                Assert.AreEqual(expectedPageNumber, line.PageNumber);
                Assert.NotNull(line.BoundingBox.Points);
                Assert.AreEqual(4, line.BoundingBox.Points.Length);
                Assert.NotNull(line.Text);

                if (line.Appearance != null)
                {
                    Assert.IsNotNull(line.Appearance.Style);
                    Assert.IsTrue(line.Appearance.Style.Name == TextStyleName.Handwriting || line.Appearance.Style.Name == TextStyleName.Other);
                    Assert.Greater(line.Appearance.Style.Confidence, 0f);
                }

                Assert.NotNull(line.Words);
                Assert.Greater(line.Words.Count, 0);

                foreach (var word in line.Words)
                {
                    Assert.AreEqual(expectedPageNumber, word.PageNumber);
                    Assert.NotNull(word.BoundingBox.Points);
                    Assert.AreEqual(4, word.BoundingBox.Points.Length);
                    Assert.NotNull(word.Text);

                    Assert.That(word.Confidence, Is.GreaterThanOrEqualTo(0.0).Within(0.01));
                    Assert.That(word.Confidence, Is.LessThanOrEqualTo(1.0).Within(0.01));
                }
            }

            Assert.NotNull(formPage.Tables);

            foreach (var table in formPage.Tables)
            {
                Assert.AreEqual(expectedPageNumber, table.PageNumber);
                Assert.Greater(table.ColumnCount, 0);
                Assert.Greater(table.RowCount, 0);
                if (_serviceVersion != FormRecognizerClientOptions.ServiceVersion.V2_0)
                {
                    Assert.AreEqual(4, table.BoundingBox.Points.Count());
                }

                Assert.NotNull(table.Cells);

                foreach (var cell in table.Cells)
                {
                    Assert.AreEqual(expectedPageNumber, cell.PageNumber);
                    Assert.NotNull(cell.BoundingBox.Points);
                    Assert.AreEqual(4, cell.BoundingBox.Points.Length);

                    Assert.GreaterOrEqual(cell.ColumnIndex, 0);
                    Assert.GreaterOrEqual(cell.RowIndex, 0);
                    Assert.GreaterOrEqual(cell.ColumnSpan, 1);
                    Assert.GreaterOrEqual(cell.RowSpan, 1);

                    Assert.That(cell.Confidence, Is.GreaterThanOrEqualTo(0.0).Within(0.01));
                    Assert.That(cell.Confidence, Is.LessThanOrEqualTo(1.0).Within(0.01));

                    Assert.NotNull(cell.Text);
                    Assert.NotNull(cell.FieldElements);

                    if (!includeFieldElements)
                    {
                        Assert.AreEqual(0, cell.FieldElements.Count);
                    }

                    foreach (var element in cell.FieldElements)
                    {
                        Assert.AreEqual(expectedPageNumber, element.PageNumber);
                        Assert.NotNull(element.BoundingBox.Points);
                        Assert.AreEqual(4, element.BoundingBox.Points.Length);

                        Assert.NotNull(element.Text);
                        Assert.True(element is FormWord || element is FormLine);
                    }
                }
            }

            Assert.NotNull(formPage.SelectionMarks);

            foreach (var selectionMark in formPage.SelectionMarks)
            {
                Assert.AreEqual(expectedPageNumber, selectionMark.PageNumber);
                Assert.NotNull(selectionMark.BoundingBox.Points);
                Assert.AreEqual(4, selectionMark.BoundingBox.Points.Length);
                Assert.IsNull(selectionMark.Text);
                Assert.NotNull(selectionMark.State);
                Assert.That(selectionMark.Confidence, Is.GreaterThanOrEqualTo(0.0).Within(0.01));
                Assert.That(selectionMark.Confidence, Is.LessThanOrEqualTo(1.0).Within(0.01));
            }
        }