Exemple #1
0
        public void SQLiteRegistryInstantiation_InitializesDbSuccessfully()
        {
            //Arrange
            var(dbFile, path, fileName) = SetupTempDb();

            //Act
            var sqliteReg = new SQLiteRegistry(path, fileName);

            //Assert
            var result = SQLiteDbHelper.Query(dbFile, "SELECT name FROM sqlite_master WHERE type = 'table'");

            Assert.Contains(result, s => s["name"].ToString() == "Sessions");
            Assert.Contains(result, s => s["name"].ToString() == "ReservedPorts");
            var reservedPortsResult = SQLiteDbHelper.Query(dbFile, "SELECT COUNT(*) AS cnt FROM ReservedPorts");

            Assert.Contains(reservedPortsResult, s => (long)(s["cnt"]) > 0);
            Assert.Contains(result, s => s["name"].ToString() == "CurrencyPairs");
            var currencyPairsResult = SQLiteDbHelper.Query(dbFile, "SELECT COUNT(*) AS cnt FROM CurrencyPairs");

            Assert.Contains(currencyPairsResult, s => (long)(s["cnt"]) > 0);

            TearDownTempDb(dbFile);
        }
Exemple #2
0
        private void MarkSessionAsExpired(string dbFile, string accountId, int sessionId, int currencyPairId)
        {
            string expirationDate = DateTime.UtcNow.Subtract(new TimeSpan(0, 0, 11)).ToString("yyyy-MM-dd HH:mm:ss");

            SQLiteDbHelper.NonQueryCommand(dbFile, $"UPDATE Sessions SET lastKeptAlive = '{expirationDate}' WHERE accountId='{accountId}' AND sessionId={sessionId} AND currencyPairId={currencyPairId}");
        }
Exemple #3
0
        private string GetRandomCurrencyPairName(string dbFile)
        {
            var currencyPairs = SQLiteDbHelper.Query(dbFile, "SELECT currencyPairName FROM CurrencyPairs").ToArray();

            return(currencyPairs[new Random().Next(0, currencyPairs.Length - 1)]["currencyPairName"].ToString());
        }