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


C# RhinoAutoMocker.PartialMockTheClassUnderTest方法代码示例

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


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

示例1: SetUp

		public virtual void SetUp()
		{
            AutomapperConfiguration.Configure();
            autoMocker = new RhinoAutoMocker<PlayerController>();
            autoMocker.PartialMockTheClassUnderTest();
            autoMocker.ClassUnderTest.Url = MockRepository.GenerateMock<UrlHelper>();

            currentUser = new ApplicationUser()
			{
				CurrentGamingGroupId = 123,
				Id = "app user id"
			};

			autoMocker.Get<HttpRequestBase>().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(autoMocker.Get<HttpRequestBase>());

			autoMocker.Get<HttpRequestBase>().Expect(mock => mock.Url)
							.Return(new Uri("https://nemestats.com/Details/1"));

			autoMocker.ClassUnderTest.ControllerContext = new ControllerContext(context, new RouteData(), autoMocker.ClassUnderTest);
			autoMocker.Get<IPlayerSummaryBuilder>().Expect(mock => mock.GetTopPlayers(Arg<int>.Is.Anything)).Return(new List<TopPlayer>());
			autoMocker.Get<INemesisHistoryRetriever>().Expect(mock => mock.GetRecentNemesisChanges(Arg<int>.Is.Anything)).Return(new List<NemesisChange>());
			autoMocker.Get<INemesisChangeViewModelBuilder>().Expect(mock => mock.Build(Arg<List<NemesisChange>>.Is.Anything)).Return(new List<NemesisChangeViewModel>());
			autoMocker.ClassUnderTest.Expect(mock => mock.ShowTopPlayers()).Return(new ViewResult { ViewName = MVC.Player.Views.TopPlayers, ViewData = new ViewDataDictionary(expectedTopPlayersViewModel) });
			autoMocker.ClassUnderTest.Expect(mock => mock.ShowRecentNemesisChanges()).Return(new ViewResult { ViewName = MVC.Player.Views.RecentNemesisChanges, ViewData = new ViewDataDictionary(expectedNemesisChangeViewModel) });
		}
开发者ID:NemeStats,项目名称:NemeStats,代码行数:35,代码来源:PlayerControllerTestBase.cs

示例2: 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

示例3: 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

示例4: BaseSetUp

        public void BaseSetUp()
        {
            autoMocker = new RhinoAutoMocker<GameDefinitionSaver>();
            autoMocker.PartialMockTheClassUnderTest();

            currentUser = new ApplicationUser
            {
                Id = "some application user id",
                CurrentGamingGroupId = 100
            };
        }
开发者ID:NemeStats,项目名称:NemeStats,代码行数:11,代码来源:GameDefinitionSaverTestBase.cs

示例5: SetUp

 public virtual void SetUp()
 {
     autoMocker = new RhinoAutoMocker<GamingGroupController>();
     autoMocker.PartialMockTheClassUnderTest();
    
     currentUser = new ApplicationUser()
     {
         Id = "user  id",
         CurrentGamingGroupId = 1315
     };
 }
开发者ID:NemeStats,项目名称:NemeStats,代码行数:11,代码来源:GamingGroupControllerTestBase.cs

