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


C# RhinoAutoMocker.Get方法代码示例

本文整理汇总了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);
        }
开发者ID:archnaut,项目名称:sandbox,代码行数:35,代码来源:ApplicationControllerFixtures.cs

示例2: Setup

 public void Setup()
 {
     mocks = new RhinoAutoMocker<Shelve>();
     mocks.Inject<TextWriter>(new StringWriter());
     mocks.Get<Globals>().Repository = mocks.Get<IGitRepository>();
     mocks.MockObjectFactory();
 }
开发者ID:chrisortman,项目名称:git-tfs,代码行数:7,代码来源:ShelveTest.cs

示例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);
        }
开发者ID:NemeStats,项目名称:NemeStats,代码行数:27,代码来源:PlayedGameSaverTestBase.cs

示例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>();
        }
开发者ID:rauhryan,项目名称:kokugen,代码行数:8,代码来源:CardReadyAction_Tester.cs

示例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);
        }
开发者ID:NemeStats,项目名称:NemeStats,代码行数:58,代码来源:GenerateAuthTokenTests.cs

示例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));
 }
开发者ID:inadram,项目名称:TestingApproches,代码行数:9,代码来源:TestMachine.cs

示例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);
 }
开发者ID:pmiossec,项目名称:git-tfs,代码行数:11,代码来源:GlobalsTests.cs

示例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);
 }
开发者ID:pmiossec,项目名称:git-tfs,代码行数:11,代码来源:GlobalsTests.cs

示例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);
        }
开发者ID:NemeStats,项目名称:NemeStats,代码行数:48,代码来源:ValidateAuthTokenTests.cs

示例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);
 }
开发者ID:inadram,项目名称:TestingApproches,代码行数:7,代码来源:TestMachine.cs

示例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);
 }
开发者ID:JenasysDesign,项目名称:git-tfs,代码行数:16,代码来源:GlobalsTests.cs

示例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);

        }
开发者ID:NemeStats,项目名称:NemeStats,代码行数:16,代码来源:RecalculateChampionTests.cs

示例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();
 }
开发者ID:handcraftsman,项目名称:Afluistic,代码行数:16,代码来源:ApplicationSettingsServiceTests.cs

示例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
            };
        }
开发者ID:NemeStats,项目名称:NemeStats,代码行数:30,代码来源:GameDefinitionControllerTestBase.cs


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