示例#1
0
        private static void AreEqual(LoggedData loggedData, TSK tsk, Catalog catalog, string cardPath)
        {
            var grower = catalog.Growers.SingleOrDefault(x => x.Id.ReferenceId == loggedData.GrowerId);
            var farm = catalog.Farms.SingleOrDefault(x => x.Id.ReferenceId == loggedData.FarmId);
            var field = catalog.Fields.SingleOrDefault(x => x.Id.ReferenceId == loggedData.FieldId);

            if(grower != null)
                Assert.AreEqual(grower.Id.FindIsoId(), tsk.C);
            if (farm != null)
                Assert.AreEqual(farm.Id.FindIsoId(), tsk.D);
            if (field != null)
                Assert.AreEqual(field.Id.FindIsoId(), tsk.E);

            if(loggedData.TimeScopes != null && loggedData.TimeScopes.Any())
            {
                var tims = tsk.Items.Where(x => x.GetType() == typeof(TIM)).Cast<TIM>().ToList();
                TimAssert.AreEqual(loggedData.TimeScopes, tims);
            }

            if(loggedData.OperationData != null && loggedData.OperationData.Any())
            {
                var tlgs = tsk.Items.Where(x => x.GetType() == typeof(TLG)).Cast<TLG>().ToList();
                TlgAssert.AreEqual(loggedData.OperationData.ToList(), tlgs, catalog, cardPath);
            }
        }
示例#2
0
        private void LoadGuidanceAllocations(XmlNode inputNode, LoggedData task)
        {
            var allocations = GuidanceAllocationLoader.Load(inputNode, _taskDocument);

            _taskDocument.GuidanceAllocations.AddRange(allocations);

            task.GuidanceAllocationIds = allocations.Select(x => x.Id.ReferenceId).ToList();
        }
示例#3
0
 private void LoadFarm(string farmId, LoggedData task)
 {
     var farm = _taskDocument.Farms.FindById(farmId);
     if (farm != null)
     {
         task.FarmId = farm.Id.ReferenceId;
         task.GrowerId = farm.GrowerId;
     }
 }
示例#4
0
 private void LoadField(string fieldId, LoggedData task)
 {
     var field = _taskDocument.Fields.FindById(fieldId);
     if (field != null)
     {
         task.FieldId = field.Id.ReferenceId;
         task.FarmId = field.FarmId;
     }
 }
示例#5
0
        private LoggedData LoadTask(XmlNode inputNode)
        {
            var task = new LoggedData();

            // Required fields. Do not proceed if they are missing
            var taskId = inputNode.GetXmlNodeValue("@A");
            if (taskId == null)
                return null;

            // Optional fields
            task.Description = inputNode.GetXmlNodeValue("@B");

            LoadField(inputNode.GetXmlNodeValue("@E"), task);
            LoadFarm(inputNode.GetXmlNodeValue("@D"), task);
            LoadCustomer(inputNode.GetXmlNodeValue("@C"), task);

            LoadGuidanceAllocations(inputNode, task);
            LoadCommentAllocations(inputNode, task);
            task.Id.UniqueIds.Add(new UniqueId
            {
                Id = taskId,
                Source = UniqueIdMapper.IsoSource,
                CiTypeEnum = CompoundIdentifierTypeEnum.String,
            });

            _taskDocument.LoadLinkedIds(taskId, task.Id);
            return task;
        }
示例#6
0
 private void LoadCommentAllocations(XmlNode inputNode, LoggedData task)
 {
     task.Notes = CommentAllocationLoader.Load(inputNode, _taskDocument);
 }
示例#7
0
 private void LoadCustomer(string customerId, LoggedData task)
 {
     var customer = _taskDocument.Customers.FindById(customerId);
     if (customer != null)
         task.GrowerId = customer.Id.ReferenceId;
 }
示例#8
0
 private static void AreEqual(XmlNode tskNode, string currentPath, LoggedData loggedData, Catalog catalog)
 {
     var tlgNodes = tskNode.SelectNodes("TLG");
     OperationDataAssert.AreEqual(tlgNodes, currentPath, loggedData.OperationData.ToList());
 }
示例#9
0
        public void GivenTskWhenMapThenOperationDataAreMapped()
        {
            const string taskName = "TSK5";

            var existingLoggedData = new LoggedData();
            existingLoggedData.Id.UniqueIds.Add(new UniqueId{ CiTypeEnum = CompoundIdentifierTypeEnum.String, Id = taskName, Source = UniqueIdMapper.IsoSource});
            _documents.LoggedData = new List<LoggedData> {existingLoggedData};

            var tlgs = new List<TLG> {new TLG()};
            _tsk.Items = tlgs.ToArray();
            _tsk.A = taskName;

            var operationDatas = new List<OperationData>();
            _operationDataMapper.Setup(x => x.Map(tlgs, null, _dataPath, It.IsAny<int>(), _linkIds)).Returns(operationDatas);

            var result = MapSingle();
            Assert.AreSame(operationDatas, result.OperationData);
        }
示例#10
0
        public void GivenTskWithNullItemWhenMapThenPrescriptionIdIsNullToOperationMapper()
        {
            var existingLoggedData = new LoggedData();
            existingLoggedData.Id.UniqueIds.Add(new UniqueId { CiTypeEnum = CompoundIdentifierTypeEnum.String, Id = "TSK0", Source = UniqueIdMapper.IsoSource });
            _documents.LoggedData = new List<LoggedData> { existingLoggedData };
            _tsk.A = "TSK0";

            MapSingle();

            _operationDataMapper.Verify(x => x.Map(It.IsAny<List<TLG>>(), null, _dataPath, existingLoggedData.Id.ReferenceId, _linkIds), Times.Once);
        }
示例#11
0
        public void GivenTskWithGrdWhenMapThenPrescriptionIdFromCatalogIsPassedToOperationMapper()
        {
            var prescription = new RasterGridPrescription();
            prescription.Id.UniqueIds = new List<UniqueId>
            {
                new UniqueId
                {
                    CiTypeEnum = CompoundIdentifierTypeEnum.String,
                    Id = "FIX1",
                    Source = "http://dictionary.isobus.net/isobus/"
                }
            };

            _catalog.Prescriptions = new List<Prescription> { prescription };

            var existingLoggedData = new LoggedData();
            existingLoggedData.Id.UniqueIds.Add(new UniqueId { CiTypeEnum = CompoundIdentifierTypeEnum.String, Id = "FIX1", Source = UniqueIdMapper.IsoSource });
            _documents.LoggedData = new List<LoggedData> { existingLoggedData };

            var grd = new GRD();
            _tsk.Items = new List<IWriter> {grd}.ToArray();
            _tsk.A = "FIX1";

            MapSingle();

            _operationDataMapper.Verify(x => x.Map(It.IsAny<List<TLG>>(), prescription.Id.ReferenceId, _dataPath,existingLoggedData.Id.ReferenceId, _linkIds ), Times.Once);
        }
示例#12
0
        public void Setup()
        {
            _loggedData = new LoggedData();
            _loggedDatas = new List<LoggedData>{ _loggedData };
            _catalog = new Catalog();
            _datacardPath = "";
            _taskDocumentWriter = new TaskDocumentWriter();

            _timeMapperMock = new Mock<ITimeMapper>();
            _tlgMapperMock = new Mock<ITlgMapper>();

            _taskMapper = new TaskMapper(_timeMapperMock.Object, _tlgMapperMock.Object);
        }