Exemplo n.º 1
0
 public void SetUp()
 {
     _sut      = CreateSUT();
     _resolver = new Mock <IBusinessPartnerSpecificServiceResolver>();
     _resolver.Setup(r => r.GetBuildValueFactoryFor(BusinessPartner.FedEx)).Returns(new FedExBuildValueFactory());
     _seg = new SegmentFactory(_resolver.Object);
 }
Exemplo n.º 2
0
 private static Displayable SwitchableSegment2(char onTrigger, string firstOnValue, string secondOnValue)
 {
     return(new CircularDisplayable(
                SegmentFactory.CreateSwitchable(onTrigger, firstOnValue, _()),
                SegmentFactory.CreateSwitchable(onTrigger, secondOnValue, _()),
                SegmentFactory.CreateSwitchable(onTrigger, onTrigger.ToString(), _())));
 }
Exemplo n.º 3
0
        public virtual void Parse()
        {
            if (!string.IsNullOrEmpty(_message))
            {
                SegmentFactoryManager segmentBuilder = new SegmentFactoryManager();
                SegmentFactory        segmentFactory = segmentBuilder.GetFactory(_driverType);

                List <string> segments = new List <string>(_message.Replace("\r\n", "\r").Split('\r'));

                foreach (string segment in segments)
                {
                    Segment newSegment = segmentFactory.CreateSegmentInstance(
                        ((SegmentTypes)EnumUtils.enumValueOf(segment.Substring(0, 3), typeof(SegmentTypes))),
                        segment);

                    _segments.Add(newSegment);
                }

                if (_segments != null && _segments.Count > 0)
                {
                    MSH msh = (MSH)_segments.Find(s => s.SegmentType == SegmentTypes.MSH);
                    _delimiters.FieldSeparator        = msh.GetFieldSeparator();
                    _delimiters.ComponentSeparator    = msh.GetComponentSeparator();
                    _delimiters.FieldRepeatSeparator  = msh.GetFieldRepeatSeparator();
                    _delimiters.EscapeCharacter       = msh.GetEscapeCharacter();
                    _delimiters.SubComponentSeparator = msh.GetSubComponentSeparator();

                    _versioinId       = msh.GetVersionId();
                    _messageDate      = msh.GetMessageDateTime();
                    _type             = msh.GetMessageType();
                    _messageControlId = msh.GetMessageControlId();
                    _processingId     = msh.GetProcessingId();
                }
            }
        }
Exemplo n.º 4
0
 public SegmentStream(SegmentFactory segmentCreator)
 {
     _currentSegIndex = 0;
     _position        = 0;
     _core            = new List <SegmentData>();
     StreamType       = StreamType.Write;
     _segmentCreator  = segmentCreator;
 }
Exemplo n.º 5
0
 public SegmentStream(SegmentFactory segmentCreator)
 {
     _currentSegIndex = 0;
     _position = 0;
     _core = new List<SegmentData>();
     StreamType = StreamType.Write;
     _segmentCreator = segmentCreator;
 }
Exemplo n.º 6
0
 public void SetUp()
 {
     _sut      = CreateSUT();
     _resolver = new Mock <IBusinessPartnerSpecificServiceResolver>();
     _resolver.Setup(r => r.GetBuildValueFactoryFor(It.IsAny <BusinessPartner>())).Returns(
         new InitechBuildValueFactory());
     _seg = new SegmentFactory(_resolver.Object);
     _seg.SetBuildValues(BusinessPartner.Initech);
 }
Exemplo n.º 7
0
        public void CreateNextSegment_InputDirectionNorth_ReturnsVerticalSegment()
        {
            //Arrange
            SegmentFactory factory = new SegmentFactory();
            string         command = "N 4";

            //Act
            Segment segment = factory.CreateNextSegment(command, 1, 1, 0);

            Assert.AreEqual(segment.Layout, Segment.Position.Vertical);
        }
Exemplo n.º 8
0
        public void CreateNextSegment_InputCommandIncludesTenSteps_ReturnsSegmentOfLengthTen()
        {
            //Arrange
            SegmentFactory factory = new SegmentFactory();
            string         command = "E 10";

            //Act
            Segment segment = factory.CreateNextSegment(command, 1, 1, 1);

            Assert.AreEqual(segment.Length, 10);
        }
