public void TestFileLimit_ShouldCleanupTheSpace_SpaceWasCleaned()
        {
            const string breadcrumbMessage         = "foo";
            const int    minimalSize               = 10 * 1000;
            var          breadcrumbFile            = new InMemoryBreadcrumbFile();
            var          breadcrumbsStorageManager = new BacktraceStorageLogManager(Application.temporaryCachePath)
            {
                BreadcrumbFile  = breadcrumbFile,
                BreadcrumbsSize = minimalSize
            };
            var breadcrumbsManager  = new BacktraceBreadcrumbs(breadcrumbsStorageManager);
            var unityEngineLogLevel = UnityEngineLogLevel.Debug;
            var breadcrumbStart     = breadcrumbsManager.BreadcrumbId();

            breadcrumbsManager.EnableBreadcrumbs(ManualBreadcrumbsType, unityEngineLogLevel);
            int numberOfAddedBreadcrumbs = 1;

            breadcrumbsManager.Log(breadcrumbMessage, LogType.Assert);
            var breadcrumbSize = breadcrumbFile.Size - 2;

            while (breadcrumbFile.Size + breadcrumbSize < minimalSize != false)
            {
                breadcrumbsManager.Log(breadcrumbMessage, LogType.Assert);
                numberOfAddedBreadcrumbs++;
            }
            var sizeBeforeCleanup = breadcrumbFile.Size;
            var numberOfBreadcurmbsBeforeCleanUp = numberOfAddedBreadcrumbs;

            breadcrumbsManager.Log(breadcrumbMessage, LogType.Assert);
            numberOfAddedBreadcrumbs++;

            Assert.That(breadcrumbFile.Size, Is.LessThan(sizeBeforeCleanup));
            var data = ConvertToBreadcrumbs(breadcrumbFile);

            Assert.IsNotEmpty(data);
            Assert.AreEqual(breadcrumbStart + numberOfAddedBreadcrumbs, breadcrumbsStorageManager.BreadcrumbId());
            Assert.That(breadcrumbsStorageManager.Length(), Is.LessThan(numberOfBreadcurmbsBeforeCleanUp));
        }
        public void TestBreadcrumbs_BasicBreadcrumbsTestForAllEvents_ShouldStoreEvents()
        {
            const int expectedNumberOfBreadcrumbs = 3;

            string[] messages = new string[expectedNumberOfBreadcrumbs] {
                "CustomUserBreadcrumb1",
                "PlayerStarted",
                "unhandled exception custom message from breadcrumbs test case"
            };

            var breadcrumb1Attributes = new Dictionary <string, string>()
            {
                { "name", "CustomUserBreadcrumb1Value" }
            };

            var breadcrumbFile            = new InMemoryBreadcrumbFile();
            var breadcrumbsStorageManager = new BacktraceStorageLogManager(Application.temporaryCachePath)
            {
                BreadcrumbFile = breadcrumbFile
            };
            var breadcrumbsManager   = new BacktraceBreadcrumbs(breadcrumbsStorageManager);
            var expectedBreadcrumbId = breadcrumbsManager.BreadcrumbId();
            var unityEngineLogLevel  = UnityEngineLogLevel.Debug | UnityEngineLogLevel.Warning | UnityEngineLogLevel.Info | UnityEngineLogLevel.Error | UnityEngineLogLevel.Fatal;

            breadcrumbsManager.EnableBreadcrumbs(BacktraceBreadcrumbType.Manual | BacktraceBreadcrumbType.System, unityEngineLogLevel);
            breadcrumbsManager.Warning(messages[0], breadcrumb1Attributes);
            breadcrumbsManager.Info(messages[1]);
            breadcrumbsManager.Exception(messages[2]);

            Assert.AreEqual(expectedNumberOfBreadcrumbs, breadcrumbsStorageManager.Length());
            Assert.AreEqual(expectedNumberOfBreadcrumbs + expectedBreadcrumbId, breadcrumbsStorageManager.BreadcrumbId());
            var breadcrumbs = ConvertToBreadcrumbs(breadcrumbFile);

            for (int i = 0; i < expectedNumberOfBreadcrumbs; i++)
            {
                Assert.AreEqual(messages[i], breadcrumbs.ElementAt(i).Message);
            }
        }