public void ShareUsageElement_SessionIdAndSequence_Existing()
        {
            // Arrange
            CreateShareUsage(1, 1, 1, new List <string>(), new List <string>(), new List <KeyValuePair <string, string> >());

            Dictionary <string, object> evidenceData = new Dictionary <string, object>()
            {
                { Core.Constants.EVIDENCE_CLIENTIP_KEY, "1.2.3.4" },
                { Constants.EVIDENCE_SESSIONID, "abcdefg-hijklmn-opqrst-uvwyxz" },
                { Constants.EVIDENCE_SEQUENCE, "2" },
            };

            var pipeline = new TestPipeline(_pipeline.Object);
            var data     = new TestFlowData(new Logger <TestFlowData>(new LoggerFactory()), pipeline, new Evidence(new Logger <Evidence>(new LoggerFactory())));

            data.AddEvidence(evidenceData);

            // Act
            _sequenceElement.Process(data);
            _shareUsageElement.Process(data);
            // Wait for the consumer task to finish.
            Assert.IsNotNull(_shareUsageElement.SendDataTask);
            _shareUsageElement.SendDataTask.Wait();

            // Assert
            // Check that one and only one HTTP message was sent
            _httpHandler.Verify(h => h.Send(It.IsAny <HttpRequestMessage>()), Times.Once);
            Assert.AreEqual(1, _xmlContent.Count);

            // Validate that the XML is well formed by passing it through a reader
            using (XmlReader xr = XmlReader.Create(new StringReader(_xmlContent[0])))
            {
                while (xr.Read())
                {
                }
            }

            // Check that the expected values are populated.
            Assert.IsTrue(_xmlContent[0].Contains("<SessionId>abcdefg-hijklmn-opqrst-uvwyxz</SessionId>"));
            Assert.IsTrue(_xmlContent[0].Contains("<Sequence>3</Sequence>"));
            Assert.IsTrue(data.GetEvidence().AsDictionary().ContainsKey(Constants.EVIDENCE_SESSIONID));
            Assert.IsTrue(data.GetEvidence().AsDictionary().ContainsKey(Constants.EVIDENCE_SEQUENCE));
        }
Exemplo n.º 2
0
 public void AccessEvidenceStringValues_AsDictionary_ToString()
 {
     var value = _flowDataStringValues.GetEvidence().AsDictionary()["test"].ToString();
 }
Exemplo n.º 3
0
 public void AccessEvidenceLargeDict_AsDictionary_ToString()
 {
     var value = _flowDataLargeDict.GetEvidence().AsDictionary()["test50"].ToString();
 }