Exemplo n.º 9
0
        public void CreateNextSegment_InputDirectionWest_ReturnsHorizontalSegment()
        {
            //Arrange
            SegmentFactory factory = new SegmentFactory();
            string         command = "W 4";

            //Act
            Segment segment = factory.CreateNextSegment(command, 1, 1, 0);

            Assert.AreEqual(segment.Layout, Segment.Position.Horizontal);
        }
Exemplo n.º 10
0
    private void Start()
    {
        segFactory       = GetComponent <SegmentFactory>();
        globalGoals      = GetComponent <GlobalGoals>();
        localConstraints = GetComponent <LocalConstraints>();
        map           = GetComponent <RoadMap>();
        lotsGenerator = GetComponent <LotsGenerator>();

        seed = 8;
        //seed = Random.Range(0, 65536);
        Generate(seed);
    }
Exemplo n.º 11
0
        public void TennesseePidFirstNameIsThomasUsingDefaultDelimiters()
        {
            // Arrange
            string testPidSegment = "PID|1||10006579^^^1^MRN^1||THOMAS^C^CHAPMAN||19241010|M||1|111 DUCK ST^^FOWL^CA^999990000^^M|1|8885551212|8885551212|1|2||40007716^^^AccMgr^VN^1|123121234|||||||||||NO";

            // Act
            SegmentFactoryManager newManager = new SegmentFactoryManager();
            SegmentFactory        newFactory = newManager.GetFactory(DriverTypes.TennesseeHealthCare);

            PID newPid = newFactory.CreatePIDInstance(testPidSegment);

            // Assert
            Assert.AreEqual("THOMAS", newPid.GetPatientName().GivenName.ToUpper());
        }
Exemplo n.º 12
0
        public void GenericV23PidFirstNameIsDonaldUsingDefaultDelimiters()
        {
            // Arrange
            string testPidSegment = "PID|1||10006579^^^1^MRN^1||DUCK^DONALD^D||19241010|M||1|111 DUCK ST^^FOWL^CA^999990000^^M|1|(888)555-1212|(888)555-1212|1|2||40007716^^^AccMgr^VN^1|123121234|||||||||||NO";

            // Act
            SegmentFactoryManager newManager = new SegmentFactoryManager();
            SegmentFactory        newFactory = newManager.GetFactory(DriverTypes.GenericV23);

            PID newPid = newFactory.CreatePIDInstance(testPidSegment);

            // Assert
            Assert.AreEqual("DONALD", newPid.GetPatientName().GivenName.ToUpper());
        }
Exemplo n.º 13
0
        public void can_build_invoice_detail()
        {
            var segFactory = new SegmentFactory(new BusinessPartnerSpecificServiceResolver());

            segFactory.SetBuildValues(BusinessPartner.Initech);
            IDictionary <Qualifier, string> values = new Dictionary <Qualifier, string>
            {
                { Qualifier.InvoiceVendorPart, "FIN23432" },
                { Qualifier.PartDescription, "rectangular box" },
                { Qualifier.PONumber, "32543243" },
                { Qualifier.POLineNumber, "10" }
            };
            EDIXmlSegment seg = segFactory.GetLineItemInvoiceDetail("10",
                                                                    1, (decimal).99, values);

            Console.WriteLine(seg.Value);
        }
Exemplo n.º 14
0
        public void GenericV23PidFirstNameIsDonaldUsingCustomDelimiters()
        {
            // Arrange
            SegmentDelimiters delimiters = new SegmentDelimiters {
                FieldSeparator = '%'
            };
            string testPidSegment = "PID%1%%10006579^^^1^MRN^1%%DUCK^DONALD^D%%19241010%M%%1%111 DUCK ST^^FOWL^CA^999990000^^M%1%(888)555-1212%(888)555-1212%1%2%%40007716^^^AccMgr^VN^1%123121234%%%%%%%%%%%NO";

            // Act
            SegmentFactoryManager newManager = new SegmentFactoryManager(delimiters);
            SegmentFactory        newFactory = newManager.GetFactory(DriverTypes.GenericV23);

            PID newPid = newFactory.CreatePIDInstance(testPidSegment);

            // Assert
            Assert.AreEqual("DONALD", newPid.GetPatientName().GivenName.ToUpper());
        }
