Exemple #1
0
        public void SerializeEvent(AlertType alertType, string title, string message, EventPriority priority, string?source,
                                   string?aggregationKey, string?constantTags, string?extraTags, string expected)
        {
            byte[] sourceBytes = source != null?Encoding.ASCII.GetBytes(source) : Array.Empty <byte>();

            byte[] constantTagsBytes = DogStatsDSerializer.ValidateAndSerializeTags(TestHelper.ParseTags(constantTags));
            var    eventBytes        = DogStatsDSerializer.SerializeEvent(alertType, title, message, priority, sourceBytes, aggregationKey, constantTagsBytes, TestHelper.ParseTags(extraTags));
            string eventStr          = Encoding.UTF8.GetString(eventBytes.Array !, eventBytes.Offset, eventBytes.Count);

            Assert.AreEqual(expected, eventStr);
            ArrayPool <byte> .Shared.Return(eventBytes.Array !);
        }
Exemple #2
0
        public void SerializeServiceCheck(string?ns, string name, CheckStatus checkStatus, string?message, string?constantTags,
                                          string?extraTags, string expected)
        {
            byte[] nsBytes = ns != null?Encoding.ASCII.GetBytes(ns) : Array.Empty <byte>();

            message ??= string.Empty;
            byte[] constantTagsBytes = DogStatsDSerializer.ValidateAndSerializeTags(TestHelper.ParseTags(constantTags));
            var    serviceCheckBytes = DogStatsDSerializer.SerializeServiceCheck(nsBytes, name, checkStatus, message, constantTagsBytes, TestHelper.ParseTags(extraTags));
            string serviceCheckStr   = Encoding.UTF8.GetString(serviceCheckBytes.Array !, serviceCheckBytes.Offset, serviceCheckBytes.Count);

            Assert.AreEqual(expected, serviceCheckStr);
            ArrayPool <byte> .Shared.Return(serviceCheckBytes.Array !);
        }