public void FieldWithMissingRequiredInfoTest() { var fields = new List <string> { TestData.TestData.Field7, TestData.TestData.Field8, TestData.TestData.Field9, TestData.TestData.Field10, }; for (int i = 0; i < fields.Count; i++) { // Setup var taskDocument = new TaskDataDocument(); var path = Path.Combine(_directory, String.Format("field{0}.xml", i)); File.WriteAllText(path, fields[i]); // Act var result = taskDocument.LoadFromFile(path); // Verify Assert.IsTrue(result); Assert.IsNotNull(taskDocument.Fields); Assert.AreEqual(0, taskDocument.Fields.Count); } }
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 IdTypeEnum expectedType = IdTypeEnum.String; var field = taskDocument.Fields["PFD1"]; Assert.AreEqual("PFD1", field.Id.UniqueIds[0].Id); Assert.AreEqual(expectedType, field.Id.UniqueIds[0].IdType); 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].IdType); Assert.AreEqual(expectedSource, field.Id.UniqueIds[0].Source); }
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); }
private CropLoader(TaskDataDocument taskDocument) { _taskDocument = taskDocument; _rootNode = _taskDocument.RootNode; _baseFolder = _taskDocument.BaseFolder; _crops = new Dictionary <string, Crop>(); }
public void FieldWithMissingBoundaryTest() { // Setup var taskDocument = new TaskDataDocument(); var path = Path.Combine(_directory, "test.xml"); //File.WriteAllText(path, TestData.TestData.Field2); // 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.IsNull(farm.Value.ContactInfo.Contacts); Assert.IsNull(farm.Value.GrowerId); }
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); }
public void LoadFarmInfoTest() { // 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 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.AreEqual("Street", farm.Value.ContactInfo.AddressLine1); Assert.AreEqual("City", farm.Value.ContactInfo.City); Assert.AreEqual("Country", farm.Value.ContactInfo.Country); Assert.AreEqual("PO Box", farm.Value.ContactInfo.PoBoxNumber); Assert.AreEqual("PostalCode", farm.Value.ContactInfo.PostalCode); Assert.AreEqual("State", farm.Value.ContactInfo.StateOrProvince); Assert.IsEmpty(farm.Value.ContactInfo.Contacts); Assert.IsNotNull(farm.Value.GrowerId); Assert.AreEqual(taskDocument.Customers["CTR1"].Id.ReferenceId, farm.Value.GrowerId); }
public void ProductWithExternalProductGroupTest() { // Setup var taskDocument = new TaskDataDocument(); var path = Path.Combine(_directory, "test.xml"); File.WriteAllText(path, TestData.TestData.Product9); var pgp1Path = Path.Combine(_directory, "PGP00001.xml"); File.WriteAllText(pgp1Path, TestData.TestData.PGP00001); var pgp2Path = Path.Combine(_directory, "PGP00002.xml"); File.WriteAllText(pgp2Path, TestData.TestData.PGP00002); // 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); }
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); }
public void CustomerWithMissingPhonesTest() { // Setup var taskDocument = new TaskDataDocument(); var path = Path.Combine(_directory, "test.xml"); File.WriteAllText(path, TestData.TestData.Customer2); // 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(0, customer.Value.ContactInfo.Contacts.Count); }
private ProductLoader(TaskDataDocument taskDocument) { _taskDocument = taskDocument; _rootNode = _taskDocument.RootNode; _baseFolder = _taskDocument.BaseFolder; _products = new Dictionary <string, Product>(); }
private DeviceLoader(TaskDataDocument taskDocument) { _taskDocument = taskDocument; _rootNode = _taskDocument.RootNode; _baseFolder = _taskDocument.BaseFolder; _machines = new Dictionary <string, DeviceElement>(); }
private WorkerLoader(TaskDataDocument taskDocument) { _taskDocument = taskDocument; _rootNode = _taskDocument.RootNode; _baseFolder = _taskDocument.BaseFolder; _workers = new Dictionary <string, Person>(); }
private TaskLoader(TaskDataDocument taskDocument) { _taskDocument = taskDocument; _rootNode = _taskDocument.RootNode; _baseFolder = _taskDocument.BaseFolder; _tasks = new List <LoggedData>(); }
public void CustomerWithMissingRequiredInfoTest() { var customers = new List <string> { TestData.TestData.Customer6, TestData.TestData.Customer7, TestData.TestData.Customer8, }; for (int i = 0; i < customers.Count; i++) { var path = Path.Combine(_directory, String.Format("customer{0}.xml", i)); File.WriteAllText(path, customers[i]); // Setup var taskDocument = new TaskDataDocument(); // Act var result = taskDocument.LoadFromFile(path); // Verify Assert.IsTrue(result); Assert.IsNotNull(taskDocument.Customers); Assert.AreEqual(0, taskDocument.Customers.Count); } }
private LinkListLoader(TaskDataDocument taskDocument) { _taskDocument = taskDocument; _rootNode = _taskDocument.RootNode; _baseFolder = _taskDocument.BaseFolder; _linkedIds = new Dictionary <string, List <UniqueId> >(StringComparer.OrdinalIgnoreCase); }
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); } }
private FieldLoader(TaskDataDocument taskDocument) { _taskDocument = taskDocument; _rootNode = _taskDocument.RootNode; _baseFolder = _taskDocument.BaseFolder; _fields = new Dictionary <string, Field>(); }
private UnitLoader(TaskDataDocument taskDocument) { _taskDocument = taskDocument; _rootNode = _taskDocument.RootNode; _baseFolder = _taskDocument.BaseFolder; _units = new Dictionary <string, ValuePresentation>(); }
private CommentLoader(TaskDataDocument taskDocument) { _taskDocument = taskDocument; _rootNode = _taskDocument.RootNode; _baseFolder = _taskDocument.BaseFolder; _comments = new Dictionary <string, CodedComment>(); }
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); }
private CustomerLoader(TaskDataDocument taskDocument) { _taskDocument = taskDocument; _rootNode = _taskDocument.RootNode; _baseFolder = _taskDocument.BaseFolder; _growers = new Dictionary <string, Grower>(); }
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); }
private PrescriptionLoader(TaskDataDocument taskDocument) { _taskDocument = taskDocument; _rootNode = _taskDocument.RootNode; _baseFolder = _taskDocument.BaseFolder; _prescriptions = new List <RasterGridPrescription>(); _representationMapper = new RepresentationMapper(); }
public static GuidanceShift Load(XmlNodeList inputNode, TaskDataDocument taskDataDocument) { var loader = new GuidanceShiftLoader(taskDataDocument); var node = inputNode.Item(0); return(loader.Load(node)); }
private static List <Product> AddAllProducts(TaskDataDocument taskDocument) { var products = new List <Product>(); products.AddRange(taskDocument.CropVarieties.Values); products.AddRange(taskDocument.ProductMixes.Values); products.AddRange(taskDocument.Products.Values.OfType <FertilizerProduct>()); return(products); }
public void GivenTaskDocumentWithPrescriptionWhenLoadThenUniqueIdIsSet() { TaskDataDocument taskDocument = CreateTaskDocument(); var result = PrescriptionLoader.Load(taskDocument).First(); Assert.AreEqual(1, result.Id.UniqueIds.Count); Assert.AreEqual("TSK0", result.Id.UniqueIds.First().Id); Assert.AreEqual(IdTypeEnum.String, result.Id.UniqueIds.First().IdType); Assert.AreEqual("http://dictionary.isobus.net/isobus/", result.Id.UniqueIds.First().Source); }
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); }
public void ProductWithMissingRequiredFieldTest() { // Setup var taskDocument = new TaskDataDocument(); var path = Path.Combine(_directory, "test.xml"); File.WriteAllText(path, TestData.TestData.Product6); // Act var result = taskDocument.LoadFromFile(path); // Verify Assert.IsTrue(result); Assert.IsNotNull(taskDocument.Products); Assert.AreEqual(0, taskDocument.Products.Count); }
public void Setup() { _taskDataDocument = new TaskDataDocument(); _xmlDoc = new XmlDocument(); _gstNode = _xmlDoc.CreateElement("GST"); _a = _xmlDoc.CreateAttribute("A"); _a.Value = "bob"; _gstNode.Attributes.Append(_a); _b = _xmlDoc.CreateAttribute("B"); _b.Value = "rob"; _gstNode.Attributes.Append(_b); _xmlDoc.AppendChild(_gstNode); }