public void ExceptionsCannotBeEmpty()
 {
     Assert.ThrowsException <ArgumentException>(() =>
     {
         var rb = new Body(ArrayUtility.GetEmptyArray <System.Exception>());
     });
 }
Esempio n. 2
0
 public void NullRollbarExceptionNotAllowed()
 {
     Assert.ThrowsException <ArgumentException>(() =>
     {
         new dto.Trace(ArrayUtility.GetEmptyArray <dto.Frame>(), null);
     });
 }
Esempio n. 3
0
        public void TraceBuiltManuallyWorksCorrectly()
        {
            var trace = new dto.Trace(ArrayUtility.GetEmptyArray <dto.Frame>(), new dto.Exception("BadClass"));

            Assert.AreEqual("BadClass", trace.Exception.Class);
            Assert.IsTrue(trace.Frames.Length == 0);
        }
        /// <summary>
        /// Creates the payload store repository.
        /// </summary>
        /// <returns>IPayloadStoreRepository.</returns>
        public static IPayloadStoreRepository CreatePayloadStoreRepository()
        {
            if (!File.Exists(ASSEMBLY))
            {
                return(RaiseTypeLoadException());
            }

            var assembly = ReflectionUtility.LoadSdkModuleAssembly(ASSEMBLY);

            if (assembly == null)
            {
                return(RaiseTypeLoadException());
            }

            var type = assembly.GetType("Rollbar.OfflinePersistence.PayloadStoreRepository", false);

            if (type == null)
            {
                return(RaiseTypeLoadException());
            }

            var ctor = type.GetConstructor(ArrayUtility.GetEmptyArray <Type>());

            if (ctor == null)
            {
                return(RaiseTypeLoadException());
            }

            return((IPayloadStoreRepository)ctor.Invoke(ArrayUtility.GetEmptyArray <object>()));
        }
        /// <summary>
        /// Validates this instance.
        /// </summary>
        /// <returns>IReadOnlyCollection&lt;ValidationResult&gt; containing failed validation rules.</returns>
        public IReadOnlyCollection <ValidationResult> Validate()
        {
            var validator = this.GetValidator();

            var failedValidations = validator?.Validate(this);

            if (failedValidations == null)
            {
                // it is always better to return an empty collection instead of null:
                failedValidations = ArrayUtility.GetEmptyArray <ValidationResult>();
            }

            return(failedValidations);
        }
        public void FrameCanHaveKwargs()
        {
            var frame = new Frame()
            {
                Kwargs = new Dictionary <string, object>
                {
                    { "One", 1 },
                    { "String", "Hi There" },
                    { "Arr", ArrayUtility.GetEmptyArray <object>() },
                },
            };
            var json = JsonConvert.SerializeObject(frame);

            Assert.IsTrue(json.Contains("\"kwargs\":{"));
            Assert.IsTrue(json.Contains("\"One\":1"));
            Assert.IsTrue(json.Contains("\"String\":\"Hi There\""));
            Assert.IsTrue(json.Contains("\"Arr\":[]"));
        }