LoadFromFile() public method

public LoadFromFile ( string taskDataFile ) : bool
taskDataFile string
return bool
Esempio n. 1
0
        public void CropWithMissingRequiredInfoTest()
        {
            var crops = new List<String>
            {
                TestData.TestData.Crop4,
                TestData.TestData.Crop5,
                TestData.TestData.Crop6,
            };

            for (int i = 0; i < crops.Count; i++)
            {
                // Setup
                var taskDocument = new TaskDataDocument();
                var path = Path.Combine(_directory, String.Format("crop{0}.xml", i));
                File.WriteAllText(path, crops[i]);

                // Act
                var result = taskDocument.LoadFromFile(path);

                // Verify
                Assert.IsTrue(result);
                Assert.IsNotNull(taskDocument.Crops);
                Assert.AreEqual(0, taskDocument.Crops.Count);
            }
        }
Esempio n. 2
0
        public void FarmWithMissingCropZoneTest()
        {
            // Setup
            var taskDocument = new TaskDataDocument();
            var path = Path.Combine(_directory, "test.xml");
            File.WriteAllText(path, TestData.TestData.Field5);

            // Act
            var result = taskDocument.LoadFromFile(path);

            // Verify
            Assert.IsTrue(result);
            Assert.IsNotNull(taskDocument.Fields);
            Assert.AreEqual(1, taskDocument.Fields.Count);

            var field = taskDocument.Fields["PFD1"];
            Assert.AreEqual("Field 1", field.Description);
            Assert.AreEqual(12345, field.Area.Value.Value);
            Assert.AreEqual("m2", field.Area.Value.UnitOfMeasure.Code);

            Assert.AreEqual(0, taskDocument.CropZones.Count);

            Assert.AreEqual(1, taskDocument.Crops.Count);

            Assert.AreEqual(1, taskDocument.Farms.Count);
            var farm = taskDocument.Farms.First();
            Assert.AreEqual(farm.Value.Id.ReferenceId, field.FarmId);
        }
Esempio n. 3
0
        public void CropInExternalFileTest()
        {
            // Setup
            var taskDocument = new TaskDataDocument();
            var path = Path.Combine(_directory, "Crop3.xml");
            File.WriteAllText(path, TestData.TestData.Crop3);
            var ctpPath = Path.Combine(_directory, "CTP00003.xml");
            File.WriteAllText(ctpPath, TestData.TestData.CTP00003);

            // Act
            var result = taskDocument.LoadFromFile(path);

            // Verify
            Assert.IsTrue(result);
            Assert.IsNotNull(taskDocument.Crops);
            Assert.AreEqual(2, taskDocument.Crops.Count);

            var crop1 = taskDocument.Crops["CTP1"];
            Assert.AreEqual("Crop 1", crop1.Name);

            var crop2 = taskDocument.Crops["CTP2"];
            Assert.AreEqual("Crop 2", crop2.Name);

            Assert.IsNotNull(taskDocument.CropVarieties);
            Assert.AreEqual(4, taskDocument.CropVarieties.Count);
            for (int i = 0; i < taskDocument.CropVarieties.Count; i++)
            {
                var variety = taskDocument.CropVarieties.ElementAt(i);
                Assert.That(variety.Value.CropId, Is.EqualTo(crop1.Id.ReferenceId).Or.EqualTo(crop2.Id.ReferenceId));
                Assert.AreEqual(string.Format(CultureInfo.InvariantCulture, "CVT{0}", i + 1), variety.Key);
                Assert.AreEqual(string.Format(CultureInfo.InvariantCulture, "Variety {0}", i + 1), variety.Value.Description);
                Assert.AreEqual(ProductTypeEnum.Variety, variety.Value.ProductType);
            }
        }
