本文整理汇总了C#中IDataContext.Expect方法的典型用法代码示例。如果您正苦于以下问题:C# IDataContext.Expect方法的具体用法?C# IDataContext.Expect怎么用?C# IDataContext.Expect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDataContext
的用法示例。
在下文中一共展示了IDataContext.Expect方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetUp
public void SetUp()
{
_playerRepositoryMock = MockRepository.GenerateMock<IPlayerRepository>();
_dataContextMock = MockRepository.GenerateMock<IDataContext>();
_nemesisRecalculator = new NemesisRecalculator(_dataContextMock, _playerRepositoryMock);
_currentUser = new ApplicationUser();
_minionPlayer = new Player()
{
NemesisId = _existingNemesisId
};
_dataContextMock.Expect(mock => mock.FindById<Player>(_playerId))
.Return(_minionPlayer);
_savedNemesis = new Nemesis() { Id = _newNemesisId };
_dataContextMock.Expect(mock => mock.Save<Nemesis>(Arg<Nemesis>.Is.Anything, Arg<ApplicationUser>.Is.Anything))
.Return(_savedNemesis);
}
示例2: SetUp
public void SetUp()
{
dataContextMock = MockRepository.GenerateMock<IDataContext>();
emailServiceMock = MockRepository.GenerateMock<IIdentityMessageService>();
configurationManagerMock = MockRepository.GenerateMock<IConfigurationManager>();
playerInvitation = new PlayerInvitation
{
CustomEmailMessage = "custom message",
EmailSubject = "email subject",
InvitedPlayerEmail = "player email",
InvitedPlayerId = 1
};
currentUser = new ApplicationUser
{
CurrentGamingGroupId = 15,
UserName = "Fergie Ferg"
};
player = new Player
{
Id = playerInvitation.InvitedPlayerId,
GamingGroupId = 135
};
gamingGroup = new GamingGroup
{
Id = currentUser.CurrentGamingGroupId,
Name = "jake's Gaming Group"
};
gamingGroupInvitation = new GamingGroupInvitation
{
Id = Guid.NewGuid()
};
dataContextMock.Expect(mock => mock.FindById<GamingGroup>(currentUser.CurrentGamingGroupId))
.Return(gamingGroup);
List<ApplicationUser> applicationUsers = new List<ApplicationUser>
{
new ApplicationUser
{
Email = playerInvitation.InvitedPlayerEmail,
Id = existingUserId
}
};
dataContextMock.Expect(mock => mock.GetQueryable<ApplicationUser>())
.Return(applicationUsers.AsQueryable());
dataContextMock.Expect(mock => mock.Save<GamingGroupInvitation>(Arg<GamingGroupInvitation>.Is.Anything, Arg<ApplicationUser>.Is.Anything))
.Return(gamingGroupInvitation);
configurationManagerMock.Expect(mock => mock.AppSettings[PlayerInviter.APP_SETTING_URL_ROOT])
.Return(rootUrl);
emailServiceMock.Expect(mock => mock.SendAsync(Arg<IdentityMessage>.Is.Anything))
.Return(Task.FromResult<object>(null));
playerInviter = new PlayerInviter(dataContextMock, emailServiceMock, configurationManagerMock);
}
示例3: SetUp
public void SetUp()
{
dataContextMock = MockRepository.GenerateMock<IDataContext>();
contextSwitcher = new GamingGroupContextSwitcher(dataContextMock);
currentUser = new ApplicationUser
{
Id = "user id",
CurrentGamingGroupId = 777
};
retrievedUser = new ApplicationUser
{
Id = "user id"
};
userGamingGroups = new List<UserGamingGroup>
{
new UserGamingGroup
{
Id = 1,
ApplicationUserId = currentUser.Id,
GamingGroupId = gamingGroupIdUserCanSee
},
new UserGamingGroup
{
Id = 2,
ApplicationUserId = "some other id the user cant see",
GamingGroupId = gamingGroupIdUserCanSee
}
};
dataContextMock.Expect(mock => mock.GetQueryable<UserGamingGroup>())
.Return(userGamingGroups.AsQueryable());
dataContextMock.Expect(mock => mock.FindById<ApplicationUser>(currentUser.Id))
.Return(retrievedUser);
}
示例4: SetUp
public void SetUp()
{
dataContextMock = MockRepository.GenerateMock<IDataContext>();
championRepositoryMock = MockRepository.GenerateMock<IChampionRepository>();
championRecalculatorPartialMock = MockRepository.GeneratePartialMock<ChampionRecalculator>(dataContextMock,
championRepositoryMock);
List<GameDefinition> allGameDefinitions = new List<GameDefinition>
{
new GameDefinition { Active = true, Id = 1 },
new GameDefinition { Active = true, Id = 2 },
new GameDefinition { Active = false, Id = 3 }
};
allGameDefinitionsQueryable = allGameDefinitions.AsQueryable();
dataContextMock.Expect(mock => mock.GetQueryable<GameDefinition>()).Return(allGameDefinitionsQueryable);
}
示例5: SetUp
public void SetUp()
{
dataContextMock = MockRepository.GenerateMock<IDataContext>();
nemesisHistoryRetriever = new NemesisHistoryRetriever(dataContextMock);
List<Nemesis> nemeses = new List<Nemesis>
{
BuildNemesisItem(nemesisPlayerId1, nemesisPlayerName1, repeatedMinionPlayerId, repeatedMinionPlayerName1, lossPercentage, 0),
BuildNemesisItem(35, "another nemesis player name", repeatedMinionPlayerId, repeatedMinionPlayerName1, 59, 1),
BuildNemesisItem(36, "nemesis3", 515, "minion3", 59, 3),
BuildNemesisItem(37, "nemesis4", 516, "minion4", 100, 2),
BuildNemesisItem(39, "nemesis5", 515116, "minion4", 70, 5)
};
dataContextMock.Expect(mock => mock.GetQueryable<Nemesis>())
.Return(nemeses.AsQueryable());
}
示例6: SetUp
public void SetUp()
{
dataContextMock = MockRepository.GenerateMock<IDataContext>();
playerRepositoryMock = MockRepository.GenerateMock<IPlayerRepository>();
nemesisRecalculatorPartialMock = MockRepository.GeneratePartialMock<NemesisRecalculator>(dataContextMock, playerRepositoryMock);
List<Player> allPlayers = new List<Player>()
{
new Player(){ Active = true, Id = 1 },
new Player(){ Active = true, Id = 2 },
new Player(){ Active = false, Id = 3 }
};
allPlayersQueryable = allPlayers.AsQueryable();
dataContextMock.Expect(mock => mock.GetQueryable<Player>())
.Return(allPlayersQueryable);
}
示例7: SetUp
public void SetUp()
{
dataContextMock = MockRepository.GenerateMock<IDataContext>();
nemesisHistoryRetriever = new NemesisHistoryRetriever(dataContextMock);
List<Nemesis> nemeses = new List<Nemesis>();
nemeses.Add(new Nemesis
{
Id = 4567,
MinionPlayerId = playerIdWithOneNemesisOnly,
MinionPlayer = new Player{ NemesisId = 4567 },
NemesisPlayer = new Player(),
DateCreated = new DateTime(2010, 1, 1)
});
nemeses.Add(new Nemesis
{
MinionPlayerId = playerIdUnderTest,
MinionPlayer = new Player(),
NemesisPlayer = new Player(),
DateCreated = new DateTime(2011, 1, 1)
});
nemeses.Add(new Nemesis
{
MinionPlayerId = playerIdUnderTest,
MinionPlayer = new Player{ Id = playerIdOfPreviousNemesis },
NemesisPlayer = new Player(),
DateCreated = new DateTime(2012, 1, 1)
});
nemeses.Add(new Nemesis
{
Id = 1234,
MinionPlayerId = playerIdUnderTest,
MinionPlayer = new Player { Id = playerIdOfCurrentNemesis, NemesisId = 1234 },
NemesisPlayer = new Player(),
DateCreated = new DateTime(2013, 1, 1)
});
dataContextMock.Expect(mock => mock.GetQueryable<Nemesis>())
.Return(nemeses.AsQueryable());
}
示例8: SetUp
public void SetUp()
{
dataContextMock = MockRepository.GenerateMock<IDataContext>();
nemesisRecalculatorMock = MockRepository.GenerateMock<INemesisRecalculator>();
championRecalculatorMock = MockRepository.GenerateMock<IChampionRecalculator>();
playedGameDeleter = new PlayedGameDeleter(dataContextMock, nemesisRecalculatorMock, championRecalculatorMock);
currentUser = new ApplicationUser();
playedGame = new PlayedGame()
{
GameDefinitionId = gameDefinitionId
};
playerGameResults = new List<PlayerGameResult>()
{
new PlayerGameResult(){ PlayerId = playerInGame1Id, PlayedGameId = playedGameId, PlayedGame = playedGame },
new PlayerGameResult(){ PlayerId = playerInGame2Id, PlayedGameId = playedGameId, PlayedGame = playedGame },
new PlayerGameResult(){ PlayerId = 3, PlayedGameId = playedGameId + 9999, PlayedGame = playedGame }
};
dataContextMock.Expect(mock => mock.GetQueryable<PlayerGameResult>())
.Return(playerGameResults.AsQueryable());
}
示例9: SetUp
public void SetUp()
{
firstTimeUserAuthenticatorMock = MockRepository.GenerateMock<IFirstTimeAuthenticator>();
userStoreMock = MockRepository.GenerateMock<IUserStore<ApplicationUser>>();
var dataProtector = MockRepository.GenerateMock<IDataProtector>();
dataProtectionProviderMock = MockRepository.GenerateMock<IDataProtectionProvider>();
dataProtectionProviderMock.Expect(mock => mock.Create(Arg<string>.Is.Anything)).Return(dataProtector);
applicationUserManagerMock = MockRepository.GenerateMock<ApplicationUserManager>(userStoreMock, dataProtectionProviderMock);
authenticationManagerMock = MockRepository.GenerateMock<IAuthenticationManager>();
signInManagerMock = MockRepository.GenerateMock<ApplicationSignInManager>(applicationUserManagerMock, authenticationManagerMock);
dataContextMock = MockRepository.GenerateMock<IDataContext>();
eventTrackerMock = MockRepository.GenerateMock<INemeStatsEventTracker>();
gamingGroupInviteConsumerMock = MockRepository.GenerateMock<IGamingGroupInviteConsumer>();
userRegisterer = new UserRegisterer(
applicationUserManagerMock,
firstTimeUserAuthenticatorMock,
dataContextMock,
signInManagerMock,
eventTrackerMock,
gamingGroupInviteConsumerMock);
Guid invitationId = Guid.NewGuid();
const int PLAYER_ID = 1938;
GamingGroupInvitation invitation = new GamingGroupInvitation
{
Id = invitationId,
PlayerId = PLAYER_ID,
GamingGroupId = 10
};
newUser = new NewUser()
{
UserName = "user name",
EmailAddress = "the email",
GamingGroupInvitationId = invitationId,
Source = TransactionSource.WebApplication
};
expectedNewlyRegisteredUser = new NewlyRegisteredUser
{
GamingGroupId = invitation.GamingGroupId,
GamingGroupName = "some awesome gaming group name",
PlayerId = PLAYER_ID,
PlayerName = "some awesome player name",
UserId = applicationUserIdAfterSaving
};
IdentityResult result = IdentityResult.Success;
dataContextMock.Expect(mock => mock.FindById<GamingGroupInvitation>(invitationId))
.Return(invitation);
applicationUserManagerMock.Expect(mock => mock.CreateAsync(Arg<ApplicationUser>.Is.Anything, Arg<string>.Is.Anything))
.Return(Task.FromResult(result))
.WhenCalled(invocation => ((ApplicationUser)invocation.Arguments[0]).Id = applicationUserIdAfterSaving);
signInManagerMock.Expect(mock => mock.SignInAsync(
Arg<ApplicationUser>.Is.Anything,
Arg<bool>.Is.Anything,
Arg<bool>.Is.Anything))
.Return(Task.FromResult(-1));
gamingGroupInviteConsumerMock.Expect(mock => mock.AddNewUserToGamingGroup(Arg<string>.Is.Anything, Arg<Guid>.Is.Anything))
.Return(expectedNewlyRegisteredUser);
firstTimeUserAuthenticatorMock.Expect(mock => mock.CreateGamingGroupAndSendEmailConfirmation(
Arg<ApplicationUser>.Is.Anything,
Arg<TransactionSource>.Is.Anything))
.Return(Task.FromResult(expectedNewlyRegisteredUser));
}