Ejemplo n.º 1
0
        public void GivenPathAndIdWithTypeStringWhenWriteThenLstAddedToLGP2()
        {
            var uniqueId = new UniqueId
            {
                Id     = "bob",
                IdType = IdTypeEnum.String,
                Source = "urn:epc:id:sgln:0000000.00000.1",
            };
            var id = new CompoundIdentifier(0)
            {
                UniqueIds = new List <UniqueId> {
                    uniqueId
                }
            };

            _ids.Add("TSK5", id);

            var linkListFilename = Path.Combine(_taskdataPath, "LINKLIST.XML");

            LinkListWriter.Write(_taskdataPath, _ids);

            var linkListDocument = new XmlDocument();

            linkListDocument.Load(linkListFilename);
            var lsts = linkListDocument.DocumentElement.SelectNodes("LGP")[1].ChildNodes;

            Assert.AreEqual("TSK5", lsts[0].Attributes["A"].Value);
            Assert.AreEqual(uniqueId.Id, lsts[0].Attributes["B"].Value);
            Assert.AreEqual(uniqueId.Source, lsts[0].Attributes["C"].Value);
        }
Ejemplo n.º 2
0
        public void GivenPathAndIdsWhenWriteThenLgp2Added()
        {
            var uniqueId = new UniqueId
            {
                Id     = Guid.NewGuid().ToString(),
                IdType = IdTypeEnum.UUID,
                Source = "urn:epc:id:sgln:0000000.00000.1",
            };
            var id = new CompoundIdentifier(0)
            {
                UniqueIds = new List <UniqueId> {
                    uniqueId
                }
            };

            _ids.Add("TSK5", id);

            var linkListFilename = Path.Combine(_taskdataPath, "LINKLIST.XML");

            LinkListWriter.Write(_taskdataPath, _ids);

            var linkListDocument = new XmlDocument();

            linkListDocument.Load(linkListFilename);

            var lgps = linkListDocument.DocumentElement.SelectNodes("LGP");

            Assert.AreEqual("LGP2", lgps[1].Attributes["A"].Value);
            Assert.AreEqual("2", lgps[1].Attributes["B"].Value);
        }
Ejemplo n.º 3
0
        public void GivenPathAndIdsWhenWriteThenFileIsCreated()
        {
            var linkListFilename = Path.Combine(_taskdataPath, "LINKLIST.XML");

            LinkListWriter.Write(_taskdataPath, _ids);

            Assert.IsTrue(File.Exists(linkListFilename));
        }
Ejemplo n.º 4
0
        public void GivenPathAndIdsWhenWriteThenManagementSoftwareVersionAdded()
        {
            var linkListFilename = Path.Combine(_taskdataPath, "LINKLIST.XML");

            LinkListWriter.Write(_taskdataPath, _ids);

            var linkListDocument = new XmlDocument();

            linkListDocument.Load(linkListFilename);
            var iso11783LinkList = linkListDocument.DocumentElement;

            Assert.IsNotNull(iso11783LinkList);
            Assert.AreEqual("1.0", iso11783LinkList.Attributes["ManagementSoftwareVersion"].Value);
        }
Ejemplo n.º 5
0
        public void GivenPathAndIdsWhenWriteThenTaskControllerManufacturerAdded()
        {
            var linkListFilename = Path.Combine(_taskdataPath, "LINKLIST.XML");

            LinkListWriter.Write(_taskdataPath, _ids);

            var linkListDocument = new XmlDocument();

            linkListDocument.Load(linkListFilename);
            var iso11783LinkList = linkListDocument.DocumentElement;

            Assert.IsNotNull(iso11783LinkList);
            Assert.AreEqual("", iso11783LinkList.Attributes["TaskControllerManufacturer"].Value);
        }
Ejemplo n.º 6
0
        public void GivenPathAndIdsWhenWriteThenDataTransferOriginAdded()
        {
            var linkListFilename = Path.Combine(_taskdataPath, "LINKLIST.XML");

            LinkListWriter.Write(_taskdataPath, _ids);

            var linkListDocument = new XmlDocument();

            linkListDocument.Load(linkListFilename);
            var iso11783LinkList = linkListDocument.DocumentElement;

            Assert.IsNotNull(iso11783LinkList);
            Assert.AreEqual(((int)ISO11783_TaskDataDataTransferOrigin.Item1).ToString(CultureInfo.InvariantCulture), iso11783LinkList.Attributes["DataTransferOrigin"].Value);
        }
Ejemplo n.º 7
0
        public void Export(ApplicationDataModel.ADM.ApplicationDataModel dataModel, string exportPath, Properties properties = null)
        {
            using (var taskWriter = new TaskDocumentWriter())
            {
                var taskDataPath     = Path.Combine(exportPath, "TASKDATA");
                var iso11783TaskData = _exporter.Export(dataModel, taskDataPath, taskWriter);

                var filePath = Path.Combine(taskDataPath, FileName);
                if (iso11783TaskData != null)
                {
                    var xml = Encoding.UTF8.GetString(taskWriter.XmlStream.ToArray());
                    File.WriteAllText(filePath, xml);
                    LinkListWriter.Write(taskDataPath, taskWriter.Ids);
                }
            }
        }
