Exemple #1
0
            public ZipArchiveProblems Validate(ZipArchiveEntry entry, IDbaseRecordEnumerator <FakeDbaseRecord> records)
            {
                var collected = new List <FakeDbaseRecord>();

                while (records.MoveNext())
                {
                    collected.Add(records.Current);
                }
                Collected = collected.ToArray();

                return(ZipArchiveProblems.None);
            }
Exemple #2
0
            public TranslatedChanges Translate(ZipArchiveEntry entry, IDbaseRecordEnumerator <FakeDbaseRecord> records, TranslatedChanges changes)
            {
                var collected = new List <FakeDbaseRecord>();

                while (records.MoveNext())
                {
                    collected.Add(records.Current);
                }
                Collected = collected.ToArray();

                return(changes);
            }
        public TranslatedChanges Translate(ZipArchiveEntry entry, IDbaseRecordEnumerator <RoadSegmentChangeDbaseRecord> records, TranslatedChanges changes)
        {
            if (entry == null)
            {
                throw new ArgumentNullException(nameof(entry));
            }
            if (records == null)
            {
                throw new ArgumentNullException(nameof(records));
            }
            if (changes == null)
            {
                throw new ArgumentNullException(nameof(changes));
            }

            while (records.MoveNext())
            {
                var record = records.Current;
                if (record != null)
                {
                    switch (record.RECORDTYPE.Value)
                    {
                    case RecordType.AddedIdentifier:
                        changes = changes.Append(
                            new AddRoadSegment(
                                records.CurrentRecordNumber,
                                new RoadSegmentId(record.WS_OIDN.Value),
                                new RoadNodeId(record.B_WK_OIDN.Value),
                                new RoadNodeId(record.E_WK_OIDN.Value),
                                new OrganizationId(record.BEHEERDER.Value),
                                RoadSegmentGeometryDrawMethod.ByIdentifier[record.METHODE.Value],
                                RoadSegmentMorphology.ByIdentifier[record.MORFOLOGIE.Value],
                                RoadSegmentStatus.ByIdentifier[record.STATUS.Value],
                                RoadSegmentCategory.ByIdentifier[record.WEGCAT.Value],
                                RoadSegmentAccessRestriction.ByIdentifier[record.TGBEP.Value],
                                record.LSTRNMID.Value.HasValue ? new CrabStreetnameId(record.LSTRNMID.Value.Value) : new CrabStreetnameId?(),
                                record.RSTRNMID.Value.HasValue ? new CrabStreetnameId(record.RSTRNMID.Value.Value) : new CrabStreetnameId?()
                                )
                            );
                        break;
                    }
                }
            }

            return(changes);
        }
Exemple #4
0
        public TranslatedChanges Translate(ZipArchiveEntry entry, IDbaseRecordEnumerator <RoadSegmentLaneChangeDbaseRecord> records, TranslatedChanges changes)
        {
            if (entry == null)
            {
                throw new ArgumentNullException(nameof(entry));
            }
            if (records == null)
            {
                throw new ArgumentNullException(nameof(records));
            }
            if (changes == null)
            {
                throw new ArgumentNullException(nameof(changes));
            }

            while (records.MoveNext())
            {
                var record = records.Current;
                if (record != null)
                {
                    switch (record.RECORDTYPE.Value)
                    {
                    case RecordType.EqualIdentifier:
                    case RecordType.AddedIdentifier:
                    case RecordType.ModifiedIdentifier:
                        var segmentId = new RoadSegmentId(record.WS_OIDN.Value);
                        if (changes.TryFindAddRoadSegment(segmentId, out var change))
                        {
                            var lane = new RoadSegmentLaneAttribute(
                                new AttributeId(record.RS_OIDN.Value),
                                new RoadSegmentLaneCount(record.AANTAL.Value),
                                RoadSegmentLaneDirection.ByIdentifier[record.RICHTING.Value],
                                RoadSegmentPosition.FromDouble(record.VANPOSITIE.Value),
                                RoadSegmentPosition.FromDouble(record.TOTPOSITIE.Value)
                                );
                            changes = changes.Replace(change, change.WithLane(lane));
                        }
                        break;
                    }
                }
            }

            return(changes);
        }
