Пример #1
0
        /// <summary>
        /// Publishes the error.
        /// </summary>
        /// <param name="ex">The ex.</param>
        public void PublishError(Exception ex)
        {
            VisualRxChannelWrapper[] channels = _setting.GetChannel(StreamKey);

            #region Validation

            if (channels.Length == 0)
            {
                return;
            }

            #endregion // Validation

            TimeSpan elapsed    = Elapsed();
            var      marbleItem = Marble.CreateError(
                StreamKey,
                ex,
                elapsed,
                _setting.MachineInfo);
            Publish(marbleItem, channels);
        }
Пример #2
0
        public void SerializeError_Test()
        {
            // arrange
            var ex  = new ArgumentException("Bad");
            var msg = Marble.CreateError("Test Marble",
                                         ex,
                                         TimeSpan.FromMilliseconds(10),
                                         "Test Machine");

            // act
            string json   = JsonConvert.SerializeObject(msg);
            Marble result = JsonConvert.DeserializeObject <Marble>(json);

            // verify
            Assert.AreEqual(msg.StreamKey, result.StreamKey);
            Assert.AreEqual(msg.Kind, result.Kind);
            Assert.AreEqual(msg.IndexOrder, result.IndexOrder);
            Assert.AreEqual(msg.DateCreatedUtc, result.DateCreatedUtc);
            Assert.AreEqual(msg.MachineName, result.MachineName);
            Assert.AreEqual(msg.Offset, result.Offset);
            Assert.AreEqual(msg.GetValue <ArgumentException>().Message, result.GetValue <ArgumentException>().Message);
            Assert.IsTrue(json.Contains($"\"Kind\":\"{NotificationKind.OnError}\""));
        }