Ejemplo n.º 1
0
        public void ToSentryUnityOptions_ValueMapping_AreEqual(bool isBuilding, bool enableOfflineCaching)
        {
            var expectedOptions = new SentryUnityOptions
            {
                Enabled                     = false,
                Dsn                         = "test",
                CaptureInEditor             = false,
                EnableLogDebouncing         = true,
                TracesSampleRate            = 1.0f,
                AutoSessionTracking         = false,
                AutoSessionTrackingInterval = TimeSpan.FromSeconds(1),
                AttachStacktrace            = true,
                MaxBreadcrumbs              = 1,
                ReportAssembliesMode        = ReportAssembliesMode.None,
                SendDefaultPii              = true,
                IsEnvironmentUser           = true,
                MaxCacheItems               = 1,
                CacheDirectoryPath          = enableOfflineCaching ? _fixture.Application.PersistentDataPath : null,
                InitCacheFlushTimeout       = TimeSpan.FromSeconds(1),
                SampleRate                  = 0.5f,
                ShutdownTimeout             = TimeSpan.FromSeconds(1),
                MaxQueueItems               = 1,
                Release                     = "testRelease",
                Environment                 = "testEnvironment",
                Debug                       = true,
                DebugOnlyInEditor           = true,
                DiagnosticLevel             = SentryLevel.Info,
            };

            var scriptableOptions = ScriptableObject.CreateInstance <ScriptableSentryUnityOptions>();

            scriptableOptions.Enabled                     = expectedOptions.Enabled;
            scriptableOptions.Dsn                         = expectedOptions.Dsn;
            scriptableOptions.CaptureInEditor             = expectedOptions.CaptureInEditor;
            scriptableOptions.EnableLogDebouncing         = expectedOptions.EnableLogDebouncing;
            scriptableOptions.TracesSampleRate            = expectedOptions.TracesSampleRate;
            scriptableOptions.AutoSessionTracking         = expectedOptions.AutoSessionTracking;
            scriptableOptions.AutoSessionTrackingInterval = (int)expectedOptions.AutoSessionTrackingInterval.TotalMilliseconds;
            scriptableOptions.AttachStacktrace            = expectedOptions.AttachStacktrace;
            scriptableOptions.MaxBreadcrumbs              = expectedOptions.MaxBreadcrumbs;
            scriptableOptions.ReportAssembliesMode        = expectedOptions.ReportAssembliesMode;
            scriptableOptions.SendDefaultPii              = expectedOptions.SendDefaultPii;
            scriptableOptions.IsEnvironmentUser           = expectedOptions.IsEnvironmentUser;
            scriptableOptions.MaxCacheItems               = expectedOptions.MaxCacheItems;
            scriptableOptions.EnableOfflineCaching        = enableOfflineCaching;
            scriptableOptions.InitCacheFlushTimeout       = (int)expectedOptions.InitCacheFlushTimeout.TotalMilliseconds;
            scriptableOptions.SampleRate                  = expectedOptions.SampleRate;
            scriptableOptions.ShutdownTimeout             = (int)expectedOptions.ShutdownTimeout.TotalMilliseconds;
            scriptableOptions.MaxQueueItems               = expectedOptions.MaxQueueItems;
            scriptableOptions.ReleaseOverride             = expectedOptions.Release;
            scriptableOptions.EnvironmentOverride         = expectedOptions.Environment;
            scriptableOptions.Debug                       = expectedOptions.Debug;
            scriptableOptions.DebugOnlyInEditor           = expectedOptions.DebugOnlyInEditor;
            scriptableOptions.DiagnosticLevel             = expectedOptions.DiagnosticLevel;

            var optionsActual = ScriptableSentryUnityOptions.ToSentryUnityOptions(scriptableOptions, isBuilding, _fixture.Application);

            AssertOptions(expectedOptions, optionsActual);
        }
Ejemplo n.º 2
0
        public void ToSentryUnityOptions_HasOptionsConfiguration_GetsCalled(bool isBuilding)
        {
            var optionsConfiguration = ScriptableObject.CreateInstance <TestOptionsConfiguration>();
            var scriptableOptions    = ScriptableObject.CreateInstance <ScriptableSentryUnityOptions>();

            scriptableOptions.OptionsConfiguration = optionsConfiguration;

            ScriptableSentryUnityOptions.ToSentryUnityOptions(scriptableOptions, isBuilding);

            Assert.IsTrue(optionsConfiguration.GotCalled);
        }
Ejemplo n.º 3
0
        public void ToScriptableOptions_ConvertJsonOptions_AreEqual(bool isBuilding)
        {
            var jsonTextAsset   = new TextAsset(File.ReadAllText(GetTestOptionsFilePath()));
            var expectedOptions = JsonSentryUnityOptions.LoadFromJson(jsonTextAsset);

            var scriptableOptions = ScriptableObject.CreateInstance <ScriptableSentryUnityOptions>();

            SentryOptionsUtility.SetDefaults(scriptableOptions);
            JsonSentryUnityOptions.ToScriptableOptions(jsonTextAsset, scriptableOptions);

            var actualOptions = ScriptableSentryUnityOptions.ToSentryUnityOptions(scriptableOptions, isBuilding);

            AssertOptions(expectedOptions, actualOptions);
        }
Ejemplo n.º 4
0
        public void ToSentryOptions_OptionsCreated_AreEqualToNewOptions(bool isBuilding)
        {
            var expectedOptions = new SentryUnityOptions(_fixture.Application, isBuilding);

            var scriptableOptions = ScriptableObject.CreateInstance <ScriptableSentryUnityOptions>();

            SentryOptionsUtility.SetDefaults(scriptableOptions);

            // These are config window specific differences in default values we actually want
            scriptableOptions.Debug             = false;
            scriptableOptions.DebugOnlyInEditor = false;
            scriptableOptions.DiagnosticLevel   = SentryLevel.Debug;

            var actualOptions = ScriptableSentryUnityOptions.ToSentryUnityOptions(scriptableOptions, isBuilding, _fixture.Application);

            AssertOptions(expectedOptions, actualOptions);
        }