public static void AreEqual(XmlNode productNode, FertilizerProduct fertilizerProduct, Dictionary<string, List<UniqueId>> linkList)
        {
            if (productNode.GetXmlAttribute("A") == null || productNode.GetXmlAttribute("B") == null)
                return;

            UniqueIdAssert.AreEqual(linkList, productNode.GetXmlAttribute("A"), fertilizerProduct.Id.UniqueIds);
            Assert.AreEqual(productNode.GetXmlAttribute("A"), fertilizerProduct.Id.FindIsoId());
            Assert.AreEqual(productNode.GetXmlAttribute("B"), fertilizerProduct.Description);
        }
        public void ShouldWritePrescription()
        {
            // Setup
            var taskWriter = new TaskDocumentWriter();
            var adaptDocument = TestHelpers.LoadFromJson<ApplicationDataModel>(TestData.TestData.SingleProduct);
            var fertilizerProduct = new FertilizerProduct{ Description = "product"};
            fertilizerProduct.Id.ReferenceId = -1;
            adaptDocument.Catalog.Products.Add(fertilizerProduct);

            // Act
            using (taskWriter)
            {
                var actualXml = TestHelpers.Export(taskWriter, adaptDocument, _exportPath);
                Assert.AreEqual(TestData.TestData.SingleProductOutputXml, actualXml);
            }

            // Verify
            var expectedPath = Path.Combine(_exportPath, "TASKDATA", "GRD00000.BIN");
            Assert.AreEqual(TestData.TestData.SingleProductOutputTxt, TestHelpers.LoadFromFileAsHexString(expectedPath));
        }
Example #3
0
        private Product GetProduct(XmlNode inputNode)
        {
            var product = new FertilizerProduct { ProductType = ProductTypeEnum.Generic, Form = ProductFormEnum.Unknown };

            var groupId = inputNode.GetXmlNodeValue("@C");
            if (string.IsNullOrEmpty(groupId))
                return product;

            var groupNode = GetGroupNode(groupId);

            if (groupNode == null)
                return product;

            var groupType = groupNode.GetXmlNodeValue("@C");
            if (string.IsNullOrEmpty(groupType))
                return product;

            if (string.Equals(groupType, "2", StringComparison.OrdinalIgnoreCase))
                product.ProductType = ProductTypeEnum.Variety;

            return product;
        }