public virtual void RecordEntry(PointLedgerEntry entry)
 {
     _sqlObjectFactory.GetConnection().Using(connection =>
                                             connection.Command(_sqlObjectFactory, "INSERT INTO pf_PointLedger (UserID, EventDefinitionID, Points, TimeStamp) VALUES (@UserID, @EventDefinitionID, @Points, @TimeStamp)")
                                             .AddParameter(_sqlObjectFactory, "@UserID", entry.UserID)
                                             .AddParameter(_sqlObjectFactory, "@EventDefinitionID", entry.EventDefinitionID)
                                             .AddParameter(_sqlObjectFactory, "@Points", entry.Points)
                                             .AddParameter(_sqlObjectFactory, "@TimeStamp", entry.TimeStamp)
                                             .ExecuteNonQuery());
 }
예제 #2
0
        public void ProcessManualEventPublishesToLedger()
        {
            var          user      = new User(123, DateTime.MinValue);
            const string message   = "msg";
            const int    points    = 252;
            var          publisher = GetPublisher();
            var          entry     = new PointLedgerEntry();

            _pointLedgerRepo.Setup(x => x.RecordEntry(It.IsAny <PointLedgerEntry>())).Callback <PointLedgerEntry>(x => entry = x);
            publisher.ProcessManualEvent(message, user, points);
            Assert.Equal(user.UserID, entry.UserID);
            Assert.Equal("Manual", entry.EventDefinitionID);
            Assert.Equal(points, entry.Points);
        }
예제 #3
0
        public void ProcessEventPublishesToLedger()
        {
            var user     = new User(123, DateTime.MinValue);
            var eventDef = new EventDefinition {
                EventDefinitionID = "blah", PointValue = 42
            };
            const string message   = "msg";
            var          publisher = GetPublisher();

            _eventDefService.Setup(x => x.GetEventDefinition(eventDef.EventDefinitionID)).Returns(eventDef);
            var entry = new PointLedgerEntry();

            _pointLedgerRepo.Setup(x => x.RecordEntry(It.IsAny <PointLedgerEntry>())).Callback <PointLedgerEntry>(x => entry = x);
            publisher.ProcessEvent(message, user, eventDef.EventDefinitionID, false);
            Assert.Equal(user.UserID, entry.UserID);
            Assert.Equal(eventDef.EventDefinitionID, entry.EventDefinitionID);
            Assert.Equal(eventDef.PointValue, entry.Points);
        }
 public virtual async Task RecordEntry(PointLedgerEntry entry)
 {
     await _sqlObjectFactory.GetConnection().UsingAsync(connection =>
                                                        connection.ExecuteAsync("INSERT INTO pf_PointLedger (UserID, EventDefinitionID, Points, TimeStamp) VALUES (@UserID, @EventDefinitionID, @Points, @TimeStamp)", new { entry.UserID, entry.EventDefinitionID, entry.Points, entry.TimeStamp }));
 }