示例6: ItFiltersPlayedGamesThatHappenedBeforeTheFromDate

        public void ItFiltersPlayedGamesThatHappenedBeforeTheFromDate()
        {
            var autoMocker = new RhinoAutoMocker<PlayerRetriever>();
            autoMocker.PartialMockTheClassUnderTest();
            var gamingGroupId = 1;
            var fromDate = new DateTime(2015, 6, 1);
            var expectedNemePointsAwardedForEachGame = 50;
            var queryable = new List<Player>
            {
                new Player
                {
                    GamingGroupId = gamingGroupId,
                    PlayerGameResults = new List<PlayerGameResult>
                    {
                        new PlayerGameResult
                        {
                            GameRank = 2,
                            PlayedGame = new PlayedGame
                            {
                                DatePlayed = fromDate.AddDays(-1)
                            },
                            NemeStatsPointsAwarded = expectedNemePointsAwardedForEachGame
                        },
                        new PlayerGameResult
                        {
                            GameRank = 1,
                            PlayedGame = new PlayedGame
                            {
                                DatePlayed = fromDate.AddDays(1)
                            },
                            NemeStatsPointsAwarded = expectedNemePointsAwardedForEachGame
                        },
                        new PlayerGameResult
                        {
                            GameRank = 1,
                            PlayedGame = new PlayedGame
                            {
                                DatePlayed = fromDate.AddDays(-1)
                            },
                            NemeStatsPointsAwarded = expectedNemePointsAwardedForEachGame
                        }
                    },
                    ChampionedGames = new List<Champion>()
                }
            }.AsQueryable();
            autoMocker.Get<IDataContext>().Expect(mock => mock.GetQueryable<Player>())
                .Return(queryable);
            autoMocker.ClassUnderTest.Expect(mock => mock.PopulateNemePointsSummary(Arg<int>.Is.Anything, Arg<List<PlayerWithNemesis>>.Is.Anything, Arg<IDateRangeFilter>.Is.Anything));

            var dateRangeFilter = new BasicDateRangeFilter
            {
                FromDate = fromDate
            };

            var players = autoMocker.ClassUnderTest.GetAllPlayersWithNemesisInfo(gamingGroupId, dateRangeFilter);

            Assert.That(players.Count, Is.EqualTo(1));
            var player = players.First();
            Assert.That(player.GamesLost, Is.EqualTo(0));
            Assert.That(player.GamesWon, Is.EqualTo(1));
        }
开发者ID:NemeStats,项目名称:NemeStats,代码行数:61,代码来源:GetAllPlayersWithNemesisInfoTests.cs

示例7: FixtureSetUp

        public void FixtureSetUp()
        {
            _autoMocker = new RhinoAutoMocker<GameDefinitionDetailsViewModelBuilder>();
            _autoMocker.PartialMockTheClassUnderTest();

            _expectedPlayerSummary1 = new GameDefinitionPlayerSummaryViewModel();
            _expectedPlayerSummary2 = new GameDefinitionPlayerSummaryViewModel();

            List<PlayedGame> playedGames = new List<PlayedGame>();
            playedGames.Add(new PlayedGame
            {
                    Id = 10
                });
            _playedGameDetailsViewModel1 = new PlayedGameDetailsViewModel();
            playedGames.Add(new PlayedGame
            {
                Id = 11
            });
            _playedGameDetailsViewModel2 = new PlayedGameDetailsViewModel();
            _championPlayer = new Player
            {
                Name = _championName,
                Id = _championPlayerId,
                Active = true
            };
            _previousChampionPlayer = new Player
            {
                Name = _previousChampionName,
                Id = _previousChampionPlayerId,
                Active = false
            };
            _champion = new Champion
            {
                Player = _championPlayer,
                WinPercentage = _championWinPercentage,
                NumberOfGames = _championNumberOfGames,
                NumberOfWins = _championNumberOfWins
            };
            _previousChampion = new Champion
            {
                Player = _previousChampionPlayer
            };
            _playerWinRecord1 = new PlayerWinRecord
            {
                GamesWon = 1,
                GamesLost = 2,
                PlayerName = "player name",
                WinPercentage = 33,
                PlayerId = 3
            };
            _playerWinRecord2 = new PlayerWinRecord();

            _autoMocker.Get<ITransformer>().Expect(mock => mock.Transform<GameDefinitionPlayerSummaryViewModel>(_playerWinRecord1))
                       .Return(_expectedPlayerSummary1);
            _autoMocker.Get<ITransformer>().Expect(mock => mock.Transform<GameDefinitionPlayerSummaryViewModel>(_playerWinRecord2))
                 .Return(_expectedPlayerSummary2); 

            _gameDefinitionSummary = new GameDefinitionSummary
            {
                Id = 1,
                Name = "game definition name",
                Description = "game definition description",
                GamingGroupId = _gamingGroupid,
                GamingGroupName = "gaming group name",
                PlayedGames = playedGames,
                TotalNumberOfGamesPlayed = 3,
                AveragePlayersPerGame = 2.2M,
                BoardGameGeekGameDefinitionId = 123,
                BoardGameGeekGameDefinition = new BoardGameGeekGameDefinition() { Id = 123},
                Champion = _champion,
                PreviousChampion = _previousChampion,
                PlayerWinRecords = new List<PlayerWinRecord>
                {
                    _playerWinRecord1,
                    _playerWinRecord2
                },
                BoardGameGeekInfo = new BoardGameGeekInfo()
            };
            _currentUser = new ApplicationUser
            {
                CurrentGamingGroupId = _gamingGroupid
            };
            _autoMocker.Get<IPlayedGameDetailsViewModelBuilder>().Expect(mock => mock.Build(_gameDefinitionSummary.PlayedGames[0], _currentUser, true))
                .Return(_playedGameDetailsViewModel1);
            _autoMocker.Get<IPlayedGameDetailsViewModelBuilder>().Expect(mock => mock.Build(_gameDefinitionSummary.PlayedGames[1], _currentUser, true))
                .Return(_playedGameDetailsViewModel2);

            _expectedBoardGameGeekInfo = new BoardGameGeekInfoViewModel();
            _autoMocker.Get<ITransformer>().Expect(mock => mock.Transform<BoardGameGeekInfoViewModel>(_gameDefinitionSummary.BoardGameGeekInfo))
                .Return(_expectedBoardGameGeekInfo);

            _viewModel = _autoMocker.ClassUnderTest.Build(_gameDefinitionSummary, _currentUser);
        }
