Exemple #1
0
        public void Initialize_DefaultSettings()
        {
            try
            {
                JsonConvert.DefaultSettings = () => new JsonSerializerSettings
                {
                    Formatting = Formatting.Indented
                };

                MockMessageBroker  broker = new MockMessageBroker();
                MockExecutionTimer timer  = new MockExecutionTimer();

                GlimpseJson.Initialize(() => RuntimePolicy.PersistResults, () => timer, broker);

                Assert.IsNotNull(JsonConvert.DefaultSettings);

                JsonSerializerSettings settings = JsonConvert.DefaultSettings();

                Assert.IsNotNull(settings.TraceWriter);
                Assert.IsInstanceOf <GlimpseTraceWriter>(settings.TraceWriter);

                Assert.AreEqual(Formatting.Indented, settings.Formatting);
            }
            finally
            {
                JsonConvert.DefaultSettings = null;
            }
        }
Exemple #2
0
        public void Initialize_GlimpseOff()
        {
            try
            {
                JsonConvert.DefaultSettings = null;

                MockMessageBroker  broker = new MockMessageBroker();
                MockExecutionTimer timer  = new MockExecutionTimer();

                GlimpseJson.Initialize(() => RuntimePolicy.Off, () => timer, broker);

                Assert.IsNotNull(JsonConvert.DefaultSettings);

                JsonSerializerSettings settings = JsonConvert.DefaultSettings();

                Assert.IsNull(settings.TraceWriter);
            }
            finally
            {
                JsonConvert.DefaultSettings = null;
            }
        }