Esempio n. 4
0
        public void CustomerInExternalFileTest()
        {
            // Setup
            var taskDocument = new TaskDataDocument();
            var path = Path.Combine(_directory, "test.xml");
            File.WriteAllText(path, TestData.TestData.Customer5);
            File.WriteAllText(Path.Combine(_directory, "CTR00005.xml"), TestData.TestData.CTR00005);

            // Act
            var result = taskDocument.LoadFromFile(path);

            // Verify
            Assert.IsTrue(result);
            Assert.IsNotNull(taskDocument.Customers);
            Assert.AreEqual(2, taskDocument.Customers.Count);

            var customer = taskDocument.Customers["CTR1"];

            Assert.AreEqual("Last1, First1", customer.Name);
            Assert.IsNotNull(customer.ContactInfo);
            Assert.AreEqual("Street1", customer.ContactInfo.AddressLine1);
            Assert.AreEqual("City1", customer.ContactInfo.City);
            Assert.AreEqual("Country1", customer.ContactInfo.Country);
            Assert.AreEqual("PO Box1", customer.ContactInfo.PoBoxNumber);
            Assert.AreEqual("PostalCode1", customer.ContactInfo.PostalCode);
            Assert.AreEqual("State1", customer.ContactInfo.StateOrProvince);
            Assert.IsNotNull(customer.ContactInfo.Contacts);
            Assert.AreEqual(4, customer.ContactInfo.Contacts.Count);
            Assert.AreEqual("Phone1", customer.ContactInfo.Contacts[0].Number);
            Assert.AreEqual(ContactTypeEnum.FixedPhone, customer.ContactInfo.Contacts[0].Type);
            Assert.AreEqual("Mobile1", customer.ContactInfo.Contacts[1].Number);
            Assert.AreEqual(ContactTypeEnum.MobilePhone, customer.ContactInfo.Contacts[1].Type);
            Assert.AreEqual("Fax1", customer.ContactInfo.Contacts[2].Number);
            Assert.AreEqual(ContactTypeEnum.Fax, customer.ContactInfo.Contacts[2].Type);
            Assert.AreEqual("Email1", customer.ContactInfo.Contacts[3].Number);
            Assert.AreEqual(ContactTypeEnum.Email, customer.ContactInfo.Contacts[3].Type);

            customer = taskDocument.Customers["CTR2"];

            Assert.AreEqual("Last2, First2", customer.Name);
            Assert.IsNotNull(customer.ContactInfo);
            Assert.AreEqual("Street2", customer.ContactInfo.AddressLine1);
            Assert.AreEqual("City2", customer.ContactInfo.City);
            Assert.AreEqual("Country2", customer.ContactInfo.Country);
            Assert.AreEqual("PO Box2", customer.ContactInfo.PoBoxNumber);
            Assert.AreEqual("PostalCode2", customer.ContactInfo.PostalCode);
            Assert.AreEqual("State2", customer.ContactInfo.StateOrProvince);
            Assert.IsNotNull(customer.ContactInfo.Contacts);
            Assert.AreEqual(4, customer.ContactInfo.Contacts.Count);
            Assert.AreEqual("Phone2", customer.ContactInfo.Contacts[0].Number);
            Assert.AreEqual(ContactTypeEnum.FixedPhone, customer.ContactInfo.Contacts[0].Type);
            Assert.AreEqual("Mobile2", customer.ContactInfo.Contacts[1].Number);
            Assert.AreEqual(ContactTypeEnum.MobilePhone, customer.ContactInfo.Contacts[1].Type);
            Assert.AreEqual("Fax2", customer.ContactInfo.Contacts[2].Number);
            Assert.AreEqual(ContactTypeEnum.Fax, customer.ContactInfo.Contacts[2].Type);
            Assert.AreEqual("Email2", customer.ContactInfo.Contacts[3].Number);
            Assert.AreEqual(ContactTypeEnum.Email, customer.ContactInfo.Contacts[3].Type);
        }