Exemple #5
0
        public TranslatedChanges Translate(ZipArchiveEntry entry, IDbaseRecordEnumerator <RoadSegmentWidthChangeDbaseRecord> records, TranslatedChanges changes)
        {
            if (entry == null)
            {
                throw new ArgumentNullException(nameof(entry));
            }
            if (records == null)
            {
                throw new ArgumentNullException(nameof(records));
            }
            if (changes == null)
            {
                throw new ArgumentNullException(nameof(changes));
            }

            while (records.MoveNext())
            {
                var record = records.Current;
                if (record != null)
                {
                    switch (record.RECORDTYPE.Value)
                    {
                    case RecordType.EqualIdentifier:
                    case RecordType.AddedIdentifier:
                    case RecordType.ModifiedIdentifier:
                        var segmentId = new RoadSegmentId(record.WS_OIDN.Value);
                        if (changes.TryFindAddRoadSegment(segmentId, out var before))
                        {
                            var width = new RoadSegmentWidthAttribute(
                                new AttributeId(record.WB_OIDN.Value),
                                new RoadSegmentWidth(record.BREEDTE.Value),
                                RoadSegmentPosition.FromDouble(record.VANPOSITIE.Value),
                                RoadSegmentPosition.FromDouble(record.TOTPOSITIE.Value)
                                );
                            changes = changes.Replace(before, before.WithWidth(width));
                        }
                        break;
                    }
                }
            }

            return(changes);
        }
        public TranslatedChanges Translate(ZipArchiveEntry entry, IDbaseRecordEnumerator <RoadNodeChangeDbaseRecord> records, TranslatedChanges changes)
        {
            if (entry == null)
            {
                throw new ArgumentNullException(nameof(entry));
            }
            if (records == null)
            {
                throw new ArgumentNullException(nameof(records));
            }
            if (changes == null)
            {
                throw new ArgumentNullException(nameof(changes));
            }

            var recordNumber = RecordNumber.Initial;

            while (records.MoveNext())
            {
                var record = records.Current;
                if (record != null)
                {
                    switch (record.RECORDTYPE.Value)
                    {
                    case RecordType.AddedIdentifier:
                        changes = changes.Append(
                            new AddRoadNode(
                                recordNumber,
                                new RoadNodeId(record.WEGKNOOPID.Value),
                                RoadNodeType.ByIdentifier[record.TYPE.Value]
                                )
                            );
                        break;
                    }
                }
                recordNumber = recordNumber.Next();
            }

            return(changes);
        }
