本文整理汇总了C#中Rhino.Mocks.MockRepository.Replay方法的典型用法代码示例。如果您正苦于以下问题:C# MockRepository.Replay方法的具体用法?C# MockRepository.Replay怎么用?C# MockRepository.Replay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rhino.Mocks.MockRepository
的用法示例。
在下文中一共展示了MockRepository.Replay方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RetrieveDenialsForDirectory_Root_Group
public void RetrieveDenialsForDirectory_Root_Group()
{
MockRepository mocks = new MockRepository();
ISettingsStorageProviderV30 prov = mocks.DynamicMock<ISettingsStorageProviderV30>();
IFilesStorageProviderV30 filesProv = mocks.DynamicMock<IFilesStorageProviderV30>();
IAclManager aclManager = mocks.DynamicMock<IAclManager>();
Expect.Call(prov.AclManager).Return(aclManager).Repeat.Any();
string dirName = Actions.ForDirectories.ResourceMasterPrefix + AuthTools.GetDirectoryName(filesProv, "/");
Expect.Call(aclManager.RetrieveEntriesForSubject("G.Group")).Return(
new AclEntry[] {
new AclEntry(dirName, Actions.ForDirectories.List, "G.Group", Value.Deny),
new AclEntry(dirName, Actions.FullControl, "G.Group", Value.Grant),
new AclEntry("D." + AuthTools.GetDirectoryName(filesProv, "/Other/"), Actions.ForDirectories.UploadFiles, "G.Group", Value.Deny)
});
mocks.Replay(prov);
mocks.Replay(aclManager);
Collectors.SettingsProvider = prov;
string[] grants = AuthReader.RetrieveDenialsForDirectory(new UserGroup("Group", "Group", null),
filesProv, "/");
Assert.AreEqual(1, grants.Length, "Wrong denial count");
Assert.AreEqual(Actions.ForDirectories.List, grants[0], "Wrong denial");
}
示例2: CreateMockOrderDao
public IOrderDao CreateMockOrderDao() {
MockRepository mocks = new MockRepository();
IOrderDao mockedOrderDao = mocks.CreateMock<IOrderDao>();
Expect.Call(mockedOrderDao.GetByExample(null)).IgnoreArguments()
.Return(new TestOrdersFactory().CreateOrders());
mocks.Replay(mockedOrderDao);
return mockedOrderDao;
}
示例3: ClearEntriesForDirectory
public void ClearEntriesForDirectory()
{
MockRepository mocks = new MockRepository();
ISettingsStorageProviderV30 prov = mocks.DynamicMock<ISettingsStorageProviderV30>();
IFilesStorageProviderV30 filesProv = mocks.DynamicMock<IFilesStorageProviderV30>();
IAclManager aclManager = mocks.DynamicMock<IAclManager>();
Expect.Call(prov.AclManager).Return(aclManager).Repeat.Any();
string dirName = Actions.ForDirectories.ResourceMasterPrefix + AuthTools.GetDirectoryName(filesProv, "/Dir/Sub/");
Expect.Call(aclManager.DeleteEntriesForResource(dirName)).Return(true);
mocks.Replay(prov);
mocks.Replay(aclManager);
Collectors.SettingsProvider = prov;
AuthWriter.ClearEntriesForDirectory(filesProv, "/Dir/Sub/");
mocks.Verify(prov);
mocks.Verify(aclManager);
}
示例4: CreateMockNewsRepository
//[Test]
//public void CanListAllNews()
//{
// var controller = new NewsController(CreateMockNewsRepository());
// var result = controller.Index(1)
// .AssertViewRendered()
// .ForView("Index");
// Assert.That(result.ViewData, Is.Not.Null);
// Assert.That(result.ViewData.Model as List<News>, Is.Not.Null);
// Assert.That((result.ViewData.Model as List<News>).Count, Is.EqualTo(2));
//}
public IRepository<News> CreateMockNewsRepository()
{
var mocks = new MockRepository();
var mockedRepository = mocks.StrictMock<IRepository<News>>();
Expect.Call(mockedRepository.GetAll())
.IgnoreArguments()
.Return(createNews());
mocks.Replay(mockedRepository);
return mockedRepository;
}
示例5: CreateMockStaffMemberRepository
/// <summary>
/// In most cases, we'd simply return
/// IRepository<MyEntity>, but since we're
/// leveraging a custom Repository method, we need a
/// custom Repository interface.
/// </summary>
public IStaffMemberRepository CreateMockStaffMemberRepository()
{
MockRepository mocks = new MockRepository();
IStaffMemberRepository mockedRepository = mocks.StrictMock<IStaffMemberRepository>();
Expect.Call(mockedRepository.FindAllMatching(null))
.IgnoreArguments()
.Return(CreateStaffMembers());
mocks.Replay(mockedRepository);
return mockedRepository;
}
示例6: ClearEntriesForNamespace
public void ClearEntriesForNamespace()
{
MockRepository mocks = new MockRepository();
ISettingsStorageProviderV30 prov = mocks.DynamicMock<ISettingsStorageProviderV30>();
IAclManager aclManager = mocks.DynamicMock<IAclManager>();
Expect.Call(prov.AclManager).Return(aclManager).Repeat.Any();
Expect.Call(aclManager.DeleteEntriesForResource(Actions.ForNamespaces.ResourceMasterPrefix + "NS")).Return(true);
Expect.Call(aclManager.DeleteEntriesForResource(Actions.ForPages.ResourceMasterPrefix + "NS.Page1")).Return(true);
Expect.Call(aclManager.DeleteEntriesForResource(Actions.ForPages.ResourceMasterPrefix + "NS.Page2")).Return(true);
Expect.Call(aclManager.DeleteEntriesForResource(Actions.ForPages.ResourceMasterPrefix + "NS.Page3")).Return(true);
mocks.Replay(prov);
mocks.Replay(aclManager);
Collectors.SettingsProvider = prov;
AuthWriter.ClearEntriesForNamespace("NS", new List<string>() { "Page1", "Page2", "Page3" });
mocks.Verify(prov);
mocks.Verify(aclManager);
}
示例7: CreateMockIBlogTask
/// </summary>
public IBlogTasks CreateMockIBlogTask()
{
MockRepository mocks = new MockRepository();
IBlogTasks mockedRepository =
mocks.StrictMock<IBlogTasks>();
Blog mockBlog = MockRepository.GenerateStub<Blog>();
mockBlog.Stub(x => x.Id).Return(1);
Expect.Call(mockedRepository.Posts())
.IgnoreArguments()
.Return(CreatePosts(mockBlog));
mocks.Replay(mockedRepository);
return mockedRepository;
}
示例8: SetUp
public void SetUp()
{
_mocks = new MockRepository();
var httpContext = new TestHttpContext();
var requestContext = new RequestContext(httpContext, new RouteData());
var controller = _mocks.StrictMock<ControllerBase>();
_mocks.Replay(controller);
var viewEngine = new BooViewEngine
{
ViewSourceLoader = new FileSystemViewSourceLoader(VIEW_ROOT_DIRECTORY),
Options = new BooViewEngineOptions()
};
viewEngine.Initialize();
_viewEngine = new BrailViewFactory(viewEngine);
_mocks.ReplayAll();
}
示例9: 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.GetSettingValue(SettingName.AdministratorsGroup)).Return("Administrators").Repeat.Once();
Expect.Call(host.GetSettingValue(SettingName.UsersGroup)).Return("Users").Repeat.Once();
Expect.Call(host.UpgradeSecurityFlagsToGroupsAcl(null, null)).IgnoreArguments().Repeat.Times(1).Return(true);
mocks.Replay(host);
string file = Path.Combine(host.GetSettingValue(SettingName.PublicDirectory), "Users.cs");
File.WriteAllText(file, "user|PASSHASH|[email protected]|Inactive|2008/10/31 15:15:15|USER\r\nsuperuser|SUPERPASSHASH|[email protected]|Active|2008/10/31 15:15:16|ADMIN");
UsersStorageProvider prov = new UsersStorageProvider();
prov.Init(host, "");
UserInfo[] users = prov.GetUsers();
Assert.AreEqual(2, users.Length, "Wrong user count");
Assert.AreEqual("superuser", users[0].Username, "Wrong username");
Assert.AreEqual("[email protected]", users[0].Email, "Wrong email");
Assert.IsTrue(users[0].Active, "User should be active");
Assert.AreEqual("2008/10/31 15:15:16", users[0].DateTime.ToString("yyyy'/'MM'/'dd' 'HH':'mm':'ss"), "Wrong date/time");
Assert.AreEqual(1, users[0].Groups.Length, "Wrong user count");
Assert.AreEqual("Administrators", users[0].Groups[0], "Wrong group");
Assert.AreEqual("user", users[1].Username, "Wrong username");
Assert.AreEqual("[email protected]", users[1].Email, "Wrong email");
Assert.IsFalse(users[1].Active, "User should be inactive");
Assert.AreEqual("2008/10/31 15:15:15", users[1].DateTime.ToString("yyyy'/'MM'/'dd' 'HH':'mm':'ss"), "Wrong date/time");
Assert.AreEqual(1, users[1].Groups.Length, "Wrong user count");
Assert.AreEqual("Users", users[1].Groups[0], "Wrong group");
mocks.Verify(host);
Directory.Delete(testDir, true);
}
示例10: SetUp
public virtual void SetUp()
{
HttpMethodToReturn = "GET";
EcmaScriptVersionToReturn = new Version(1, 1);
mockRepository = new MockRepository();
HttpContext = mockRepository.DynamicHttpContextBase();
SetupResult.For(Request.UserHostAddress).Return("::1");
SetupResult.For(Request.UserHostName).Return("::1");
SetupResult.For(Request.RequestType).Do(new Func<string>(() => HttpMethodToReturn)); //.Return("GET");
SetupResult.For(Request.HttpMethod).Do(new Func<string>(() => HttpMethodToReturn));
SetupResult.For(Request.PhysicalApplicationPath).Return("http://testing/mycontroller/test");
SetupResult.For(Request.Url).Return(new Uri("http://testing/mycontroller/test"));
mockRepository.Replay(Request);
SetupResult.For(Request.Browser.EcmaScriptVersion).Do(new Func<Version>(() => EcmaScriptVersionToReturn));
SetupResult.For(Request.Browser.Browser).Return("Firefox 2.0.11");
SetupResult.For(HttpContext.User.Identity).Return(new MockIdentity {Name = string.Empty});
mockRepository.ReplayAll();
}
示例11: SetUp
public void SetUp()
{
mocks = new MockRepository();
ISettingsStorageProviderV30 settingsProvider = mocks.StrictMock<ISettingsStorageProviderV30>();
Expect.Call(settingsProvider.GetSetting("ProcessSingleLineBreaks")).Return("true").Repeat.Any();
Collectors.SettingsProvider = settingsProvider;
mocks.Replay(settingsProvider);
}
示例12: RemoveEntriesForNamespace_Group_Sub
public void RemoveEntriesForNamespace_Group_Sub()
{
MockRepository mocks = new MockRepository();
ISettingsStorageProviderV30 prov = mocks.DynamicMock<ISettingsStorageProviderV30>();
IAclManager aclManager = mocks.DynamicMock<IAclManager>();
Expect.Call(prov.AclManager).Return(aclManager).Repeat.Any();
Expect.Call(aclManager.RetrieveEntriesForSubject("G.Group")).Return(
new AclEntry[] {
new AclEntry(Actions.ForNamespaces.ResourceMasterPrefix + "Sub", Actions.ForNamespaces.ManagePages, "G.Group", Value.Grant),
new AclEntry(Actions.ForNamespaces.ResourceMasterPrefix + "Sub", Actions.ForNamespaces.ManageCategories, "G.Group", Value.Grant),
new AclEntry(Actions.ForNamespaces.ResourceMasterPrefix, Actions.ForNamespaces.ModifyPages, "G.Group", Value.Grant),
new AclEntry(Actions.ForGlobals.ResourceMasterPrefix, Actions.ForGlobals.ManageNavigationPaths, "G.Group", Value.Grant) });
Expect.Call(aclManager.DeleteEntry(Actions.ForNamespaces.ResourceMasterPrefix + "Sub",
Actions.ForNamespaces.ManagePages, "G.Group")).Return(true);
Expect.Call(aclManager.DeleteEntry(Actions.ForNamespaces.ResourceMasterPrefix + "Sub",
Actions.ForNamespaces.ManageCategories, "G.Group")).Return(true);
mocks.Replay(prov);
mocks.Replay(aclManager);
Collectors.SettingsProvider = prov;
Assert.IsTrue(AuthWriter.RemoveEntriesForNamespace(new UserGroup("Group", "Group", null), new NamespaceInfo("Sub", null, null)), "RemoveEntriesForNamespace should return true");
mocks.Verify(prov);
mocks.Verify(aclManager);
}
示例13: RemoveEntriesForDirectory_Sub_User
public void RemoveEntriesForDirectory_Sub_User()
{
MockRepository mocks = new MockRepository();
ISettingsStorageProviderV30 prov = mocks.DynamicMock<ISettingsStorageProviderV30>();
IFilesStorageProviderV30 filesProv = mocks.DynamicMock<IFilesStorageProviderV30>();
IAclManager aclManager = mocks.DynamicMock<IAclManager>();
Expect.Call(prov.AclManager).Return(aclManager).Repeat.Any();
string dirName = Actions.ForDirectories.ResourceMasterPrefix + AuthTools.GetDirectoryName(filesProv, "/Dir/Sub/");
Expect.Call(aclManager.RetrieveEntriesForSubject("U.User")).Return(
new AclEntry[] {
new AclEntry(dirName, Actions.ForDirectories.List, "U.User", Value.Grant),
new AclEntry(dirName, Actions.ForDirectories.UploadFiles, "U.User", Value.Deny),
new AclEntry("D." + AuthTools.GetDirectoryName(filesProv, "/"), Actions.ForDirectories.UploadFiles, "U.User", Value.Grant),
new AclEntry(Actions.ForGlobals.ResourceMasterPrefix, Actions.ForGlobals.ManageNavigationPaths, "U.User", Value.Grant) });
Expect.Call(aclManager.DeleteEntry(dirName, Actions.ForDirectories.List, "U.User")).Return(true);
Expect.Call(aclManager.DeleteEntry(dirName, Actions.ForDirectories.UploadFiles, "U.User")).Return(true);
mocks.Replay(prov);
mocks.Replay(aclManager);
Collectors.SettingsProvider = prov;
Assert.IsTrue(AuthWriter.RemoveEntriesForDirectory(new UserInfo("User", "User", "[email protected]", true, DateTime.Now, null),
filesProv, "/Dir/Sub/"), "RemoveEntriesForPage should return true");
mocks.Verify(prov);
mocks.Verify(aclManager);
}
示例14: 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);
}
示例15: SetPermissionForDirectory_User_Grant
public void SetPermissionForDirectory_User_Grant()
{
MockRepository mocks = new MockRepository();
ISettingsStorageProviderV30 prov = mocks.DynamicMock<ISettingsStorageProviderV30>();
IFilesStorageProviderV30 filesProv = mocks.DynamicMock<IFilesStorageProviderV30>();
IAclManager aclManager = mocks.DynamicMock<IAclManager>();
Expect.Call(prov.AclManager).Return(aclManager).Repeat.Any();
Expect.Call(aclManager.StoreEntry(
Actions.ForDirectories.ResourceMasterPrefix + AuthTools.GetDirectoryName(filesProv, "/"),
Actions.ForDirectories.DownloadFiles, "U.User", Value.Grant)).Return(true);
mocks.Replay(prov);
mocks.Replay(aclManager);
Collectors.SettingsProvider = prov;
Assert.IsTrue(AuthWriter.SetPermissionForDirectory(AuthStatus.Grant, filesProv, "/", Actions.ForDirectories.DownloadFiles,
new UserInfo("User", "User", "[email protected]", true, DateTime.Now, null)),
"SetPermissionForDirectory should return true");
mocks.Verify(prov);
mocks.Verify(aclManager);
}