Esempio n. 5
0
        public void ProductMixInExternalFileTest()
        {
            // Setup
            var taskDocument = new TaskDataDocument();
            var path = Path.Combine(_directory, "test.xml");
            File.WriteAllText(path, TestData.TestData.ProductMix2);
            File.WriteAllText(Path.Combine(_directory, "PDT00002.xml"), TestData.TestData.PDT00002);

            // Act
            var result = taskDocument.LoadFromFile(path);

            // Verify
            Assert.IsTrue(result);
            Assert.IsNotNull(taskDocument.Products);
            Assert.AreEqual(1, taskDocument.Products.Count);

            var product = taskDocument.Products.First();
            Assert.AreEqual("PDT2", product.Key);
            Assert.AreEqual("Product 2", product.Value.Description);
            Assert.AreEqual(ProductTypeEnum.Generic, product.Value.ProductType);
            Assert.IsTrue(taskDocument.UnitsByItemId.ContainsKey(product.Key));
            Assert.AreEqual("l", taskDocument.UnitsByItemId[product.Key].Code);

            Assert.IsNotNull(taskDocument.ProductMixes);
            Assert.AreEqual(1, taskDocument.ProductMixes.Count);

            var productMix = taskDocument.ProductMixes.First();
            Assert.AreEqual("PDT1", productMix.Key);
            Assert.AreEqual("Product 1", productMix.Value.Description);
            Assert.AreEqual(ProductTypeEnum.Mix, productMix.Value.ProductType);
            Assert.IsNotNull(productMix.Value.TotalQuantity);
            Assert.AreEqual("l", productMix.Value.TotalQuantity.Value.UnitOfMeasure.Code);

            Assert.AreEqual(1, productMix.Value.ProductComponents.Count);
            var productComponent = productMix.Value.ProductComponents.First();
            Assert.AreEqual(1, productComponent.Quantity.Value.Value);
            Assert.AreEqual("l", productComponent.Quantity.Value.UnitOfMeasure.Code);
            Assert.AreEqual(productComponent.IngredientId, product.Value.Id.ReferenceId);

            Assert.IsNotNull(taskDocument.Ingredients);
            Assert.AreEqual(1, taskDocument.Ingredients.Count);

            var ingredient = taskDocument.Ingredients.First() as ActiveIngredient;
            Assert.IsNotNull(ingredient);
        }
Esempio n. 6
0
        public void FarmInExternalFileTest()
        {
            // Setup
            var taskDocument = new TaskDataDocument();
            var path = Path.Combine(_directory, "test.xml");
            File.WriteAllText(path, TestData.TestData.Farm4);
            var frmPath = Path.Combine(_directory, "FRM00004.xml");
            File.WriteAllText(frmPath, TestData.TestData.FRM00004);

            // Act
            var result = taskDocument.LoadFromFile(path);

            // Verify
            Assert.IsTrue(result);
            Assert.IsNotNull(taskDocument.Farms);
            Assert.AreEqual(2, taskDocument.Farms.Count);

            var farm = taskDocument.Farms["FRM1"];

            Assert.AreEqual("Farm1", farm.Description);
            Assert.IsNotNull(farm.ContactInfo);
            Assert.AreEqual("Street1", farm.ContactInfo.AddressLine1);
            Assert.AreEqual("City1", farm.ContactInfo.City);
            Assert.AreEqual("Country1", farm.ContactInfo.Country);
            Assert.AreEqual("PO Box1", farm.ContactInfo.PoBoxNumber);
            Assert.AreEqual("PostalCode1", farm.ContactInfo.PostalCode);
            Assert.AreEqual("State1", farm.ContactInfo.StateOrProvince);
            Assert.IsEmpty(farm.ContactInfo.Contacts);
            Assert.AreEqual(taskDocument.Customers["CTR1"].Id.ReferenceId, farm.GrowerId.Value);

            farm = taskDocument.Farms["FRM2"];

            Assert.AreEqual("Farm2", farm.Description);
            Assert.IsNotNull(farm.ContactInfo);
            Assert.AreEqual("Street2", farm.ContactInfo.AddressLine1);
            Assert.AreEqual("City2", farm.ContactInfo.City);
            Assert.AreEqual("Country2", farm.ContactInfo.Country);
            Assert.AreEqual("PO Box2", farm.ContactInfo.PoBoxNumber);
            Assert.AreEqual("PostalCode2", farm.ContactInfo.PostalCode);
            Assert.AreEqual("State2", farm.ContactInfo.StateOrProvince);
            Assert.IsEmpty(farm.ContactInfo.Contacts);
            Assert.AreEqual(taskDocument.Customers["CTR2"].Id.ReferenceId, farm.GrowerId.Value);
        }
