示例#1
0
        public void Setup()
        {
            UnityController.SwapEditorPrefs(new TestData.MockEditorPrefs());
            LoggingController.testing  = true;
            TestableConstants.testcase = true;
            TestableConstants.DefaultRegistryLocation =
                new Uri(Path.GetFullPath(
                            Path.Combine(TestData.PATH, "registry/registry.xml")))
                .AbsoluteUri;

            string testRegXmlPath = TestableConstants.DefaultRegistryLocation;

            mockFetcher.AddResponse((new Uri(testRegXmlPath)).AbsoluteUri,
                                    File.ReadAllText((new Uri(testRegXmlPath)).AbsolutePath),
                                    ResponseCode.FETCH_COMPLETE);
            var rb = new RegistryManagerController.RegistryDatabase();

            rb.registryLocation.Add(TestableConstants.DefaultRegistryLocation);
            UnityController.EditorPrefs.SetString(Constants.KEY_REGISTRIES,
                                                  rb.SerializeToXMLString());

            var u = new Uri(Path.GetFullPath(Path.Combine(TestData.PATH, "registry2/registry.xml")));

            mockFetcher.AddResponse(u.AbsoluteUri,
                                    File.ReadAllText(u.AbsolutePath),
                                    ResponseCode.FETCH_COMPLETE);

            UriDataFetchController.SwapUriDataFetcher(mockFetcher);
            UnityController.SwapEditorPrefs(TestData.editorPrefs);

            var rdb = new RegistryManagerController.RegistryDatabase();

            rdb.registryLocation.Add(TestableConstants.DefaultRegistryLocation);

            /// ISO 8601 format: yyyy-MM-ddTHH:mm:ssZ
            rdb.lastUpdate = DateTime.UtcNow.ToString("o"); // "o" = ISO 8601 formatting
            Console.Write(rdb.SerializeToXMLString());
            TestData.editorPrefs.SetString(Constants.KEY_REGISTRIES, rdb.SerializeToXMLString());
        }