Exemple #7
0
        public TranslatedChanges Translate(ZipArchiveEntry entry, IDbaseRecordEnumerator <NumberedRoadChangeDbaseRecord> records, TranslatedChanges changes)
        {
            if (entry == null)
            {
                throw new ArgumentNullException(nameof(entry));
            }
            if (records == null)
            {
                throw new ArgumentNullException(nameof(records));
            }
            if (changes == null)
            {
                throw new ArgumentNullException(nameof(changes));
            }

            while (records.MoveNext())
            {
                var record = records.Current;
                if (record != null)
                {
                    switch (record.RECORDTYPE.Value)
                    {
                    case RecordType.AddedIdentifier:
                        changes = changes.Append(
                            new AddRoadSegmentToNumberedRoad(
                                new AttributeId(record.GW_OIDN.Value),
                                new RoadSegmentId(record.WS_OIDN.Value),
                                NumberedRoadNumber.Parse(record.IDENT8.Value),
                                RoadSegmentNumberedRoadDirection.ByIdentifier[record.RICHTING.Value],
                                new RoadSegmentNumberedRoadOrdinal(record.VOLGNUMMER.Value)
                                )
                            );
                        break;
                    }
                }
            }

            return(changes);
        }
        public TranslatedChanges Translate(ZipArchiveEntry entry, IDbaseRecordEnumerator <GradeSeparatedJunctionChangeDbaseRecord> records, TranslatedChanges changes)
        {
            if (entry == null)
            {
                throw new ArgumentNullException(nameof(entry));
            }
            if (records == null)
            {
                throw new ArgumentNullException(nameof(records));
            }
            if (changes == null)
            {
                throw new ArgumentNullException(nameof(changes));
            }

            while (records.MoveNext())
            {
                var record = records.Current;
                if (record != null)
                {
                    switch (record.RECORDTYPE.Value)
                    {
                    case RecordType.AddedIdentifier:
                        changes = changes.Append(
                            new AddGradeSeparatedJunction(
                                new GradeSeparatedJunctionId(record.OK_OIDN.Value),
                                GradeSeparatedJunctionType.ByIdentifier[record.TYPE.Value],
                                new RoadSegmentId(record.BO_WS_OIDN.Value),
                                new RoadSegmentId(record.ON_WS_OIDN.Value)
                                )
                            );
                        break;
                    }
                }
            }

            return(changes);
        }
        public TranslatedChanges Translate(ZipArchiveEntry entry, IDbaseRecordEnumerator <EuropeanRoadChangeDbaseRecord> records, TranslatedChanges changes)
        {
            if (entry == null)
            {
                throw new ArgumentNullException(nameof(entry));
            }
            if (records == null)
            {
                throw new ArgumentNullException(nameof(records));
            }
            if (changes == null)
            {
                throw new ArgumentNullException(nameof(changes));
            }

            while (records.MoveNext())
            {
                var record = records.Current;
                if (record != null)
                {
                    switch (record.RECORDTYPE.Value)
                    {
                    case RecordType.AddedIdentifier:
                        changes = changes.Append(
                            new AddRoadSegmentToEuropeanRoad(
                                new AttributeId(record.EU_OIDN.Value),
                                new RoadSegmentId(record.WS_OIDN.Value),
                                EuropeanRoadNumber.Parse(record.EUNUMMER.Value)
                                )
                            );
                        break;
                    }
                }
            }

            return(changes);
        }
        public TranslatedChanges Translate(ZipArchiveEntry entry, IDbaseRecordEnumerator <TransactionZoneDbaseRecord> records, TranslatedChanges changes)
        {
            if (entry == null)
            {
                throw new ArgumentNullException(nameof(entry));
            }
            if (records == null)
            {
                throw new ArgumentNullException(nameof(records));
            }
            if (changes == null)
            {
                throw new ArgumentNullException(nameof(changes));
            }

            if (records.MoveNext() && records.Current != null)
            {
                return(changes
                       .WithReason(new Reason(records.Current.BESCHRIJV.Value))
                       .WithOperatorName(new OperatorName(records.Current.OPERATOR.Value))
                       .WithOrganization(new OrganizationId(records.Current.ORG.Value)));
            }
            return(changes);
        }
Exemple #11
0
 public void MoveNextReturnsExpectedResult()
 {
     Assert.False(_sut.MoveNext());
 }