Esempio n. 7
0
        public void FarmUniqueIdIsSetCorrectly()
        {
            // Setup
            var taskDocument = new TaskDataDocument();
            var path = Path.Combine(_directory, "test.xml");
            File.WriteAllText(path, TestData.TestData.Farm1);

            // Act
            var result = taskDocument.LoadFromFile(path);

            // Verify
            var farm = taskDocument.Farms["FRM1"];
            const string expectedSource = "http://dictionary.isobus.net/isobus/";
            const CompoundIdentifierTypeEnum expectedType = CompoundIdentifierTypeEnum.String;

            Assert.AreEqual("FRM1", farm.Id.UniqueIds[0].Id);
            Assert.AreEqual(expectedType, farm.Id.UniqueIds[0].CiTypeEnum);
            Assert.AreEqual(expectedSource, farm.Id.UniqueIds[0].Source);
        }
Esempio n. 8
0
        public void CommentInExternalFileTest()
        {
            // Setup
            var taskDocument = new TaskDataDocument();
            var path = Path.Combine(_directory, "comment2.xml");
            File.WriteAllText(path, TestData.TestData.Comment2);
            File.WriteAllText(Path.Combine(_directory, "CCT00002.xml"), TestData.TestData.CCT00002);

            // Act
            var result = taskDocument.LoadFromFile(path);

            // Verify
            Assert.IsTrue(result);
            Assert.IsNotNull(taskDocument.Comments);
            Assert.AreEqual(2, taskDocument.Comments.Count);

            var comment = taskDocument.Comments["CCT1"];

            Assert.AreEqual("Comment 1", comment.Comment.Description);
            Assert.AreEqual(2, comment.Scope);
            Assert.AreEqual(2, comment.Comment.EnumeratedMembers.Count);

            Assert.AreEqual("Comment value 1", comment.Comment.EnumeratedMembers[0].Value);
            Assert.AreEqual("Comment value 2", comment.Comment.EnumeratedMembers[1].Value);

            Assert.AreEqual(2, comment.Values.Count);
            Assert.AreEqual("Comment value 1", comment.Values["CCL1"].Value);
            Assert.AreEqual("Comment value 2", comment.Values["CCL2"].Value);

            comment = taskDocument.Comments["CCT2"];

            Assert.AreEqual("Comment 2", comment.Comment.Description);
            Assert.AreEqual(2, comment.Scope);
            Assert.AreEqual(2, comment.Comment.EnumeratedMembers.Count);

            Assert.AreEqual("Comment value 3", comment.Comment.EnumeratedMembers[0].Value);
            Assert.AreEqual("Comment value 4", comment.Comment.EnumeratedMembers[1].Value);

            Assert.AreEqual(2, comment.Values.Count);
            Assert.AreEqual("Comment value 3", comment.Values["CCL3"].Value);
            Assert.AreEqual("Comment value 4", comment.Values["CCL4"].Value);
        }
Esempio n. 9
0
        public void LoadSeedProductTest()
        {
            // Setup
            var taskDocument = new TaskDataDocument();
            var path = Path.Combine(_directory, "test.xml");
            File.WriteAllText(path, TestData.TestData.Product3);

            // Act
            var result = taskDocument.LoadFromFile(path);

            // Verify
            Assert.IsTrue(result);
            Assert.IsNotNull(taskDocument.Products);
            Assert.AreEqual(1, taskDocument.Products.Count);

            var product = taskDocument.Products.First();
            Assert.AreEqual("PDT1", product.Key);
            Assert.AreEqual("Product 1", product.Value.Description);
            Assert.AreEqual(ProductTypeEnum.Generic, product.Value.ProductType);
            Assert.IsTrue(taskDocument.UnitsByItemId.ContainsKey(product.Key));
            Assert.AreEqual("count", taskDocument.UnitsByItemId[product.Key].Code);
        }
Esempio n. 10
0
        public void CommentWithInvalidValuesTest()
        {
            // Setup
            var taskDocument = new TaskDataDocument();
            var path = Path.Combine(_directory, "comment6.xml");
            File.WriteAllText(path, TestData.TestData.Comment9);

            // Act
            var result = taskDocument.LoadFromFile(path);

            // Verify
            Assert.IsTrue(result);
            Assert.IsNotNull(taskDocument.Comments);
            Assert.AreEqual(1, taskDocument.Comments.Count);

            var comment = taskDocument.Comments["CCT1"];

            Assert.AreEqual("Comment 1", comment.Comment.Description);
            Assert.AreEqual(2, comment.Scope);
            Assert.IsEmpty(comment.Comment.EnumeratedMembers);
            Assert.IsNull(comment.Values);
        }
