当前位置: 首页>>代码示例>>C#>>正文


C# MockRepository.BackToRecord方法代码示例

本文整理汇总了C#中Rhino.Mocks.MockRepository.BackToRecord方法的典型用法代码示例。如果您正苦于以下问题:C# MockRepository.BackToRecord方法的具体用法?C# MockRepository.BackToRecord怎么用?C# MockRepository.BackToRecord使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Rhino.Mocks.MockRepository的用法示例。


在下文中一共展示了MockRepository.BackToRecord方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Init_Upgrade

        public void Init_Upgrade()
        {
            string testDir = Path.Combine(Environment.GetEnvironmentVariable("TEMP"), Guid.NewGuid().ToString());
            Directory.CreateDirectory(testDir);

            MockRepository mocks = new MockRepository();
            IHostV30 host = mocks.DynamicMock<IHostV30>();
            Expect.Call(host.GetSettingValue(SettingName.PublicDirectory)).Return(testDir).Repeat.AtLeastOnce();

            Expect.Call(host.UpgradePageStatusToAcl(null, 'L')).IgnoreArguments().Repeat.Twice().Return(true);

            mocks.Replay(host);

            string file = Path.Combine(host.GetSettingValue(SettingName.PublicDirectory), "Pages.cs");
            string categoriesFile = Path.Combine(host.GetSettingValue(SettingName.PublicDirectory), "Categories.cs");
            string navPathsFile = Path.Combine(host.GetSettingValue(SettingName.PublicDirectory), "NavigationPaths.cs");
            string directory = Path.Combine(host.GetSettingValue(SettingName.PublicDirectory), "Pages");
            string messagesDirectory = Path.Combine(host.GetSettingValue(SettingName.PublicDirectory), "Messages");
            Directory.CreateDirectory(directory);
            Directory.CreateDirectory(messagesDirectory);

            // Structure (Keywords and Description are new in v3)
            // Page Title
            // Username|DateTime[|Comment] --- Comment is optional
            // ##PAGE##
            // Content...

            File.WriteAllText(Path.Combine(directory, "Page1.cs"), "Title1\r\nSYSTEM|2008/10/30 20:20:20|Comment\r\n##PAGE##\r\nContent...");
            File.WriteAllText(Path.Combine(directory, "Page2.cs"), "Title2\r\nSYSTEM|2008/10/30 20:20:20\r\n##PAGE\r\nContent. [[Page.3]] [Page.3|Link to update].");
            File.WriteAllText(Path.Combine(directory, "Page.3.cs"), "Title3\r\nSYSTEM|2008/10/30 20:20:20|Comment\r\n##PAGE\r\nContent...");

            // ID|Username|Subject|DateTime|ParentID|Body
            File.WriteAllText(Path.Combine(messagesDirectory, "Page.3.cs"), "0|User|Hello|2008/10/30 21:21:21|-1|Blah\r\n");

            // Structure
            // [Namespace.]PageName|PageFile|Status|DateTime
            File.WriteAllText(file, "Page1|Page1.cs|NORMAL|2008/10/30 20:20:20\r\nPage2|Page2.cs|PUBLIC\r\nPage.3|Page.3.cs|LOCKED");

            File.WriteAllText(categoriesFile, "Cat1|Page.3\r\nCat.2|Page1|Page2\r\n");

            File.WriteAllText(navPathsFile, "Path1|Page1|Page.3\r\nPath2|Page2\r\n");

            PagesStorageProvider prov = new PagesStorageProvider();
            prov.Init(host, "");

            PageInfo[] pages = prov.GetPages(null);

            Assert.AreEqual(3, pages.Length, "Wrong page count");
            Assert.AreEqual("Page1", pages[0].FullName, "Wrong name");
            Assert.AreEqual("Page2", pages[1].FullName, "Wrong name");
            Assert.AreEqual("Page_3", pages[2].FullName, "Wrong name");
            //Assert.IsFalse(prov.GetContent(pages[1]).Content.Contains("Page.3"), "Content should not contain 'Page.3'");
            //Assert.IsTrue(prov.GetContent(pages[1]).Content.Contains("Page_3"), "Content should contain 'Page_3'");

            Message[] messages = prov.GetMessages(pages[2]);
            Assert.AreEqual(1, messages.Length, "Wrong message count");
            Assert.AreEqual("Hello", messages[0].Subject, "Wrong subject");

            CategoryInfo[] categories = prov.GetCategories(null);

            Assert.AreEqual(2, categories.Length, "Wrong category count");
            Assert.AreEqual("Cat1", categories[0].FullName, "Wrong name");
            Assert.AreEqual(1, categories[0].Pages.Length, "Wrong page count");
            Assert.AreEqual("Page_3", categories[0].Pages[0], "Wrong page");
            Assert.AreEqual("Cat_2", categories[1].FullName, "Wrong name");
            Assert.AreEqual(2, categories[1].Pages.Length, "Wrong page count");
            Assert.AreEqual("Page1", categories[1].Pages[0], "Wrong page");
            Assert.AreEqual("Page2", categories[1].Pages[1], "Wrong page");

            NavigationPath[] navPaths = prov.GetNavigationPaths(null);

            Assert.AreEqual(2, navPaths.Length, "Wrong nav path count");
            Assert.AreEqual("Path1", navPaths[0].FullName, "Wrong name");
            Assert.AreEqual(2, navPaths[0].Pages.Length, "Wrong page count");
            Assert.AreEqual("Page1", navPaths[0].Pages[0], "Wrong page");
            Assert.AreEqual("Page_3", navPaths[0].Pages[1], "Wrong page");
            Assert.AreEqual(1, navPaths[1].Pages.Length, "Wrong page count");
            Assert.AreEqual("Page2", navPaths[1].Pages[0], "Wrong page");

            mocks.Verify(host);

            // Simulate another startup - upgrade not needed anymore

            mocks.BackToRecord(host);
            Expect.Call(host.GetSettingValue(SettingName.PublicDirectory)).Return(testDir).Repeat.AtLeastOnce();
            Expect.Call(host.UpgradePageStatusToAcl(null, 'L')).IgnoreArguments().Repeat.Times(0).Return(false);

            mocks.Replay(host);

            prov = new PagesStorageProvider();
            prov.Init(host, "");

            mocks.Verify(host);

            Directory.Delete(testDir, true);
        }
开发者ID:mono,项目名称:ScrewTurnWiki,代码行数:96,代码来源:PagesStorageProviderTests.cs


注:本文中的Rhino.Mocks.MockRepository.BackToRecord方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。