Exemple #1
0
        static void Main(string[] args)
        {
            try
            {
                if (!File.Exists(FileName))
                {
                    var newRegistry = ProjectGenerator.GenRegistry(3, 10);
                    newRegistry.Save(FileName);
                }

                var registry = XmlRegistry.Load(FileName);

                // Валидация реестра - урлы в проектах и словах
                XmlRegistry.ValidateRegistry(registry);

                //------

                var apiKey = ConfigurationManager.AppSettings["apikey"];
                if (string.IsNullOrEmpty(apiKey))
                {
                    throw new InvalidOperationException(
                        "Invalid 'apikey' setting in application config.");
                }

                var config = new ClientConfig(apiKey);
                var client = new ApiClient(config);

                var syncClient = new SyncClient(client);

                Console.Write("Project's data loading...");
                syncClient.LoadSyncObjects();

                Console.WriteLine();
                Console.Write("Project's synchronization...");
                syncClient.SyncProjects(registry.Projects);

                Console.WriteLine();
                Console.Write("Groups's synchronization...");
                syncClient.SyncGroups(registry.Projects);

                Console.WriteLine();
                Console.Write("Keywords's synchronization...");
                syncClient.SyncKeywords(registry.Projects);

                Console.WriteLine();
                Console.Write("Synchronization completed, press any key...");
                Console.ReadKey();
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine();
                Console.WriteLine("Error:");
                Console.WriteLine(ex.ToString());
                Console.ResetColor();

                Console.Write("Press any key...");
                Console.ReadKey();
            }
        }
Exemple #2
0
        public void SyncConsistency()
        {
            var xmlRegistry = SyncTestHelper.GetRegistry();

            var apiProjects = SyncTestHelper.GetProjects();
            var apiKeywords = SyncTestHelper.GetKeywords();

            var client = new MockApiClient();

            client.SetProjects(apiProjects);
            client.SetKeywords(apiKeywords);

            var syncClient = new SyncClient(client);

            syncClient.LoadSyncObjects();

            var syncProjectsCount = syncClient.SyncProjects(xmlRegistry.Projects);

            Assert.IsTrue(syncProjectsCount != 0);

            syncProjectsCount = syncClient.SyncProjects(xmlRegistry.Projects);

            Assert.IsTrue(syncProjectsCount == 0);

            var syncGroupsCount = syncClient.SyncGroups(xmlRegistry.Projects);

            Assert.IsTrue(syncGroupsCount != 0);

            syncGroupsCount = syncClient.SyncGroups(xmlRegistry.Projects);

            Assert.IsTrue(syncGroupsCount == 0);

            var syncKeywordsCount = syncClient.SyncKeywords(xmlRegistry.Projects);

            Assert.IsTrue(syncKeywordsCount != 0);

            syncKeywordsCount = syncClient.SyncKeywords(xmlRegistry.Projects);

            Assert.IsTrue(syncKeywordsCount == 0);
        }
        public void SyncConsistency()
        {
            var xmlRegistry = SyncTestHelper.GetRegistry();

            var apiProjects = SyncTestHelper.GetProjects();
            var apiKeywords = SyncTestHelper.GetKeywords();

            var client = new MockApiClient();
            client.SetProjects(apiProjects);
            client.SetKeywords(apiKeywords);

            var syncClient = new SyncClient(client);
            syncClient.LoadSyncObjects();

            var syncProjectsCount = syncClient.SyncProjects(xmlRegistry.Projects);

            Assert.IsTrue(syncProjectsCount != 0);

            syncProjectsCount = syncClient.SyncProjects(xmlRegistry.Projects);

            Assert.IsTrue(syncProjectsCount == 0);

            var syncGroupsCount = syncClient.SyncGroups(xmlRegistry.Projects);

            Assert.IsTrue(syncGroupsCount != 0);

            syncGroupsCount = syncClient.SyncGroups(xmlRegistry.Projects);

            Assert.IsTrue(syncGroupsCount == 0);

            var syncKeywordsCount = syncClient.SyncKeywords(xmlRegistry.Projects);

            Assert.IsTrue(syncKeywordsCount != 0);

            syncKeywordsCount = syncClient.SyncKeywords(xmlRegistry.Projects);

            Assert.IsTrue(syncKeywordsCount == 0);
        }