Exemple #1
0
        public void ShouldSendUnderTheLimit()
        {
            Dictionary <LogType, int> maximumTypePerTimePeriod =
                new Dictionary <LogType, int> {
                { LogType.Error, 5 }
            };

            var configuration = new TestConfiguration("foo")
            {
                MaximumTypePerTimePeriod = maximumTypePerTimePeriod
            };

            var counter = new MaximumLogTypeCounter(configuration);

            var message1 = new UnityLogMessage("", "", LogType.Error);
            var message2 = new UnityLogMessage("", "", LogType.Error);
            var message3 = new UnityLogMessage("", "", LogType.Error);
            var message4 = new UnityLogMessage("", "", LogType.Error);
            var message5 = new UnityLogMessage("", "", LogType.Error);

            Assert.True(counter.ShouldSend(message1));
            Assert.True(counter.ShouldSend(message2));
            Assert.True(counter.ShouldSend(message3));
            Assert.True(counter.ShouldSend(message4));
            Assert.True(counter.ShouldSend(message5));
        }
Exemple #2
0
        public void FlushesCorrectly()
        {
            Dictionary <LogType, int> maximumTypePerTimePeriod =
                new Dictionary <LogType, int> {
                { LogType.Error, 1 }
            };

            var configuration = new TestConfiguration("foo")
            {
                MaximumTypePerTimePeriod = maximumTypePerTimePeriod,
                MaximumLogsTimePeriod    = TimeSpan.FromSeconds(2),
            };

            var counter = new MaximumLogTypeCounter(configuration);

            var message = new UnityLogMessage("", "", LogType.Error);

            counter.ShouldSend(message);

            Thread.Sleep(configuration.MaximumLogsTimePeriod);

            message = new UnityLogMessage("", "", LogType.Error);

            Assert.True(counter.ShouldSend(message));
        }
Exemple #3
0
        public void ShouldNotSendOverLimitMessages()
        {
            Dictionary <LogType, int> maximumTypePerTimePeriod =
                new Dictionary <LogType, int> {
                { LogType.Error, 1 }
            };

            var configuration = new TestConfiguration("foo")
            {
                MaximumTypePerTimePeriod = maximumTypePerTimePeriod
            };

            var counter = new MaximumLogTypeCounter(configuration);

            var message1 = new UnityLogMessage("", "", LogType.Error);
            var message2 = new UnityLogMessage("", "", LogType.Error);

            counter.ShouldSend(message1);
            Assert.False(counter.ShouldSend(message2));
        }
Exemple #4
0
        public void DontTrackCertainLogType()
        {
            Dictionary <LogType, int> maximumTypePerTimePeriod =
                new Dictionary <LogType, int>();

            var configuration = new TestConfiguration("foo")
            {
                MaximumTypePerTimePeriod = maximumTypePerTimePeriod
            };

            var counter = new MaximumLogTypeCounter(configuration);


            var message = new UnityLogMessage("", "", LogType.Error);

            Assert.True(counter.ShouldSend(message));
        }