开发者ID:NemeStats,项目名称:NemeStats,代码行数:93,代码来源:GameDefinitionDetailsViewModelBuilderTests.cs

示例8: SetUp

        public void SetUp()
        {
            autoMocker = new RhinoAutoMocker<PlayerRetriever>();
            autoMocker.PartialMockTheClassUnderTest();
          
            expectedChampion = new Champion()
            {
                Id = 100,
                PlayerId = 101,
                Player = new Player()
            };
            expectedNemesis = new Nemesis()
            {
                Id = 155,
                NemesisPlayerId = 8888,
                NemesisPlayer = new Player()
            };
            expectedPriorNemesis = new Nemesis()
            {
                Id = 22222,
                NemesisPlayerId = 4444,
                NemesisPlayer = new Player()
            };
            var nemesisForPlayerWithOnlyACurrentNemesis = new Nemesis
            {
                Id = 33333,
                NemesisPlayer = new Player()
            };
            player = new Player()
            {
                Id = 1351,
                Name = "the player",
                PlayerGameResults = new List<PlayerGameResult>(),
                GamingGroup = new GamingGroup{ Id = gamingGroupId },
                GamingGroupId = gamingGroupId,
                Active = true,
                NemesisId = expectedNemesis.Id,
                Nemesis = expectedNemesis,
                PreviousNemesisId = expectedPriorNemesis.Id,
                PreviousNemesis = expectedPriorNemesis
            };
            expectedFormerChampionGame = new GameDefinition
            {
                Id = 111,
                PreviousChampionId = player.Id,
                GamingGroupId = gamingGroupId
            };
            playerWithNoNemesisEver = new Player()
            {
                Id = 161266939,
                GamingGroup = new GamingGroup { Id = gamingGroupId },
                GamingGroupId = gamingGroupId
            };
            playerWithOnlyACurrentNemesis = new Player()
            {
                Id = 888484,
                NemesisId = 7,
                Nemesis = nemesisForPlayerWithOnlyACurrentNemesis,
                GamingGroup = new GamingGroup { Id = gamingGroupId },
                GamingGroupId = gamingGroupId
            };
            playerWithAChampionship = new Player()
            {
                Id = 101,
                GamingGroup = new GamingGroup { Id = gamingGroupId }
            };

            var players = new List<Player>()
            {
                player,
                playerWithNoNemesisEver,
                playerWithOnlyACurrentNemesis,
                playerWithAChampionship
            };

            autoMocker.Get<IDataContext>().Expect(mock => mock.GetQueryable<Player>())
                                               .Return(players.AsQueryable());

            expectedPlayerStatistics = new PlayerStatistics
            {
                NemePointsSummary = new NemePointsSummary(1, 2, 4)
            };

            autoMocker.ClassUnderTest.Expect(repo => repo.GetPlayerStatistics(Arg<int>.Is.Anything))
                .Repeat.Once()
                .Return(expectedPlayerStatistics);

            autoMocker.ClassUnderTest.Expect(mock => mock.GetPlayerGameResultsWithPlayedGameAndGameDefinition(
                Arg<int>.Is.Anything, 
                Arg<int>.Is.Anything))
                            .Repeat.Once()
                            .Return(player.PlayerGameResults.ToList());

            this.expectedMinions = new List<Player>();
            autoMocker.ClassUnderTest.Expect(mock => mock.GetMinions(Arg<int>.Is.Anything))
                .Return(this.expectedMinions);

            expectedPlayerGameSummaries = new List<PlayerGameSummary>
            {
                new PlayerGameSummary()
//.........这里部分代码省略.........
开发者ID:NemeStats,项目名称:NemeStats,代码行数:101,代码来源:GetPlayerDetailsTests.cs

示例9: BaseSetUp

        public virtual void BaseSetUp()
        {
            autoMocker = new RhinoAutoMocker<PlayerRetriever>();
            autoMocker.PartialMockTheClassUnderTest();
            const int CHAMPION_ID = 55;

            gameDefinition = new GameDefinition
            {
                Name = "game name",
                ChampionId = CHAMPION_ID
            };

            var playerId = 1;
            var champion = new Champion
            {
                Id = CHAMPION_ID,
                GameDefinition = gameDefinition,
                PlayerId = playerId
            };

            playerGameResultsForFirstPlayer = new List<PlayerGameResult>()
            {
                new PlayerGameResult
                {
                    GameRank = 2,
                    NemeStatsPointsAwarded = 10,
                    PlayedGame = new PlayedGame
                    {
                        DatePlayed = new BasicDateRangeFilter().FromDate
                    }
                },
                new PlayerGameResult
                {
                    GameRank = 1,
                    NemeStatsPointsAwarded = 20,
                    PlayedGame = new PlayedGame
                    {
                        DatePlayed = new BasicDateRangeFilter().ToDate
                    }
                }};

            playerChampionshipsForFirstPlayer = new List<Champion>
            {
                champion
            };
            List<Player> players = new List<Player>()
            {
                new Player(){ GamingGroupId = gamingGroupId, Name = "2", PlayerGameResults = new List<PlayerGameResult>(), ChampionedGames = new List<Champion>()},
                new Player(){ GamingGroupId = gamingGroupId, Name = "3", PlayerGameResults = new List<PlayerGameResult>(), ChampionedGames = new List<Champion>() },
                new Player(){ GamingGroupId = -1, Name = "not in gaming group", PlayerGameResults = new List<PlayerGameResult>(), ChampionedGames = new List<Champion>() },
                new Player()
                {
                    Id = playerId,
                    GamingGroupId = gamingGroupId, 
                    Name = "1", 
                    PlayerGameResults = playerGameResultsForFirstPlayer,
                    ChampionedGames = new List<Champion>
                    {
                        champion
                    }
                },
                new Player()
                {
                    //player that will be last because she's inactive
                    GamingGroupId = gamingGroupId, Name = "0", PlayerGameResults = new List<PlayerGameResult>(), ChampionedGames = new List<Champion>(), Active = false 
                }
            };
            players[3].NemesisId = 1;
            players[3].Nemesis = new Nemesis()
            {
                NemesisPlayerId = 2,
                NemesisPlayer = new Player() { Id = 93995 }
            };
            playerQueryable = players.AsQueryable<Player>();

            autoMocker.Get<IDataContext>().Expect(mock => mock.GetQueryable<Player>())
                .Return(playerQueryable);

            autoMocker.Get<IDataContext>().Expect(mock => mock.GetQueryable<GameDefinition>())
                .Return(
                new List<GameDefinition>
                { gameDefinition }.AsQueryable());

            var playerAchievement =
                new PlayerAchievement
                {
                    DateCreated = DateTime.UtcNow,
                    LastUpdatedDate = DateTime.UtcNow,
                    PlayerId = playerId,
                    AchievementLevel = AchievementLevel.Bronze,
                    AchievementId = AchievementId.BusyBee
                };
            autoMocker.Get<IDataContext>().Expect(mock => mock.GetQueryable<PlayerAchievement>())
                .Return(new List<PlayerAchievement> { playerAchievement }.AsQueryable());
        }
开发者ID:NemeStats,项目名称:NemeStats,代码行数:95,代码来源:PlayerRetrieverTestBase.cs

示例10: SetUp

 public virtual void SetUp()
 {
     _autoMocker = new RhinoAutoMocker<PointsCalculator>();
     _autoMocker.PartialMockTheClassUnderTest();
 }
开发者ID:NemeStats,项目名称:NemeStats,代码行数:5,代码来源:PointsCalculatorTests.cs


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