Esempio n. 11
0
        public void ProductMixWithMissingComponentsTest()
        {
            // Setup
            var taskDocument = new TaskDataDocument();
            var path = Path.Combine(_directory, "test.xml");
            File.WriteAllText(path, TestData.TestData.ProductMix3);

            // Act
            var result = taskDocument.LoadFromFile(path);

            // Verify
            Assert.IsTrue(result);
            Assert.IsNotNull(taskDocument.ProductMixes);
            Assert.AreEqual(0, taskDocument.ProductMixes.Count);

            Assert.IsNotNull(taskDocument.Ingredients);
            Assert.AreEqual(0, taskDocument.Ingredients.Count);
        }
Esempio n. 12
0
        private static TaskDataDocument ConvertTaskDataFileToModel(string taskDataFile, ApplicationDataModel.ADM.ApplicationDataModel dataModel)
        {
            var taskDocument = new TaskDataDocument();
            if (taskDocument.LoadFromFile(taskDataFile) == false)
                return taskDocument;

            var catalog = new Catalog();
            catalog.Growers = taskDocument.Customers.Values.ToList();
            catalog.Farms = taskDocument.Farms.Values.ToList();
            catalog.Fields = taskDocument.Fields.Values.ToList();
            catalog.GuidanceGroups = taskDocument.GuidanceGroups.Values.Select(x => x.Group).ToList();
            catalog.GuidancePatterns = taskDocument.GuidanceGroups.Values.SelectMany(x => x.Patterns.Values).ToList();
            catalog.Crops = taskDocument.Crops.Values.ToList();
            catalog.CropZones = taskDocument.CropZones.Values.ToList();
            catalog.DeviceElements = taskDocument.Machines.Values.ToList();
            catalog.FieldBoundaries = taskDocument.FieldBoundaries;
            catalog.Ingredients = taskDocument.Ingredients;
            catalog.Prescriptions = taskDocument.RasterPrescriptions.Cast<Prescription>().ToList();
            catalog.ContactInfo = taskDocument.Contacts;
            catalog.Products = AddAllProducts(taskDocument);

            dataModel.Catalog = catalog;

            var documents = new Documents();
            documents.GuidanceAllocations = taskDocument.GuidanceAllocations;
            documents.LoggedData = taskDocument.Tasks;

            dataModel.Documents = documents;

            return taskDocument;
        }
Esempio n. 13
0
        public IList<IError> ValidateDataOnCard(string dataPath, Properties properties = null)
        {
            var errors = new List<IError>();
            var taskDataFiles = GetListOfTaskDataFiles(dataPath);
            if (!taskDataFiles.Any())
                return errors;

            foreach (var taskDataFile in taskDataFiles)
            {
                var taskDocument = new TaskDataDocument();
                if (taskDocument.LoadFromFile(taskDataFile) == false)
                {
                    errors.AddRange(taskDocument.Errors);
                }
            }

            return errors;
        }
Esempio n. 14
0
        public void ProductInExternalFileTest()
        {
            // Setup
            var taskDocument = new TaskDataDocument();
            var path = Path.Combine(_directory, "test.xml");
            File.WriteAllText(path, TestData.TestData.Product5);
            File.WriteAllText(Path.Combine(_directory, "PDT00005.xml"), TestData.TestData.PDT00005);

            // Act
            var result = taskDocument.LoadFromFile(path);

            // Verify
            Assert.IsTrue(result);
            Assert.IsNotNull(taskDocument.Products);
            Assert.AreEqual(2, taskDocument.Products.Count);

            var product = taskDocument.Products["PDT1"];
            Assert.AreEqual("Product 1", product.Description);

            var product2 = taskDocument.Products["PDT2"];
            Assert.AreEqual("Product 2", product2.Description);
        }