Ejemplo n.º 8
0
        public void GivenPathAndIdWithMultipleIdsWhenWriteThenLstsAdded()
        {
            var uniqueId1 = new UniqueId
            {
                Id     = Guid.NewGuid().ToString(),
                Source = "urn:epc:id:sgln:0000000.00000.1",
            };
            var id1 = new CompoundIdentifier(0)
            {
                UniqueIds = new List <UniqueId> {
                    uniqueId1
                }
            };

            _ids.Add("TSK5", id1);

            var uniqueId2 = new UniqueId
            {
                Id     = Guid.NewGuid().ToString(),
                Source = "urn:epc:id:sgln:0000000.00000.1",
            };
            var id2 = new CompoundIdentifier(0)
            {
                UniqueIds = new List <UniqueId> {
                    uniqueId2
                }
            };

            _ids.Add("TSK6", id2);

            var linkListFilename = Path.Combine(_taskdataPath, "LINKLIST.XML");

            LinkListWriter.Write(Path.GetDirectoryName(linkListFilename), _ids);

            var linkListDocument = new XmlDocument();

            linkListDocument.Load(linkListFilename);
            var lsts = linkListDocument.DocumentElement.ChildNodes[0].ChildNodes;

            Assert.AreEqual("TSK5", lsts[0].Attributes["A"].Value);
            Assert.AreEqual(uniqueId1.Id, lsts[0].Attributes["B"].Value);
            Assert.AreEqual(uniqueId1.Source, lsts[0].Attributes["C"].Value);

            Assert.AreEqual("TSK6", lsts[1].Attributes["A"].Value);
            Assert.AreEqual(uniqueId2.Id, lsts[1].Attributes["B"].Value);
            Assert.AreEqual(uniqueId2.Source, lsts[1].Attributes["C"].Value);
        }
Ejemplo n.º 9
0
        public void GivenPathAndIdWithTypeUuidAndStringWhenWriteThenLstAddedToCorrectGroup()
        {
            var uniqueId1 = new UniqueId
            {
                Id     = Guid.NewGuid().ToString(),
                IdType = IdTypeEnum.UUID,
                Source = "urn:epc:id:sgln:0000000.00000.1",
            };
            var uniqueId2 = new UniqueId
            {
                Id     = "456",
                IdType = IdTypeEnum.LongInt,
                Source = "urn:epc:id:sgln:0000000.00000.1",
            };
            var id = new CompoundIdentifier(0)
            {
                UniqueIds = new List <UniqueId> {
                    uniqueId1, uniqueId2
                }
            };

            _ids.Add("TSK5", id);

            var linkListFilename = Path.Combine(_taskdataPath, "LINKLIST.XML");

            LinkListWriter.Write(_taskdataPath, _ids);

            var linkListDocument = new XmlDocument();

            linkListDocument.Load(linkListFilename);
            var group1Links = linkListDocument.DocumentElement.SelectNodes("LGP")[0].ChildNodes;
            var group2Links = linkListDocument.DocumentElement.SelectNodes("LGP")[1].ChildNodes;

            Assert.AreEqual("TSK5", group1Links[0].Attributes["A"].Value);
            Assert.AreEqual(uniqueId1.Id, group1Links[0].Attributes["B"].Value);
            Assert.AreEqual(uniqueId1.Source, group1Links[0].Attributes["C"].Value);
            Assert.AreEqual("TSK5", group2Links[0].Attributes["A"].Value);
            Assert.AreEqual(uniqueId2.Id, group2Links[0].Attributes["B"].Value);
            Assert.AreEqual(uniqueId2.Source, group2Links[0].Attributes["C"].Value);
        }
Ejemplo n.º 10
0
        public void GivenPathAndIdsWithMultipleUniqueIdsAndMultipleSourcesWhenWriteThenLstAdded()
        {
            var uniqueId1 = new UniqueId
            {
                Id     = Guid.NewGuid().ToString(),
                Source = "urn:epc:id:sgln:0000000.00000.1",
            };
            var uniqueId2 = new UniqueId
            {
                Id     = Guid.NewGuid().ToString(),
                Source = "urn:epc:id:sgln:0000000.00000.2",
            };
            var id = new CompoundIdentifier(0)
            {
                UniqueIds = new List <UniqueId> {
                    uniqueId1, uniqueId2
                }
            };

            _ids.Add("TSK5", id);

            var linkListFilename = Path.Combine(_taskdataPath, "LINKLIST.XML");

            LinkListWriter.Write(_taskdataPath, _ids);

            var linkListDocument = new XmlDocument();

            linkListDocument.Load(linkListFilename);
            var linkGroup1Lists = linkListDocument.DocumentElement.SelectNodes("LGP")[0].ChildNodes;
            var linkGroup3Lists = linkListDocument.DocumentElement.SelectNodes("LGP")[2].ChildNodes;

            Assert.AreEqual("TSK5", linkGroup1Lists[0].Attributes["A"].Value);
            Assert.AreEqual(uniqueId1.Id, linkGroup1Lists[0].Attributes["B"].Value);
            Assert.AreEqual(uniqueId1.Source, linkGroup1Lists[0].Attributes["C"].Value);
            Assert.AreEqual("TSK5", linkGroup3Lists[0].Attributes["A"].Value);
            Assert.AreEqual(uniqueId2.Id, linkGroup3Lists[0].Attributes["B"].Value);
            Assert.AreEqual(uniqueId2.Source, linkGroup3Lists[0].Attributes["C"].Value);
        }