public async Task RecentTemplates_TwoTemplatesInGroupDifferentLanguage_TreatedAsDifferentRecentTemplate()
        {
            CreateCategories("android", "app", "general");
            CreateCategorizer();
            SolutionTemplate template1 = AddTemplate("template-id1", "android/app/general");

            template1.GroupId  = "console";
            template1.Language = "C#";
            SolutionTemplate template2 = AddTemplate("template-id2", "android/app/general");

            template2.GroupId  = "console";
            template2.Language = "F#";
            CategorizeTemplates();
            recentlyUsedTemplatesFile = GetRecentlyUsedTemplatesFileName("TwoTemplatesInGroupDifferentLanguage.xml");
            var recentTemplates            = new RecentTemplates(recentlyUsedTemplatesFile);
            var initialRecentTemplatesList = recentTemplates.GetTemplates(categorizedTemplates);

            recentTemplates.AddTemplate(template1);
            recentTemplates.AddTemplate(template2);

            var recentTemplatesList = await GetRecentTemplates(recentTemplates, categorizedTemplates, 2);

            Assert.AreEqual(0, initialRecentTemplatesList.Count);
            Assert.AreEqual(2, recentTemplatesList.Count);
            Assert.AreEqual(template2, recentTemplatesList[0]);
            Assert.AreEqual(template1, recentTemplatesList[1]);
        }
        /// <summary>
        /// The RecentTemplates class uses the RecentFileStorage class. In the
        /// RecentFileStorage class constructor a task is started to create a file
        /// and may finish whilst the unit test is adding a new template. This task
        /// delay can cause the cached in-memory list in the RecentFileStorage to be
        /// cleared. This causes the test to fail since it will run before the
        /// in-memory list can be updated when the RecentFileStorage class saves the
        /// file to disk. This saving to file is delayed by a second. So we retry
        /// getting the templates from the RecentTemplates until a timeout occurs.
        /// Most of the time the RecentTemplates.GetTemplates method works first
        /// time and returns the expected templates.
        /// </summary>
        static async Task <IList <SolutionTemplate> > GetRecentTemplates(
            RecentTemplates recentTemplates,
            List <TemplateCategory> categorizedTemplates,
            int expectedTemplateCount)
        {
            const int MAX_WAIT_TIME = 5000;
            const int RETRY_WAIT    = 100;

            int remainingTries = MAX_WAIT_TIME / RETRY_WAIT;

            while (remainingTries > 0)
            {
                var recentTemplatesList = recentTemplates.GetTemplates(categorizedTemplates);
                if (recentTemplatesList.Count == expectedTemplateCount)
                {
                    return(recentTemplatesList);
                }

                // Wait for recent file storage to be updated.
                await Task.Delay(RETRY_WAIT);

                remainingTries--;
            }
            return(new List <SolutionTemplate> ());
        }