示例#1
0
        public void ValidateSplitOutputStructure()
        {
            var tester = new FunctionTester <PdfOperationsProvider>();
            FunctionDesigner designer = tester.CreateDesigner();

            Assert.IsNull(designer.Output);

            Property operation = designer.Properties[PropertyNames.Operation];

            operation.Value = Operation.Split;

            Property loopResults = designer.Properties[PropertyNames.SplitLoopResults];

            loopResults.Value = false;

            Assert.AreEqual(0, designer.ExecutionPaths.Count);

            IEnumerable <ITypeProperty> properties = designer.Output.GetProperties();

            Assert.AreEqual(2, properties.Count());
            properties.ElementAt(0).AssertList(OutputNames.PageFiles, typeof(string));
            properties.ElementAt(1).AssertCompiled(OutputNames.NumberOfPages, typeof(int));

            loopResults.Value = true;

            Assert.AreEqual(1, designer.ExecutionPaths.Count);
            ExecutionPath executionPath = designer.ExecutionPaths[0];

            Assert.AreEqual(ExecutionPathNames.PageFiles, executionPath.Name);
            Assert.AreEqual(TypeReference.Create(typeof(string)), executionPath.Output);

            properties = designer.Output.GetProperties();
            Assert.AreEqual(1, properties.Count());
            properties.ElementAt(0).AssertCompiled(OutputNames.NumberOfPages, typeof(int));
        }
示例#2
0
		public void ValidateReadSignatureOutputStructure()
		{
			var tester = new FunctionTester<ReadProvider>();
			FunctionDesigner designer = tester.CreateDesigner();
			Assert.IsNull(designer.Output);

			Property readSignature = designer.Properties[PropertyNames.ReadSignature];
			Assert.IsFalse(readSignature.GetValue<bool>());
			readSignature.Value = true;

			IEnumerable<ITypeProperty> properties = designer.Output.GetProperties();
			Assert.AreEqual(1, properties.Count());
			properties.ElementAt(0).AssertGenerated(OutputNames.Signatures);

			properties = properties.ElementAt(0).TypeReference.GetProperties();
			Assert.AreEqual(3, properties.Count());
			properties.ElementAt(0).AssertCompiled(OutputNames.IsSigned, typeof(bool));
			properties.ElementAt(1).AssertGenerated(OutputNames.LatestSignature);
			ITypeReference signatureType = properties.ElementAt(1).TypeReference;
			properties.ElementAt(2).AssertList(OutputNames.AllSignatures, signatureType);

			properties = signatureType.GetProperties();
			Assert.AreEqual(9, properties.Count());
			properties.ElementAt(0).AssertCompiled(OutputNames.SignedBy, typeof(string));
			properties.ElementAt(1).AssertCompiled(OutputNames.SignedAt, typeof(string));
			properties.ElementAt(2).AssertCompiled(OutputNames.Reason, typeof(string));
			properties.ElementAt(3).AssertCompiled(OutputNames.SignedOn, typeof(DateTime));
			properties.ElementAt(4).AssertCompiled(OutputNames.Unmodified, typeof(bool));
			properties.ElementAt(5).AssertCompiled(OutputNames.SignedRevision, typeof(int));
			properties.ElementAt(6).AssertCompiled(OutputNames.IsLatestRevision, typeof(bool));
			properties.ElementAt(7).AssertCompiled(OutputNames.Verified, typeof(bool));
			properties.ElementAt(8).AssertCompiled(OutputNames.VerificationMessage, typeof(string));
		}
        public void ValidateReadTextOutputStructure()
        {
            var tester = new FunctionTester <ReadPdfProvider>();
            FunctionDesigner designer = tester.CreateDesigner();

            Assert.IsNull(designer.Output);

            Property readText = designer.Properties[PropertyNames.ReadText];

            Assert.IsFalse(readText.GetValue <bool>());
            readText.Value = true;

            Property splitText = designer.Properties[PropertyNames.SplitText];

            splitText.Value = TextSplit.Never;
            IEnumerable <ITypeProperty> properties = designer.Output.GetProperties();

            Assert.AreEqual(1, properties.Count());
            properties.ElementAt(0).AssertCompiled(OutputNames.Text, typeof(string));

            splitText.Value = TextSplit.Page;
            properties      = designer.Output.GetProperties();
            Assert.AreEqual(1, properties.Count());
            properties.ElementAt(0).AssertList(OutputNames.Text, typeof(string));
        }
示例#4
0
		public void ValidateReadFormDataOutputStructure()
		{
			var tester = new FunctionTester<ReadProvider>();
			FunctionDesigner designer = tester.CreateDesigner();
			Assert.IsNull(designer.Output);

			Property readFormData = designer.Properties[PropertyNames.ReadFormData];
			Assert.IsFalse(readFormData.GetValue<bool>());
			readFormData.Value = true;

			Property returnDataAs = designer.Properties[PropertyNames.ReturnFormDataAs];
			returnDataAs.Value = FormExtraction.CustomType;
			IEnumerable<ITypeProperty> properties = designer.Output.GetProperties();
			Assert.AreEqual(1, properties.Count());
			properties.ElementAt(0).AssertCompiled(OutputNames.FormData, typeof(object));

			Property formDataType = designer.Properties[PropertyNames.FormDataType];
			formDataType.Value = TypeReference.Create(typeof(string));
			properties = designer.Output.GetProperties();
			Assert.AreEqual(1, properties.Count());
			properties.ElementAt(0).AssertCompiled(OutputNames.FormData, typeof(string));

			returnDataAs.Value = FormExtraction.Infer;
			Property samplePdf = designer.Properties[PropertyNames.SamplePdf];
			Assert.AreEqual(string.Empty, samplePdf.GetValue<string>());
			properties = designer.Output.GetProperties();
			Assert.AreEqual(1, properties.Count());
			properties.ElementAt(0).AssertGenerated(OutputNames.FormData);
			Assert.AreEqual(0, properties.ElementAt(0).TypeReference.GetProperties().Count());

			string blankPdfFile = ResourceHelpers.WriteResourceToFile("Twenty57.Linx.Components.Pdf.Tests.Read.Resources.Blank.pdf", this.inputDirectory);
			samplePdf.Value = blankPdfFile;
			properties = designer.Output.GetProperties();
			Assert.AreEqual(1, properties.Count());
			properties.ElementAt(0).AssertGenerated(OutputNames.FormData);
			Assert.AreEqual(0, properties.ElementAt(0).TypeReference.GetProperties().Count());

			string inferPdfFile = ResourceHelpers.WriteResourceToFile("Twenty57.Linx.Components.Pdf.Tests.Read.Resources.InferFields.pdf", this.inputDirectory);
			samplePdf.Value = inferPdfFile;
			properties = designer.Output.GetProperties();
			Assert.AreEqual(1, properties.Count());
			properties.ElementAt(0).AssertGenerated(OutputNames.FormData);
			IEnumerable<ITypeProperty> outputProperties = properties.ElementAt(0).TypeReference.GetProperties();
			Assert.AreEqual(2, outputProperties.Count());
			outputProperties.ElementAt(0).AssertCompiled("First_32Name", typeof(string));
			outputProperties.ElementAt(1).AssertCompiled("Surname", typeof(string));

			returnDataAs.Value = FormExtraction.List;
			properties = designer.Output.GetProperties();
			Assert.AreEqual(1, properties.Count());
			properties.ElementAt(0).AssertList(OutputNames.FormDataList, typeof(KeyValuePair<string, string>));
		}