Esempio n. 15
0
        public void LoadCustomerInfoTest()
        {
            // Setup
            var taskDocument = new  TaskDataDocument();
            var path = Path.Combine(_directory, "test.xml");
            File.WriteAllText(path, TestData.TestData.Customer1);

            // Act
            var result = taskDocument.LoadFromFile(path);

            // Verify
            Assert.IsTrue(result);
            Assert.IsNotNull(taskDocument.Customers);
            Assert.AreEqual(1, taskDocument.Customers.Count);
            var customer = taskDocument.Customers.First();
            Assert.AreEqual("CTR1", customer.Key);
            Assert.AreEqual("Last, First", customer.Value.Name);
            Assert.IsNotNull(customer.Value.ContactInfo);
            Assert.AreEqual("Street", customer.Value.ContactInfo.AddressLine1);
            Assert.AreEqual("City", customer.Value.ContactInfo.City);
            Assert.AreEqual("Country", customer.Value.ContactInfo.Country);
            Assert.AreEqual("PO Box", customer.Value.ContactInfo.PoBoxNumber);
            Assert.AreEqual("PostalCode", customer.Value.ContactInfo.PostalCode);
            Assert.AreEqual("State", customer.Value.ContactInfo.StateOrProvince);
            Assert.IsNotNull(customer.Value.ContactInfo.Contacts);
            Assert.AreEqual(4, customer.Value.ContactInfo.Contacts.Count);
            Assert.AreEqual("Phone", customer.Value.ContactInfo.Contacts[0].Number);
            Assert.AreEqual(ContactTypeEnum.FixedPhone, customer.Value.ContactInfo.Contacts[0].Type);
            Assert.AreEqual("Mobile", customer.Value.ContactInfo.Contacts[1].Number);
            Assert.AreEqual(ContactTypeEnum.MobilePhone, customer.Value.ContactInfo.Contacts[1].Type);
            Assert.AreEqual("Fax", customer.Value.ContactInfo.Contacts[2].Number);
            Assert.AreEqual(ContactTypeEnum.Fax, customer.Value.ContactInfo.Contacts[2].Type);
            Assert.AreEqual("Email", customer.Value.ContactInfo.Contacts[3].Number);
            Assert.AreEqual(ContactTypeEnum.Email, customer.Value.ContactInfo.Contacts[3].Type);
        }
Esempio n. 16
0
        public void LoadCommentTest()
        {
            // Setup
            var taskDocument = new  TaskDataDocument();
            var path = Path.Combine(_directory, "comment1.xml");
            File.WriteAllText(path, TestData.TestData.Comment1);

            // Act
            var result = taskDocument.LoadFromFile(path);

            // Verify
            Assert.IsTrue(result);
            Assert.IsNotNull(taskDocument.Comments);
            Assert.AreEqual(1, taskDocument.Comments.Count);
            var comment = taskDocument.Comments.First();
            Assert.AreEqual("CCT1", comment.Key);
            Assert.AreEqual("Comment 1", comment.Value.Comment.Description);
            Assert.AreEqual(2, comment.Value.Scope);
            Assert.AreEqual(2, comment.Value.Comment.EnumeratedMembers.Count);

            Assert.AreEqual("Comment value 1", comment.Value.Comment.EnumeratedMembers[0].Value);
            Assert.AreEqual("Comment value 2", comment.Value.Comment.EnumeratedMembers[1].Value);

            Assert.AreEqual(2, comment.Value.Values.Count);
            Assert.AreEqual("Comment value 1", comment.Value.Values["CCL1"].Value);
            Assert.AreEqual("Comment value 2", comment.Value.Values["CCL2"].Value);
        }
Esempio n. 17
0
        public void FarmWithMissingContactInfoTest()
        {
            // Setup
            var taskDocument = new TaskDataDocument();
            var path = Path.Combine(_directory, "test.xml");
            File.WriteAllText(path, TestData.TestData.Farm2);

            // Act
            var result = taskDocument.LoadFromFile(path);

            // Verify
            Assert.IsTrue(result);
            Assert.IsNotNull(taskDocument.Farms);
            Assert.AreEqual(1, taskDocument.Farms.Count);
            var farm = taskDocument.Farms.First();
            Assert.AreEqual("FRM1", farm.Key);
            Assert.AreEqual("Farm", farm.Value.Description);
            Assert.IsNotNull(farm.Value.ContactInfo);
            Assert.IsNull(farm.Value.ContactInfo.AddressLine1);
            Assert.IsNull(farm.Value.ContactInfo.City);
            Assert.IsNull(farm.Value.ContactInfo.Country);
            Assert.IsNull(farm.Value.ContactInfo.PoBoxNumber);
            Assert.IsNull(farm.Value.ContactInfo.PostalCode);
            Assert.IsNull(farm.Value.ContactInfo.StateOrProvince);
            Assert.IsEmpty(farm.Value.ContactInfo.Contacts);
            Assert.IsNull(farm.Value.GrowerId);
        }