Exemplo n.º 15
0
        public void TennesseePidFirstNameIsThomasUsingCustomDelimiters()
        {
            // Arrange
            SegmentDelimiters delimiters = new SegmentDelimiters {
                FieldSeparator = '*'
            };
            string testPidSegment = "PID*1**10006579^^^1^MRN^1**THOMAS^C^CHAPMAN**19241010*M**1*111 DUCK ST^^FOWL^CA^999990000^^M*1*8885551212*8885551212*1*2**40007716^^^AccMgr^VN^1*123121234***********NO";

            // Act
            SegmentFactoryManager newManager = new SegmentFactoryManager(delimiters);
            SegmentFactory        newFactory = newManager.GetFactory(DriverTypes.TennesseeHealthCare);

            PID newPid = newFactory.CreatePIDInstance(testPidSegment);

            // Assert
            Assert.AreEqual("THOMAS", newPid.GetPatientName().GivenName.ToUpper());
        }
Exemplo n.º 16
0
 public SegmentTests()
 {
     _segmentFactory = new SegmentFactory <TEntity>();
 }
Exemplo n.º 17
0
        public async Task GetCursor()
        {
            // Arrange
            string manifestPath = "idx/segments/2020/03/25/0200/meta.json";

            Mock <BlobContainerClient> containerClient = new Mock <BlobContainerClient>(MockBehavior.Strict);
            Mock <BlobClient>          blobClient      = new Mock <BlobClient>(MockBehavior.Strict);
            Mock <ShardFactory>        shardFactory    = new Mock <ShardFactory>(MockBehavior.Strict);

            List <Mock <Shard> > shards = new List <Mock <Shard> >();
            int shardCount = 3;

            for (int i = 0; i < shardCount; i++)
            {
                shards.Add(new Mock <Shard>(MockBehavior.Strict));
            }

            List <ShardCursor> shardCursors = new List <ShardCursor>
            {
                new ShardCursor(1, 2, 3),
                new ShardCursor(4, 5, 6),
                new ShardCursor(7, 8, 9)
            };

            DateTimeOffset dateTime   = new DateTimeOffset(2020, 3, 25, 2, 0, 0, TimeSpan.Zero);
            int            shardIndex = 1;

            SegmentCursor expectedCursor = new SegmentCursor(
                dateTime,
                shardCursors,
                shardIndex);

            containerClient.Setup(r => r.GetBlobClient(It.IsAny <string>())).Returns(blobClient.Object);

            using FileStream stream = File.OpenRead(
                      $"{Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)}{Path.DirectorySeparatorChar}Resources{Path.DirectorySeparatorChar}{"SegmentManifest.json"}");
            BlobDownloadInfo            blobDownloadInfo = BlobsModelFactory.BlobDownloadInfo(content: stream);
            Response <BlobDownloadInfo> downloadResponse = Response.FromValue(blobDownloadInfo, new MockResponse(200));

            if (IsAsync)
            {
                blobClient.Setup(r => r.DownloadAsync()).ReturnsAsync(downloadResponse);
            }
            else
            {
                blobClient.Setup(r => r.Download()).Returns(downloadResponse);
            }

            shardFactory.SetupSequence(r => r.BuildShard(
                                           It.IsAny <bool>(),
                                           It.IsAny <string>(),
                                           It.IsAny <ShardCursor>()))
            .ReturnsAsync(shards[0].Object)
            .ReturnsAsync(shards[1].Object)
            .ReturnsAsync(shards[2].Object);

            for (int i = 0; i < shardCount; i++)
            {
                shards[i].Setup(r => r.GetCursor()).Returns(shardCursors[i]);
            }

            SegmentFactory segmentFactory = new SegmentFactory(
                containerClient.Object,
                shardFactory.Object);
            Segment segment = await segmentFactory.BuildSegment(
                IsAsync,
                manifestPath,
                expectedCursor);

            // Act
            SegmentCursor cursor = segment.GetCursor();

            // Assert
            Assert.AreEqual(expectedCursor.SegmentTime, cursor.SegmentTime);
            Assert.AreEqual(expectedCursor.ShardCursors.Count, cursor.ShardCursors.Count);
            for (int i = 0; i < shardCount; i++)
            {
                Assert.AreEqual(expectedCursor.ShardCursors[i].BlockOffset, cursor.ShardCursors[i].BlockOffset);
                Assert.AreEqual(expectedCursor.ShardCursors[i].ChunkIndex, cursor.ShardCursors[i].ChunkIndex);
                Assert.AreEqual(expectedCursor.ShardCursors[i].EventIndex, cursor.ShardCursors[i].EventIndex);
            }
            Assert.AreEqual(shardIndex, cursor.ShardIndex);

            containerClient.Verify(r => r.GetBlobClient(manifestPath));

            if (IsAsync)
            {
                blobClient.Verify(r => r.DownloadAsync());
            }
            else
            {
                blobClient.Verify(r => r.Download());
            }

            for (int i = 0; i < shards.Count; i++)
            {
                shardFactory.Verify(r => r.BuildShard(
                                        IsAsync,
                                        $"log/0{i}/2020/03/25/0200/",
                                        shardCursors[i]));
            }
        }
