Exemplo n.º 1
0
        public void ParseSimpleMessage()
        {
            PipeParser parser = new PipeParser();
            ADT_A01    msg    = parser.Parse(GetMessage(), Constants.VERSION_25_UCH) as ADT_A01;

            Assert.IsNotNull(msg);

            Assert.AreEqual(2, msg.INSURANCERepetitionsUsed);
            Assert.AreEqual(msg.GetINSURANCE(0).IN1.SetIDIN1.Value, "1");
            Assert.AreEqual(msg.GetINSURANCE(1).IN1.SetIDIN1.Value, "2");
        }
Exemplo n.º 2
0
        public void TestCurrent()
        {
            var message = new ADT_A01();
            var sut     = new MessageIterator(message.GetROL(), "ROL", false);

            Assert.AreEqual(message.GetROL(1), sut.Current, "next rep if dir matches repeating segment");
            sut.Direction = "PDA";

            Assert.AreEqual(message.GetNK1(), sut.Current, "next sibling if dir doesn't match repeating segment");
            Console.WriteLine(sut.Current);

            sut.Direction = "PV1";
            Assert.AreEqual(message.PV2, sut.Current, "next sibling if dir matches non-repeating segment");

            sut = new MessageIterator(message.GetPROCEDURE(), "PDA", false);
            Assert.AreEqual(message.GetPROCEDURE().PR1, sut.Current, "group to child");
            sut.Direction = "PR1";

            Console.WriteLine(sut.Current);

            Assert.AreEqual(message.GetPROCEDURE(1), sut.Current, "next rep of group if 1st child matches dir");

            sut = new MessageIterator(message.GetPROCEDURE().GetROL(), "PDA", false);
            Assert.AreEqual(message.GetGT1(), sut.Current, "next sibling of parent if group doesn't contain direction");

            sut = new MessageIterator(message.GetINSURANCE().GetROL(), "IN3", false);
            Assert.AreEqual(message.ACC, sut.Current, "next sib of parent if contains dir after required child");

            sut = new MessageIterator(message.PDA, "FOO", false);
            try
            {
                var unused = sut.Current;
                Assert.Fail("should have thrown no such element exception on attempt to iterate past end of message");
            }
            catch (ArgumentOutOfRangeException)
            {
                /* OK */
            }

            sut = new MessageIterator(message.PDA, "FOO", true);
            var segment = (ISegment)sut.Current;

            Assert.AreEqual("FOO", segment.GetStructureName());

            sut     = new MessageIterator(message.GetINSURANCE().GetROL(), "BAR", true);
            segment = (ISegment)sut.Current;
            Assert.AreEqual("BAR", segment.GetStructureName());
            Assert.AreEqual(5, message.GetINSURANCE().Names.Length, "BAR added as a child of IN1 group");
        }
Exemplo n.º 3
0
        public void Contains_ValidInput_ReturnsExpectedResult()
        {
            // Arrange
            var message = new ADT_A01();

            // Act
            var actual =
                MessageIterator.contains(message.GetINSURANCE(), "IN1", true, true);

            // Assert
            Assert.AreEqual(true, actual);
        }
Exemplo n.º 4
0
        public void MatchExistsAfterPosition_ValidInput_ReturnsExpectedResult(
            string name, bool firstDescendentOnly, bool upToFirstRequired, bool expectedResult)
        {
            // Arrange
            var message  = new ADT_A01();
            var position = new MessageIterator.Position(message.GetINSURANCE(), "IN2", 0);

            // Act
            var actual =
                MessageIterator.MatchExistsAfterPosition(position, name, firstDescendentOnly, upToFirstRequired);

            // Assert
            Assert.AreEqual(expectedResult, actual);
        }