Exemple #12
0
        public ZipArchiveProblems Validate(ZipArchiveEntry entry, IDbaseRecordEnumerator <RoadSegmentChangeDbaseRecord> records)
        {
            if (entry == null)
            {
                throw new ArgumentNullException(nameof(entry));
            }
            if (records == null)
            {
                throw new ArgumentNullException(nameof(records));
            }

            var problems = ZipArchiveProblems.None;

            try
            {
                var identifiers = new Dictionary <RoadSegmentId, RecordNumber>();
                var moved       = records.MoveNext();
                if (moved)
                {
                    while (moved)
                    {
                        var recordContext = entry.AtDbaseRecord(records.CurrentRecordNumber);
                        var record        = records.Current;
                        if (record != null)
                        {
                            if (!record.RECORDTYPE.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.RECORDTYPE.Field);
                            }
                            else
                            {
                                if (!RecordType.ByIdentifier.ContainsKey(record.RECORDTYPE.Value))
                                {
                                    problems += recordContext.RecordTypeMismatch(record.RECORDTYPE.Value);
                                }
                            }
                            if (record.WS_OIDN.HasValue)
                            {
                                if (record.WS_OIDN.Value == 0)
                                {
                                    problems += recordContext.IdentifierZero();
                                }
                                else
                                {
                                    var identifier = new RoadSegmentId(record.WS_OIDN.Value);
                                    if (identifiers.TryGetValue(identifier, out var takenByRecordNumber))
                                    {
                                        problems += recordContext.IdentifierNotUnique(
                                            identifier,
                                            takenByRecordNumber
                                            );
                                    }
                                    else
                                    {
                                        identifiers.Add(identifier, records.CurrentRecordNumber);
                                    }
                                }
                            }
                            else
                            {
                                problems += recordContext.RequiredFieldIsNull(record.WS_OIDN.Field);
                            }

                            if (!record.TGBEP.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.TGBEP.Field);
                            }
                            else if (!RoadSegmentAccessRestriction.ByIdentifier.ContainsKey(record.TGBEP.Value))
                            {
                                problems += recordContext.RoadSegmentAccessRestrictionMismatch(record.TGBEP.Value);
                            }

                            if (!record.STATUS.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.STATUS.Field);
                            }
                            else if (!RoadSegmentStatus.ByIdentifier.ContainsKey(record.STATUS.Value))
                            {
                                problems += recordContext.RoadSegmentStatusMismatch(record.STATUS.Value);
                            }

                            if (!record.WEGCAT.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.WEGCAT.Field);
                            }
                            else if (!RoadSegmentCategory.ByIdentifier.ContainsKey(record.WEGCAT.Value))
                            {
                                problems += recordContext.RoadSegmentCategoryMismatch(record.WEGCAT.Value);
                            }

                            if (!record.METHODE.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.METHODE.Field);
                            }
                            else if (!RoadSegmentGeometryDrawMethod.ByIdentifier.ContainsKey(record.METHODE.Value))
                            {
                                problems += recordContext.RoadSegmentGeometryDrawMethodMismatch(record.METHODE.Value);
                            }

                            if (!record.MORFOLOGIE.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.MORFOLOGIE.Field);
                            }
                            else if (!RoadSegmentMorphology.ByIdentifier.ContainsKey(record.MORFOLOGIE.Value))
                            {
                                problems += recordContext.RoadSegmentMorphologyMismatch(record.MORFOLOGIE.Value);
                            }

                            if (!record.B_WK_OIDN.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.B_WK_OIDN.Field);
                            }
                            else if (!RoadNodeId.Accepts(record.B_WK_OIDN.Value))
                            {
                                problems += recordContext.BeginRoadNodeIdOutOfRange(record.B_WK_OIDN.Value);
                            }

                            if (!record.E_WK_OIDN.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.E_WK_OIDN.Field);
                            }
                            else if (!RoadNodeId.Accepts(record.E_WK_OIDN.Value))
                            {
                                problems += recordContext.EndRoadNodeIdOutOfRange(record.E_WK_OIDN.Value);
                            }

                            if (!record.BEHEERDER.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.BEHEERDER.Field);
                            }
                        }
                        moved = records.MoveNext();
                    }
                }
                else
                {
                    problems += entry.HasNoDbaseRecords(false);
                }
            }
            catch (Exception exception)
            {
                problems += entry.AtDbaseRecord(records.CurrentRecordNumber).HasDbaseRecordFormatError(exception);
            }

            return(problems);
        }
        public ZipArchiveProblems Validate(ZipArchiveEntry entry, IDbaseRecordEnumerator <NationalRoadChangeDbaseRecord> records)
        {
            if (entry == null)
            {
                throw new ArgumentNullException(nameof(entry));
            }
            if (records == null)
            {
                throw new ArgumentNullException(nameof(records));
            }

            var problems = ZipArchiveProblems.None;

            try
            {
                var identifiers = new Dictionary <AttributeId, RecordNumber>();
                var moved       = records.MoveNext();
                if (moved)
                {
                    while (moved)
                    {
                        var recordContext = entry.AtDbaseRecord(records.CurrentRecordNumber);
                        var record        = records.Current;
                        if (record != null)
                        {
                            if (!record.RECORDTYPE.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.RECORDTYPE.Field);
                            }
                            else
                            {
                                if (!RecordType.ByIdentifier.ContainsKey(record.RECORDTYPE.Value))
                                {
                                    problems += recordContext.RecordTypeMismatch(record.RECORDTYPE.Value);
                                }
                            }
                            if (record.NW_OIDN.HasValue)
                            {
                                if (record.NW_OIDN.Value == 0)
                                {
                                    problems += recordContext.IdentifierZero();
                                }
                                else
                                {
                                    var identifier = new AttributeId(record.NW_OIDN.Value);
                                    if (identifiers.TryGetValue(identifier, out var takenByRecordNumber))
                                    {
                                        problems += recordContext.IdentifierNotUnique(
                                            identifier,
                                            takenByRecordNumber
                                            );
                                    }
                                    else
                                    {
                                        identifiers.Add(identifier, records.CurrentRecordNumber);
                                    }
                                }
                            }
                            else
                            {
                                problems += recordContext.RequiredFieldIsNull(record.NW_OIDN.Field);
                            }

                            if (record.IDENT2.Value == null)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.IDENT2.Field);
                            }
                            else if (!NationalRoadNumber.CanParse(record.IDENT2.Value))
                            {
                                problems += recordContext.NotNationalRoadNumber(record.IDENT2.Value);
                            }

                            if (!record.WS_OIDN.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.WS_OIDN.Field);
                            }
                            else if (!RoadSegmentId.Accepts(record.WS_OIDN.Value))
                            {
                                problems += recordContext.RoadSegmentIdOutOfRange(record.WS_OIDN.Value);
                            }

                            moved = records.MoveNext();
                        }
                    }
                }
                else
                {
                    problems += entry.HasNoDbaseRecords(true);
                }
            }
            catch (Exception exception)
            {
                problems += entry.AtDbaseRecord(records.CurrentRecordNumber).HasDbaseRecordFormatError(exception);
            }

            return(problems);
        }