Esempio n. 18
0
        public void ProductWithRequiredFieldsOnlyTest()
        {
            // Setup
            var taskDocument = new TaskDataDocument();
            var path = Path.Combine(_directory, "test.xml");
            File.WriteAllText(path, TestData.TestData.Product4);

            // Act
            var result = taskDocument.LoadFromFile(path);

            // Verify
            Assert.IsTrue(result);
            Assert.IsNotNull(taskDocument.Products);
            Assert.AreEqual(1, taskDocument.Products.Count);

            var product = taskDocument.Products.First();
            Assert.AreEqual("PDT1", product.Key);
            Assert.AreEqual("Product 1", product.Value.Description);
        }
Esempio n. 19
0
        public void FieldUniqueIdIsSetCorrectly()
        {
            // Setup
            var taskDocument = new TaskDataDocument();
            var path = Path.Combine(_directory, "test.xml");
            File.WriteAllText(path, TestData.TestData.Field6);
            var pfdPath = Path.Combine(_directory, "PFD00006.xml");
            File.WriteAllText(pfdPath, TestData.TestData.PFD00006);

            // Act
            var result = taskDocument.LoadFromFile(path);

            // Verify
            Assert.IsTrue(result);
            Assert.IsNotNull(taskDocument.Fields);
            Assert.AreEqual(2, taskDocument.Fields.Count);

            const string expectedSource = "http://dictionary.isobus.net/isobus/";
            const CompoundIdentifierTypeEnum expectedType = CompoundIdentifierTypeEnum.String;

            var field = taskDocument.Fields["PFD1"];
            Assert.AreEqual("PFD1", field.Id.UniqueIds[0].Id);
            Assert.AreEqual(expectedType, field.Id.UniqueIds[0].CiTypeEnum);
            Assert.AreEqual(expectedSource, field.Id.UniqueIds[0].Source);

            field = taskDocument.Fields["PFD2"];
            Assert.AreEqual("PFD2", field.Id.UniqueIds[0].Id);
            Assert.AreEqual(expectedType, field.Id.UniqueIds[0].CiTypeEnum);
            Assert.AreEqual(expectedSource, field.Id.UniqueIds[0].Source);
        }
Esempio n. 20
0
        public void FarmWithMissingRequiredInfoTest()
        {
            var farms = new List<string>
            {
                TestData.TestData.Farm5,
                TestData.TestData.Farm6,
                TestData.TestData.Farm7,
            };

            for (int i = 0; i < farms.Count; i++)
            {
                // Setup
                var taskDocument = new TaskDataDocument();
                var path = Path.Combine(_directory, String.Format("farm{0}.xml", i));
                File.WriteAllText(path, farms[i]);

                // Act
                var result = taskDocument.LoadFromFile(path);

                // Verify
                Assert.IsTrue(result);
                Assert.IsNotNull(taskDocument.Farms);
                Assert.AreEqual(0, taskDocument.Farms.Count);
            }
        }
Esempio n. 21
0
        public void LoadCropAndVarietiesTest()
        {
            var unit = UnitFactory.Instance.GetUnitByDdi(1);
            // Setup
            var taskDocument = new  TaskDataDocument();
            var path = Path.Combine(_directory, "Crop1.xml");
            File.WriteAllText(path, TestData.TestData.Crop1);

            // Act
            var result = taskDocument.LoadFromFile(path);

            // Verify
            Assert.IsTrue(result);
            Assert.IsNotNull(taskDocument.Crops);
            Assert.AreEqual(1, taskDocument.Crops.Count);

            var crop = taskDocument.Crops.First();
            Assert.AreEqual("CTP1", crop.Key);
            Assert.AreEqual("Crop 1", crop.Value.Name);

            Assert.IsNotNull(taskDocument.CropVarieties);
            Assert.AreEqual(2, taskDocument.CropVarieties.Count);
            for (int i = 0; i < taskDocument.CropVarieties.Count; i++)
            {
                var variety = taskDocument.CropVarieties.ElementAt(i);
                Assert.AreEqual(crop.Value.Id.ReferenceId, variety.Value.CropId);
                Assert.AreEqual(string.Format(CultureInfo.InvariantCulture, "CVT{0}", i + 1), variety.Key);
                Assert.AreEqual(string.Format(CultureInfo.InvariantCulture, "Variety {0}", i + 1), variety.Value.Description);
                Assert.AreEqual(ProductTypeEnum.Variety, variety.Value.ProductType);
            }
        }
