Exemple #1
0
        public static void Init(TestContext _)
        {
            _localDbFilePaths        = new string[10];
            _sharedFolderDbFilePaths = new string[10];

            for (int i = 0; i < _localDbFilePaths.Length; i++)
            {
                _localDbFilePaths[i]        = Path.Combine(Properties.Resources.Local, $"{nameof(Add_SqliteDB_BasedOnDifferentDataRowCount_LocalVSSharedFolder_Tests)}{i}.litedb");
                _sharedFolderDbFilePaths[i] = Path.Combine(Properties.Resources.Shared, $"{nameof(Add_SqliteDB_BasedOnDifferentDataRowCount_LocalVSSharedFolder_Tests)}{i}.litedb");
            }

            for (int i = 0; i < _localDbFilePaths.Length; i++)
            {
                if (File.Exists(_localDbFilePaths[i]))
                {
                    File.Delete(_localDbFilePaths[i]);
                }
                using var db = new LiteDatabase(_localDbFilePaths[i]);
                var       collection = db.GetCollection <Entity1>();
                Entity1[] dataRows   = new Entity1[5000];
                for (int j = 0; j < i + 1; j++)
                {
                    for (int r = 0; r < dataRows.Length; r++)
                    {
                        dataRows[r] = AddDataRowsHelper.CreateDataRow <Entity1>(j, r);
                    }
                }
                collection.InsertBulk(dataRows);
                File.Copy(_localDbFilePaths[i], _sharedFolderDbFilePaths[i], true);
            }
        }
        public static void Init(TestContext tc)
        {
            CommandFile.SharedFolder   = "A:\\Cmmd";
            _cmmdTolocalDbFilePath     = Path.Combine(Properties.Resources.Local, $"{nameof(Add_SqliteDb_CmmdToSharedFolderToLocalDbVSDirectlyToLocalFolderVSToSharedFolderTest)}_local{NetCoreSqliteDB.SqliteDBContext.DBFileExtensionName}");
            _directlyTolocalDbFilePath = Path.Combine(Properties.Resources.Local, $"{nameof(Add_SqliteDb_CmmdToSharedFolderToLocalDbVSDirectlyToLocalFolderVSToSharedFolderTest)}_directlyToLocal{NetCoreSqliteDB.SqliteDBContext.DBFileExtensionName}");
            _sharedFolderDbFilePath    = Path.Combine(Properties.Resources.Shared, $"{nameof(Add_SqliteDb_CmmdToSharedFolderToLocalDbVSDirectlyToLocalFolderVSToSharedFolderTest)}_sharedFolder{NetCoreSqliteDB.SqliteDBContext.DBFileExtensionName}");

            NetCoreSqliteDB.SqliteDBContext.CopyTempateDBFile(_cmmdTolocalDbFilePath);
            NetCoreSqliteDB.SqliteDBContext.CopyTempateDBFile(_directlyTolocalDbFilePath);
            NetCoreSqliteDB.SqliteDBContext.CopyTempateDBFile(_sharedFolderDbFilePath);

            _cmmdLocalRepository       = new SqliteDBRepository(_cmmdTolocalDbFilePath);
            _directlyToLocalRepository = new SqliteDBRepository(_directlyTolocalDbFilePath);
            _sharedFolderRepository    = new SqliteDBRepository(_sharedFolderDbFilePath);

            _entitiy1000 = new Entity1[1000];
            for (int i = 0; i < 1000; i++)
            {
                _entitiy1000[i] = AddDataRowsHelper.CreateDataRow <Entity1>(0, i);
            }

            _cmmdReceiver = new CommandReceiver(new JsonSer(), _cmmdLocalRepository);
            _cmmdReceiver.Start();

            _cmmdSender = new CommandSender(new JsonSer());
        }
Exemple #3
0
        private static void Add1BatchDataRows(int batchId)
        {
            using var db = new LiteDatabase(_localDbFiles[batchId]);
            var collection = db.GetCollection <Entity1>();

            for (int r = 0; r < 5000; r++)
            {
                var row = AddDataRowsHelper.CreateDataRow <Entity1>(batchId, r);
                collection.Insert(row);
            }
        }
Exemple #4
0
        public void Add100DataRowsToSharedFolderDb(int dbFilePathIndex)
        {
            using var dbContext = new SqliteDBContext(_sharedFolderDbFilePaths[dbFilePathIndex]);
            var dataRows = new Entity1[100];

            for (int i = 0; i < 100; i++)
            {
                dataRows[i] = AddDataRowsHelper.CreateDataRow <Entity1>(dbFilePathIndex, i + 5000);
            }
            dbContext.AddRange(dataRows);
            dbContext.SaveChanges();
            Assert.AreEqual(100, dbContext.Table1.Where(i => i.BatchId == dbFilePathIndex && i.RowNo >= 5000).Count());
        }
Exemple #5
0
        public void Add100DataRowsToSharedFolderDb(int dbFilePathIndex)
        {
            var dbInsert         = new LiteDatabase(_sharedFolderDbFilePaths[dbFilePathIndex]);
            var collectionInsert = dbInsert.GetCollection <Entity1>();
            var dataRows         = new Entity1[100];

            for (int i = 0; i < 100; i++)
            {
                dataRows[i] = AddDataRowsHelper.CreateDataRow <Entity1>(dbFilePathIndex, i + 5000);
            }
            collectionInsert.InsertBulk(dataRows);
            dbInsert.Dispose();

            using var dbRead = new LiteDatabase(_sharedFolderDbFilePaths[dbFilePathIndex]);
            var collectionRead = dbRead.GetCollection <Entity1>();

            Assert.AreEqual(100, collectionRead.Query().Where(i => i.BatchId == dbFilePathIndex && i.RowNo >= 5000).Count());
        }
Exemple #6
0
        public static void Init(TestContext tc)
        {
            CommandFile.SharedFolder = "A:\\Cmmd";
            _localDbFilePath         = Path.Combine(Properties.Resources.Local, $"{nameof(Edit_SqliteDb_CmmdToSharedFolderToLocalDbVSToSharedFolderTest)}{SqliteDBContext.DBFileExtensionName}");
            _sharedFolderDbFilePath  = Path.Combine(Properties.Resources.Shared, $"{nameof(Edit_SqliteDb_CmmdToSharedFolderToLocalDbVSToSharedFolderTest)}{SqliteDBContext.DBFileExtensionName}");

            NetCoreSqliteDB.SqliteDBContext.CopyTempateDBFile(_localDbFilePath);


            _localRepository        = new SqliteDBRepository(_localDbFilePath);
            _sharedFolderRepository = new SqliteDBRepository(_sharedFolderDbFilePath);

            _entitiy1000 = new Entity1[1000];
            for (int i = 0; i < 1000; i++)
            {
                _entitiy1000[i] = AddDataRowsHelper.CreateDataRow <Entity1>(0, i);
            }

            var localDbContext = new NetCoreSqliteDB.SqliteDBContext(_localDbFilePath);

            localDbContext.Table1.AddRange(_entitiy1000);
            localDbContext.SaveChanges();

            File.Copy(_localDbFilePath, _sharedFolderDbFilePath, true);

            foreach (var e in _entitiy1000)
            {
                e.P3 = "Edited";
                e.BasedOnUpdatedDateTime = e.UpdatedDateTime;
                e.UpdatedDateTime        = DateTime.Now;
            }

            _cmmdReceiver = new CommandReceiver(new JsonSer(), _localRepository);
            _cmmdReceiver.Start();

            _cmmdSender = new CommandSender(new JsonSer());
        }