Exemplo n.º 18
0
        public async Task GetPage()
        {
            // Arrange
            string manifestPath = "idx/segments/2020/03/25/0200/meta.json";
            int    shardCount   = 3;
            int    eventCount   = 5;

            Mock <BlobContainerClient> containerClient = new Mock <BlobContainerClient>(MockBehavior.Strict);
            Mock <BlobClient>          blobClient      = new Mock <BlobClient>(MockBehavior.Strict);
            Mock <ShardFactory>        shardFactory    = new Mock <ShardFactory>(MockBehavior.Strict);

            List <Mock <Shard> > shards = new List <Mock <Shard> >();

            for (int i = 0; i < shardCount; i++)
            {
                shards.Add(new Mock <Shard>(MockBehavior.Strict));
            }

            List <Guid> eventIds = new List <Guid>();

            for (int i = 0; i < eventCount; i++)
            {
                eventIds.Add(Guid.NewGuid());
            }

            containerClient.Setup(r => r.GetBlobClient(It.IsAny <string>())).Returns(blobClient.Object);

            using FileStream stream = File.OpenRead(
                      $"{Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)}{Path.DirectorySeparatorChar}Resources{Path.DirectorySeparatorChar}{"SegmentManifest.json"}");
            BlobDownloadInfo            blobDownloadInfo = BlobsModelFactory.BlobDownloadInfo(content: stream);
            Response <BlobDownloadInfo> downloadResponse = Response.FromValue(blobDownloadInfo, new MockResponse(200));

            if (IsAsync)
            {
                blobClient.Setup(r => r.DownloadAsync()).ReturnsAsync(downloadResponse);
            }
            else
            {
                blobClient.Setup(r => r.Download()).Returns(downloadResponse);
            }

            shardFactory.SetupSequence(r => r.BuildShard(
                                           It.IsAny <bool>(),
                                           It.IsAny <string>(),
                                           It.IsAny <ShardCursor>()))
            .ReturnsAsync(shards[0].Object)
            .ReturnsAsync(shards[1].Object)
            .ReturnsAsync(shards[2].Object);

            // Set up Shards
            shards[0].SetupSequence(r => r.Next(It.IsAny <bool>(), default))
            .Returns(Task.FromResult(new BlobChangeFeedEvent
            {
                Id = eventIds[0]
            }))
            .Returns(Task.FromResult(new BlobChangeFeedEvent
            {
                Id = eventIds[3]
            }));

            shards[0].SetupSequence(r => r.HasNext())
            .Returns(true)
            .Returns(false);

            shards[1].SetupSequence(r => r.Next(It.IsAny <bool>(), default))
            .Returns(Task.FromResult(new BlobChangeFeedEvent
            {
                Id = eventIds[1]
            }))
            .Returns(Task.FromResult(new BlobChangeFeedEvent
            {
                Id = eventIds[4]
            }));

            shards[1].SetupSequence(r => r.HasNext())
            .Returns(true)
            .Returns(false);

            shards[2].Setup(r => r.Next(It.IsAny <bool>(), default))
            .Returns(Task.FromResult(new BlobChangeFeedEvent
            {
                Id = eventIds[2]
            }));

            shards[2].Setup(r => r.HasNext())
            .Returns(false);

            SegmentFactory segmentFactory = new SegmentFactory(
                containerClient.Object,
                shardFactory.Object);
            Segment segment = await segmentFactory.BuildSegment(
                IsAsync,
                manifestPath);

            // Act
            List <BlobChangeFeedEvent> events = await segment.GetPage(IsAsync, 25);

            // Assert
            Assert.AreEqual(eventCount, events.Count);
            for (int i = 0; i < eventCount; i++)
            {
                Assert.AreEqual(eventIds[i], events[i].Id);
            }

            containerClient.Verify(r => r.GetBlobClient(manifestPath));
            if (IsAsync)
            {
                blobClient.Verify(r => r.DownloadAsync());
            }
            else
            {
                blobClient.Verify(r => r.Download());
            }

            for (int i = 0; i < shards.Count; i++)
            {
                shardFactory.Verify(r => r.BuildShard(
                                        IsAsync,
                                        $"log/0{i}/2020/03/25/0200/",
                                        default));
            }

            shards[0].Verify(r => r.Next(IsAsync, default));
            shards[0].Verify(r => r.HasNext());
            shards[1].Verify(r => r.Next(IsAsync, default));
            shards[1].Verify(r => r.HasNext());
            shards[2].Verify(r => r.Next(IsAsync, default));
            shards[2].Verify(r => r.HasNext());
            shards[0].Verify(r => r.Next(IsAsync, default));
            shards[0].Verify(r => r.HasNext());
            shards[1].Verify(r => r.Next(IsAsync, default));
            shards[1].Verify(r => r.HasNext());
        }