Esempio n. 22
0
        public void CustomerWithRequiredFieldsOnlyTest()
        {
            // Setup
            var taskDocument = new TaskDataDocument();
            var path = Path.Combine(_directory, "test.xml");
            File.WriteAllText(path, TestData.TestData.Customer4);

            // Act
            var result = taskDocument.LoadFromFile(path);

            // Verify
            Assert.IsTrue(result);
            Assert.IsNotNull(taskDocument.Customers);
            Assert.AreEqual(1, taskDocument.Customers.Count);
            var customer = taskDocument.Customers.First();
            Assert.AreEqual("CTR1", customer.Key);
            Assert.AreEqual("Last", customer.Value.Name);
            Assert.IsNotNull(customer.Value.ContactInfo);
            Assert.IsNull(customer.Value.ContactInfo.AddressLine1);
            Assert.IsNull(customer.Value.ContactInfo.City);
            Assert.IsNull(customer.Value.ContactInfo.Country);
            Assert.IsNull(customer.Value.ContactInfo.PoBoxNumber);
            Assert.IsNull(customer.Value.ContactInfo.PostalCode);
            Assert.IsNull(customer.Value.ContactInfo.StateOrProvince);
            Assert.IsNotNull(customer.Value.ContactInfo.Contacts);
            Assert.AreEqual(0, customer.Value.ContactInfo.Contacts.Count);
        }
Esempio n. 23
0
        public void FieldWithExteriorBoundary()
        {
            // Setup
            var taskDocument = new TaskDataDocument();
            var path = Path.Combine(_directory, "test.xml");
            File.WriteAllText(path, TestData.TestData.Field11);

            // Act
            taskDocument.LoadFromFile(path);

            // Verify
            var field = taskDocument.Fields["PFD1"];
            var fieldBoundary = taskDocument.FieldBoundaries[0];

            Assert.AreEqual(field.Id.ReferenceId, fieldBoundary.FieldId);
            Assert.AreEqual(5, fieldBoundary.SpatialData.Polygons[0].ExteriorRing.Points.Count);
        }
Esempio n. 24
0
        public void CropWithRequiredFieldsOnlyTest()
        {
            // Setup
            var taskDocument = new TaskDataDocument();
            var path = Path.Combine(_directory, "Crop2.xml");
            File.WriteAllText(path, TestData.TestData.Crop2);

            // Act
            var result = taskDocument.LoadFromFile(path);

            // Verify
            Assert.IsTrue(result);
            Assert.IsNotNull(taskDocument.Crops);
            Assert.AreEqual(1, taskDocument.Crops.Count);

            var crop = taskDocument.Crops.First();
            Assert.AreEqual("CTP1", crop.Key);
            Assert.AreEqual("Crop 1", crop.Value.Name);

            Assert.IsNotNull(taskDocument.CropVarieties);
            Assert.AreEqual(0, taskDocument.CropVarieties.Count);
        }
Esempio n. 25
0
        public void ProductWithProductGroupTest()
        {
            // Setup
            var taskDocument = new TaskDataDocument();
            var path = Path.Combine(_directory, "test.xml");
            File.WriteAllText(path, TestData.TestData.Product7);

            // Act
            var result = taskDocument.LoadFromFile(path);

            // Verify
            Assert.IsTrue(result);
            Assert.IsNotNull(taskDocument.Products);
            Assert.AreEqual(2, taskDocument.Products.Count);

            var product = taskDocument.Products["PDT1"];
            Assert.AreEqual("Product 1", product.Description);
            Assert.AreEqual(ProductTypeEnum.Generic, product.ProductType);

            product = taskDocument.Products["PDT2"];
            Assert.AreEqual("Product 2", product.Description);
            Assert.AreEqual(ProductTypeEnum.Variety, product.ProductType);
        }