Exemple #14
0
 public void MoveNextReturnsExpectedResult()
 {
     Assert.Throws <EndOfStreamException>(() => _sut.MoveNext());
 }
        public ZipArchiveProblems Validate(ZipArchiveEntry entry, IDbaseRecordEnumerator <RoadSegmentLaneChangeDbaseRecord> records)
        {
            if (entry == null)
            {
                throw new ArgumentNullException(nameof(entry));
            }
            if (records == null)
            {
                throw new ArgumentNullException(nameof(records));
            }

            var problems = ZipArchiveProblems.None;

            try
            {
                var identifiers = new Dictionary <AttributeId, RecordNumber>();
                var moved       = records.MoveNext();
                if (moved)
                {
                    while (moved)
                    {
                        var recordContext = entry.AtDbaseRecord(records.CurrentRecordNumber);
                        var record        = records.Current;
                        if (record != null)
                        {
                            if (!record.RECORDTYPE.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.RECORDTYPE.Field);
                            }
                            else
                            {
                                if (!RecordType.ByIdentifier.ContainsKey(record.RECORDTYPE.Value))
                                {
                                    problems += recordContext.RecordTypeMismatch(record.RECORDTYPE.Value);
                                }
                            }
                            if (record.RS_OIDN.HasValue)
                            {
                                if (record.RS_OIDN.Value == 0)
                                {
                                    problems += recordContext.IdentifierZero();
                                }
                                else
                                {
                                    var identifier = new AttributeId(record.RS_OIDN.Value);
                                    if (identifiers.TryGetValue(identifier, out var takenByRecordNumber))
                                    {
                                        problems += recordContext.IdentifierNotUnique(
                                            identifier,
                                            takenByRecordNumber
                                            );
                                    }
                                    else
                                    {
                                        identifiers.Add(identifier, records.CurrentRecordNumber);
                                    }
                                }
                            }
                            else
                            {
                                problems += recordContext.RequiredFieldIsNull(record.RS_OIDN.Field);
                            }

                            if (!record.AANTAL.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.AANTAL.Field);
                            }
                            else if (!RoadSegmentLaneCount.Accepts(record.AANTAL.Value))
                            {
                                problems += recordContext.LaneCountOutOfRange(record.AANTAL.Value);
                            }

                            if (!record.RICHTING.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.RICHTING.Field);
                            }
                            else if (!RoadSegmentLaneDirection.ByIdentifier.ContainsKey(record.RICHTING.Value))
                            {
                                problems += recordContext.LaneDirectionMismatch(record.RICHTING.Value);
                            }

                            if (!record.VANPOSITIE.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.VANPOSITIE.Field);
                            }
                            else if (!RoadSegmentPosition.Accepts(record.VANPOSITIE.Value))
                            {
                                problems += recordContext.FromPositionOutOfRange(record.VANPOSITIE.Value);
                            }

                            if (!record.TOTPOSITIE.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.TOTPOSITIE.Field);
                            }
                            else if (!RoadSegmentPosition.Accepts(record.TOTPOSITIE.Value))
                            {
                                problems += recordContext.ToPositionOutOfRange(record.TOTPOSITIE.Value);
                            }

                            if (!record.WS_OIDN.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.WS_OIDN.Field);
                            }
                            else if (!RoadSegmentId.Accepts(record.WS_OIDN.Value))
                            {
                                problems += recordContext.RoadSegmentIdOutOfRange(record.WS_OIDN.Value);
                            }
                        }
                        moved = records.MoveNext();
                    }
                }
                else
                {
                    problems += entry.HasNoDbaseRecords(false);
                }
            }
            catch (Exception exception)
            {
                problems += entry.AtDbaseRecord(records.CurrentRecordNumber).HasDbaseRecordFormatError(exception);
            }

            return(problems);
        }
        public ZipArchiveProblems Validate(ZipArchiveEntry entry, IDbaseRecordEnumerator <TransactionZoneDbaseRecord> records)
        {
            if (entry == null)
            {
                throw new ArgumentNullException(nameof(entry));
            }
            if (records == null)
            {
                throw new ArgumentNullException(nameof(records));
            }

            var problems = ZipArchiveProblems.None;

            try
            {
                var count = 0;
                var moved = records.MoveNext();
                if (moved)
                {
                    while (moved)
                    {
                        var recordContext = entry.AtDbaseRecord(records.CurrentRecordNumber);
                        var record        = records.Current;
                        if (record != null)
                        {
                            if (!record.BESCHRIJV.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.BESCHRIJV.Field);
                            }
                            if (!record.OPERATOR.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.OPERATOR.Field);
                            }
                            if (!record.ORG.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.ORG.Field);
                            }
                            else if (!OrganizationId.AcceptsValue(record.ORG.Value))
                            {
                                problems += recordContext.OrganizationIdOutOfRange(record.ORG.Value);
                            }

                            count++;
                            moved = records.MoveNext();
                        }
                    }

                    if (count != 1)
                    {
                        problems += entry.HasTooManyDbaseRecords(1, count);
                    }
                }
                else
                {
                    problems += entry.HasNoDbaseRecords(true);
                }
            }
            catch (Exception exception)
            {
                problems += entry.AtDbaseRecord(records.CurrentRecordNumber).HasDbaseRecordFormatError(exception);
            }

            return(problems);
        }