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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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)));
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
        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);
        }
예제 #9
0
        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);
        }
예제 #10
0
 static IPlayerIdentity Insert(IPlayerIdentity playerIdentity, IStatelessSession statelessSession)
 {
     statelessSession.Insert(playerIdentity);
     return(playerIdentity);
 }
예제 #11
0
 public IPlayerIdentity Insert(IPlayerIdentity playerIdentity)
 {
     Session.SaveOrUpdate(playerIdentity);
     return(playerIdentity);
 }
예제 #12
0
        public void FindPlayerIdentityFor_DatabaseEmpty_ReturnsNull()
        {
            IPlayerIdentity returnedIdentity = _sut.FindPlayerIdentityFor("someName", "someSite");

            returnedIdentity.ShouldBeNull();
        }