本文整理汇总了C#中RhinoAutoMocker.Get方法的典型用法代码示例。如果您正苦于以下问题:C# RhinoAutoMocker.Get方法的具体用法?C# RhinoAutoMocker.Get怎么用?C# RhinoAutoMocker.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RhinoAutoMocker
的用法示例。
在下文中一共展示了RhinoAutoMocker.Get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetUp
public void SetUp()
{
var container = new RhinoAutoMocker<ApplicationController>();
var application = container.Get<IApplication>();
var hotKeySpecification = container.Get<IHotKeySpecification>();
var reportPesenter = container.Get<IReportPresenter>();
var keyboard = container.Get<IKeyboard>();
_presentationController = container.Get<IPresentationController>();
_keyboardEventArgs = new KeyboardEventArgs{Handled = false};
hotKeySpecification
.Stub(spec => spec.IsSatisfiedBy(Arg<IKeyboard>.Is.Anything))
.Return(true);
keyboard
.Stub(x => x.AltPressed)
.Return(true);
keyboard
.Stub(x => x.CtrlPressed)
.Return(true);
keyboard
.Stub(x => x.ShiftPressed)
.Return(true);
keyboard
.Stub(x => x.KeyPressed)
.Return(VirtualKeyCode.VK_T);
var systemUnderTest = container.ClassUnderTest;
keyboard.Raise(x=>x.KeyDown += null, this, _keyboardEventArgs);
}
示例2: Setup
public void Setup()
{
mocks = new RhinoAutoMocker<Shelve>();
mocks.Inject<TextWriter>(new StringWriter());
mocks.Get<Globals>().Repository = mocks.Get<IGitRepository>();
mocks.MockObjectFactory();
}
示例3: TestSetUp
public void TestSetUp()
{
autoMocker = new RhinoAutoMocker<PlayedGameSaver>();
autoMocker.PartialMockTheClassUnderTest();
currentUser = new ApplicationUser
{
Id = "user id",
CurrentGamingGroupId = GAMING_GROUP_ID,
AnonymousClientId = "anonymous client id"
};
gameDefinition = new GameDefinition
{
Name = "game definition name",
GamingGroupId = GAMING_GROUP_ID,
Id = 9598
};
autoMocker.Get<ISecuredEntityValidator>().Expect(mock => mock.RetrieveAndValidateAccess<GameDefinition>(Arg<int>.Is.Anything, Arg<ApplicationUser>.Is.Anything)).Return(gameDefinition);
existingPlayerWithMatchingGamingGroup = new Player
{
Id = 1,
GamingGroupId = GAMING_GROUP_ID
};
autoMocker.Get<IDataContext>().Expect(mock => mock.FindById<Player>(Arg<int>.Is.Anything)).Return(existingPlayerWithMatchingGamingGroup);
}
示例4: SetUp
public void SetUp()
{
_container = new RhinoAutoMocker<EntryPresenter>();
_systemUnderTest = _container.ClassUnderTest;
_entryView = _container.Get<IEntryView>();
_repository = _container.Get<IRepository>();
_recentActivities = _container.Get<IRecentActivities>();
_recentActivities
.Stub(x => x.First)
.Return(ACTIVITY);
_recentActivities
.Stub(x => x.ToArray())
.Return(new[]{ ACTIVITY });
_entryView
.Stub(x => x.Duration)
.Return(DURATION);
_entryView
.Stub(x => x.Activity)
.Return(ACTIVITY);
_entryView.Stub(x => x.Note).Return(NOTE);
_entryView.Raise(x => x.KeyDown += null, this, new KeyEventArgs(Keys.Enter));
}
开发者ID:archnaut,项目名称:sandbox,代码行数:27,代码来源:When_view_is_visible_time_and_task_are_not_null_and_enter_is_pressed.cs
示例5: SetContext
protected override void SetContext()
{
_mocks = new RhinoAutoMocker<CardReadyAction>();
_action = _mocks.ClassUnderTest;
_cardService = _mocks.Get<ICardService>();
_card = _mocks.Get<Kokugen.Core.Domain.Card>();
}
示例6: SetUp
public void SetUp()
{
_autoMocker = new RhinoAutoMocker<AuthTokenGenerator>();
_autoMocker.PartialMockTheClassUnderTest();
IAppSettings appSettingsMock = MockRepository.GenerateMock<IAppSettings>();
appSettingsMock.Expect(mock => mock[AuthTokenGenerator.APP_KEY_AUTH_TOKEN_SALT]).Return(_expectedSalt);
_autoMocker.Get<IConfigurationManager>().Expect(mock => mock.AppSettings).Return(appSettingsMock);
_autoMocker.ClassUnderTest.Expect(mock => mock.GenerateNewAuthToken()).Return(_expectedAuthToken);
_autoMocker.ClassUnderTest.Expect(mock => mock.HashAuthToken(_expectedAuthToken))
.Return(_expectedSaltedHashedAuthToken);
_applicationUser = new ApplicationUser
{
Id = ApplicationUserId
};
_autoMocker.Get<IDataContext>().Expect(mock => mock.FindById<ApplicationUser>(Arg<string>.Is.Anything)).Return(_applicationUser);
_userDeviceAuthTokenWithNoDeviceId = new UserDeviceAuthToken
{
Id = 0,
ApplicationUserId = ApplicationUserId,
DeviceId = null
};
_userDeviceAuthTokenThatDoesntExpire = new UserDeviceAuthToken
{
Id = 1,
ApplicationUserId = ApplicationUserId
};
_userDeviceAuthTokenThatExpiresInTheFuture = new UserDeviceAuthToken
{
Id = 2,
ApplicationUserId = ApplicationUserId,
DeviceId = "device id for future expiration",
AuthenticationTokenExpirationDate = DateTime.UtcNow.AddDays(1)
};
_userDeviceAuthTokenThatExpiresInThePast = new UserDeviceAuthToken
{
Id = 3,
ApplicationUserId = ApplicationUserId,
DeviceId = "device id for already expired",
AuthenticationTokenExpirationDate = DateTime.UtcNow.AddDays(-1)
};
var authTokens = new List<UserDeviceAuthToken>
{
_userDeviceAuthTokenWithNoDeviceId,
_userDeviceAuthTokenThatDoesntExpire,
_userDeviceAuthTokenThatExpiresInTheFuture,
_userDeviceAuthTokenThatExpiresInThePast,
new UserDeviceAuthToken
{
ApplicationUserId = "some other applicationUserId"
}
}.AsQueryable();
_autoMocker.Get<IDataContext>().Expect(mock => mock.GetQueryable<UserDeviceAuthToken>()).Return(authTokens);
}
示例7: Given_device_when_TheStockIsNotOutOfOrder_then_AddMethodShouldCalled
public void Given_device_when_TheStockIsNotOutOfOrder_then_AddMethodShouldCalled()
{
var autoMocker = new RhinoAutoMocker<Machine>();
var device = new Device { ID = 1, Name = "printer" };
var product = autoMocker.Get<Iproduct>();
product.Stub(x => x.IsOutOfStock(Arg<Device>.Is.Anything)).Return(false);
autoMocker.ClassUnderTest.RegisterNewDevice(device);
autoMocker.Get<IDeviceManager>().AssertWasCalled(x => x.Add(device));
}
示例8: WhenNoRemotesFoundInParentCommits_AndThereIsOnlyOneRemoteInRepository_ThenThrowAnException
public void WhenNoRemotesFoundInParentCommits_AndThereIsOnlyOneRemoteInRepository_ThenThrowAnException()
{
var mocker = new RhinoAutoMocker<IGitRepository>();
var gitRepoMock = mocker.Get<IGitRepository>();
var globals = new Globals() { Bootstrapper = null, Repository = gitRepoMock };
globals.Repository.Stub(r => r.GetLastParentTfsCommits("HEAD"))
.Return(new List<TfsChangesetInfo>());
globals.Repository.Stub(r => r.ReadAllTfsRemotes())
.Return(new List<GitTfsRemote>() { new GitTfsRemote(new RemoteInfo() { Id = "myRemote" }, gitRepoMock, new RemoteOptions(), globals, mocker.Get<ITfsHelper>(), new ConfigProperties(null)) });
Assert.Throws(typeof(GitTfsException), () => globals.RemoteId);
}
示例9: Globals
public void WhenNoRemotesFoundInParentCommits_ThereIsOnlyOneRemoteInRepository_AndThisIsTheDefaultOne_ThenReturnIt()
{
var mocker = new RhinoAutoMocker<IGitRepository>();
var gitRepoMock = mocker.Get<IGitRepository>();
var globals = new Globals() { Bootstrapper = null, Repository = gitRepoMock };
globals.Repository.Stub(r => r.GetLastParentTfsCommits("HEAD"))
.Return(new List<TfsChangesetInfo>());
globals.Repository.Stub(r => r.ReadAllTfsRemotes())
.Return(new List<GitTfsRemote>() { new GitTfsRemote(new RemoteInfo() { Id = "default" }, gitRepoMock, new RemoteOptions(), globals, mocker.Get<ITfsHelper>(), new ConfigProperties(null)) });
Assert.Equal("default", globals.RemoteId);
}
示例10: SetUp
public void SetUp()
{
autoMocker = new RhinoAutoMocker<AuthTokenValidator>();
const string EXPECTED_HASHED_AND_SALTED_AUTH_TOKEN = "some hashed and salted auth token";
autoMocker.Get<IAuthTokenGenerator>().Expect(mock => mock.HashAuthToken(this.validAuthToken)).Return(
EXPECTED_HASHED_AND_SALTED_AUTH_TOKEN);
_expectedUserDeviceAuthTokenThatIsntExpired = new UserDeviceAuthToken()
{
AuthenticationToken = EXPECTED_HASHED_AND_SALTED_AUTH_TOKEN,
AuthenticationTokenExpirationDate = DateTime.UtcNow.AddDays(3)
};
_applicationUserWithValidAuthToken = new ApplicationUser
{
UserDeviceAuthTokens = new List<UserDeviceAuthToken>
{
_expectedUserDeviceAuthTokenThatIsntExpired
}
};
const string EXPECTED_HASHED_AND_SALTED_AUTH_TOKEN_THAT_IS_EXPIRED = "some hashed and salted auth token that is expired";
autoMocker.Get<IAuthTokenGenerator>().Expect(mock => mock.HashAuthToken(this.expiredAuthToken)).Return(
EXPECTED_HASHED_AND_SALTED_AUTH_TOKEN_THAT_IS_EXPIRED);
_expectedUserDeviceAuthTokenThatIsExpired = new UserDeviceAuthToken()
{
AuthenticationToken = EXPECTED_HASHED_AND_SALTED_AUTH_TOKEN,
AuthenticationTokenExpirationDate = DateTime.UtcNow.AddDays(-1)
};
var applicationUserWithExpiredAuthToken = new ApplicationUser
{
UserDeviceAuthTokens = new List<UserDeviceAuthToken>
{
_expectedUserDeviceAuthTokenThatIsExpired
}
};
var applicationUsersQueryable = new List<ApplicationUser>
{
_applicationUserWithValidAuthToken,
applicationUserWithExpiredAuthToken
}.AsQueryable();
autoMocker.Get<IDataContext>().Expect(mock => mock.GetQueryable<ApplicationUser>()).Return(applicationUsersQueryable);
}
示例11: Given_device_when_RegisterNewDevice_then_AddedSucessfullyShouldSetToTrue
public void Given_device_when_RegisterNewDevice_then_AddedSucessfullyShouldSetToTrue()
{
var autoMocker=new RhinoAutoMocker<Machine>();
var device=new Device {ID=1,Name = "printer"};
autoMocker.ClassUnderTest.RegisterNewDevice(device);
autoMocker.Get<IDeviceManager>().AssertWasCalled(x => x.AddedSucessfully = true);
}
示例12: WhenOnlyOneRemoteFoundInParentCommits_ThenReturnIt
public void WhenOnlyOneRemoteFoundInParentCommits_ThenReturnIt()
{
var mocker = new RhinoAutoMocker<IGitRepository>();
var gitRepoMock = mocker.Get<IGitRepository>();
var globals = new Globals() { Bootstrapper = null, Stdout = new StringWriter(), Repository = gitRepoMock };
globals.Repository.Stub(r => r.GetLastParentTfsCommits("HEAD"))
.Return(new List<TfsChangesetInfo>()
{
new TfsChangesetInfo()
{
ChangesetId = 34,
Remote = new GitTfsRemote(new RemoteInfo() {Id = "myRemote"}, gitRepoMock, new RemoteOptions(), globals, mocker.Get<ITfsHelper>(), new StringWriter())
}
});
Assert.Equal("myRemote", globals.RemoteId);
}
示例13: SetUp
public void SetUp()
{
_autoMocker = new RhinoAutoMocker<ChampionRecalculator>();
_applicationUser = new ApplicationUser();
_gameDefinition = new GameDefinition
{
ChampionId = _previousChampionId
};
_autoMocker.Get<IDataContext>().Expect(mock => mock.FindById<GameDefinition>(_gameDefinitionId))
.Return(_gameDefinition);
_savedChampion = new Champion { Id = _newChampionId };
_autoMocker.Get<IDataContext>().Expect(mock => mock.Save(Arg<Champion>.Is.Anything, Arg<ApplicationUser>.Is.Anything))
.Return(_savedChampion);
}
示例14: Before_first_test
public void Before_first_test()
{
var mocker = new RhinoAutoMocker<ApplicationSettingsService>();
mocker.Get<ISystemService>()
.Expect(x => x.AppDataDirectory)
.Return(@"x:\temp");
_applicationSettings = new ApplicationSettings();
mocker.Get<ISerializationService>()
.Expect(x => x.DeserializeFromFile<ApplicationSettings>(Arg<string>.Is.NotNull))
.Return(new Notification<ApplicationSettings>
{
Item = _applicationSettings
})
.Repeat.Any();
_result = mocker.ClassUnderTest.Load();
}
示例15: SetUp
public virtual void SetUp()
{
autoMocker = new RhinoAutoMocker<GameDefinitionController>();
autoMocker.Get<IGameDefinitionRetriever>()
.Expect(mock => mock.GetTrendingGames(GameDefinitionController.NUMBER_OF_TRENDING_GAMES_TO_SHOW,
GameDefinitionController.NUMBER_OF_DAYS_OF_TRENDING_GAMES))
.Return(trendingGames);
AutomapperConfiguration.Configure();
urlHelperMock = MockRepository.GenerateMock<UrlHelper>();
autoMocker.ClassUnderTest.Url = urlHelperMock;
asyncRequestMock = MockRepository.GenerateMock<HttpRequestBase>();
asyncRequestMock.Expect(x => x.Headers)
.Repeat.Any()
.Return(new System.Net.WebHeaderCollection
{
{ "X-Requested-With", "XMLHttpRequest" }
});
var context = MockRepository.GenerateMock<HttpContextBase>();
context.Expect(x => x.Request)
.Repeat.Any()
.Return(asyncRequestMock);
autoMocker.ClassUnderTest.ControllerContext = new ControllerContext(context, new RouteData(), autoMocker.ClassUnderTest);
currentUser = new ApplicationUser()
{
Id = "user id",
CurrentGamingGroupId = 15151
};
}