Exemplo n.º 19
0
 public void AddLevel(string ID, string parent_id, string level_code)
 {
     AddSegment(SegmentFactory.GetHierarchicalLevel(ID, parent_id, level_code, false));
 }
Exemplo n.º 20
0
 public void SetHeader(string ID, string level_code)
 {
     _id    = ID;
     header = SegmentFactory.GetHierarchicalLevel(ID, "", level_code, true);
     AddSegment(header);
 }
Exemplo n.º 21
0
 private void AddNewSegmentToPool()
 {
     PutBackToPool(SegmentFactory.GenerateSegment());
 }
Exemplo n.º 22
0
        public EDIXmlDocument(string docType, int control_number) : base("ediDocument")
        {
            var seg = SegmentFactory.GetDocumentHeader(docType, control_number);

            Add(seg);
        }
Exemplo n.º 23
0
 public void SetHeader(string doc_type, int control_no)
 {
     _control_number = control_no;
     header          = SegmentFactory.GetDocumentHeader(doc_type, control_no);
     AddSegment(header);
 }
Exemplo n.º 24
0
 public void SetHeader(string receiver_id, int control_no, string functional_id)
 {
     header = SegmentFactory.GetGroupHeader(functional_id, receiver_id, control_no);
 }
Exemplo n.º 25
0
    bool stop  = false;        // delete this

    private void Initialize()
    {
        segFactory = GetComponent <SegmentFactory>();
    }
Exemplo n.º 26
0
 public void SetFooter()
 {
     footer = SegmentFactory.GetDocumentFooter(SegmentCount + 1, _control_number);
     AddSegment(footer);
 }
Exemplo n.º 27
0
 public void SetHeader(string receiver_id, int control_no, bool test)
 {
     header = SegmentFactory.GetInterchangeHeader(receiver_id, control_no, test);
 }
Exemplo n.º 28
0
 public void SetUp()
 {
     _sut      = CreateSUT();
     _resolver = new Mock <IBusinessPartnerSpecificServiceResolver>();
     _seg      = new SegmentFactory(_resolver.Object);
 }