public void _Init() { _session.Clear(); new SchemaExport(_configuration).Execute(false, true, false, _session.Connection, null); _identity = new PlayerIdentity(Name, Site); _hand = new ConvertedPokerHand(Site, 1, DateTime.MinValue, 2, 1, 2); }
public void _Init() { _session.Clear(); new SchemaExport(_configuration).Execute(false, true, false, _session.Connection, null); _hand = new ConvertedPokerHand(Site, GameId, _timeStamp, BB, SB, TotalPlayers); _playerIdentity1 = new PlayerIdentity(Name1, Site); _playerIdentity2 = new PlayerIdentity(Name2, Site); }
public void FindOrInsert_PlayerIdentityNotInDatabase_InsertsPlayerIdentityIntoDatabase() { const string someName = "someName"; const string someSite = "PokerStars"; IPlayerIdentity insertedIdentity = _sut.FindOrInsert(someName, someSite); var retrievedIdentity = ClearedSession.Get <PlayerIdentity>(insertedIdentity.Id); retrievedIdentity.ShouldBeEqualTo(insertedIdentity); }
public IPlayerIdentity FindOrInsert(string name, string site) { IPlayerIdentity previouslyStoredPlayerIdentityWithSameNameAndSite = FindPlayerIdentityFor(name, site); if (previouslyStoredPlayerIdentityWithSameNameAndSite != null) { return(previouslyStoredPlayerIdentityWithSameNameAndSite); } return(Insert(new PlayerIdentity(name, site))); }
public void _Init() { _stub = new StubBuilder(); _eventAggregator = new EventAggregator(); _repositoryMock = new Mock <IRepository>(); _playerIdentityStub = _stub.Setup <IPlayerIdentity>() .Get(pi => pi.Id).Returns(Id) .Out; _sut = new PlayerStatisticsSut(_eventAggregator, _repositoryMock.Object); _sut.InitializePlayer(Name, Site); }
public void GetAll_OnePlayerIdentityInDatabase_ReturnsThatPlayerIdentity() { const string someName = "someName"; const string someSite = "PokerStars"; IPlayerIdentity insertedIdentity = _sut.FindOrInsert(someName, someSite); FlushAndClearSession(); var retrievedIdentities = _sut.GetAll(); retrievedIdentities.ShouldContain(insertedIdentity); }
public void FindOrInsert_PlayerIdentityIsInDatabase_AssignsPlayerIdentityIdFromDatabase() { const string someName = "someName"; const string someSite = "PokerStars"; var playerIdentity = new PlayerIdentity(someName, someSite); IPlayerIdentity insertedIdentity = _sut.Insert(playerIdentity); FlushAndClearSession(); IPlayerIdentity samePlayerIdentity = _sut.FindOrInsert(someName, someSite); samePlayerIdentity.Id.ShouldBeEqualTo(insertedIdentity.Id); }
public void FindPlayerIdentityFor_DatabaseContainsName_ReturnsIdentityWithThatNameAndSite() { const string someName = "someName"; const string someSite = "PokerStars"; IPlayerIdentity playerIdentity = new PlayerIdentity(someName, someSite); _session.SaveOrUpdate(playerIdentity); FlushAndClearSession(); IPlayerIdentity returnedIdentity = _sut.FindPlayerIdentityFor(someName, someSite); returnedIdentity.ShouldBeEqualTo(playerIdentity); }
public void GetAll_TwoPlayerIdentitiesInDatabase_ReturnsBothPlayerIdentities() { const string firstName = "firstName"; const string secondName = "secondName"; const string someSite = "PokerStars"; IPlayerIdentity firstInsertedIdentity = _sut.FindOrInsert(firstName, someSite); IPlayerIdentity secondInsertedIdentity = _sut.FindOrInsert(secondName, someSite); FlushAndClearSession(); var retrievedIdentities = _sut.GetAll(); retrievedIdentities .ShouldContain(firstInsertedIdentity) .ShouldContain(secondInsertedIdentity) .ShouldHaveCount(2); }
static IPlayerIdentity Insert(IPlayerIdentity playerIdentity, IStatelessSession statelessSession) { statelessSession.Insert(playerIdentity); return(playerIdentity); }
public IPlayerIdentity Insert(IPlayerIdentity playerIdentity) { Session.SaveOrUpdate(playerIdentity); return(playerIdentity); }
public void FindPlayerIdentityFor_DatabaseEmpty_ReturnsNull() { IPlayerIdentity returnedIdentity = _sut.FindPlayerIdentityFor("someName", "someSite"); returnedIdentity.ShouldBeNull(); }