コード例 #1
0
        public void GetAll_None_Test()
        {
            string fileName   = DateTime.Now.Ticks.ToString() + ".kpsdb";
            string folderName = DateTime.Now.Ticks.ToString();
            var    provider   = new Provider(fileName, folderName);

            ISyncItemServices services = new SyncItemServices(provider);
            var outputData             = services.GetAll();

            Assert.AreEqual(outputData.Count, 0);
            File.Delete(provider.DbFile);
            Directory.Delete(folderName, true);
        }
コード例 #2
0
        public void Create_All_Test()
        {
            string fileName   = DateTime.Now.Ticks.ToString() + ".kpsdb";
            string folderName = DateTime.Now.Ticks.ToString();
            var    provider   = new Provider(fileName, folderName);

            var sampleData             = CreateDummyData();
            ISyncItemServices services = new SyncItemServices(provider);
            var returnData             = services.CreateSyncItem(sampleData);

            using (var connection = provider.GetConnection())
            {
                connection.Open();
                using (var command = new SqliteCommand(string.Format(
                                                           @"SELECT Id, FileKey, CloudAssetId,
                CloudLastUpdatedDate, CloudCreatedDate, IsDeleted,
                Size FROM {0} WHERE Id={1}", SyncItem.TableName, returnData.Id), connection))
                {
                    var      reader     = command.ExecuteReader();
                    SyncItem outputData = new SyncItem();

                    while (reader.Read())
                    {
                        outputData.Id               = reader.GetInt64(0);
                        outputData.FileKey          = reader.GetString(1);
                        outputData.CloudAssetId     = reader.GetString(2);
                        outputData.CloudLastUpdated = new DateTime(reader.GetInt64(3));
                        outputData.CloudCreated     = new DateTime(reader.GetInt64(4));
                        outputData.IsDeleted        = reader.GetBoolean(5);
                        outputData.Size             = reader.GetInt64(6);
                    }
                    Assert.AreEqual(outputData.Id, returnData.Id);
                    Assert.AreEqual(outputData.FileKey, returnData.FileKey);
                    Assert.AreEqual(outputData.CloudAssetId, returnData.CloudAssetId);
                    Assert.AreEqual(outputData.CloudLastUpdated, returnData.CloudLastUpdated);
                    Assert.AreEqual(outputData.CloudCreated, returnData.CloudCreated);
                    Assert.AreEqual(outputData.IsDeleted, returnData.IsDeleted);
                    Assert.AreEqual(outputData.Size, returnData.Size);
                }
                connection.Close();
            }
            File.Delete(provider.DbFile);
            Directory.Delete(folderName, true);
        }
コード例 #3
0
        public void GetAll_CountGtZero_Test()
        {
            string fileName   = DateTime.Now.Ticks.ToString() + ".kpsdb";
            string folderName = DateTime.Now.Ticks.ToString();
            var    provider   = new Provider(fileName, folderName);

            using (var connection = provider.GetConnection())
            {
                connection.Open();
                using (var command = new SqliteCommand(connection))
                {
                    this.InsertDummyData(CreateDummyData(), command);
                    this.InsertDummyData(CreateDummyData(), command);
                    this.InsertDummyData(CreateDummyData(), command);
                    ISyncItemServices services = new SyncItemServices(provider);
                    var outputData             = services.GetAll();
                    Assert.AreEqual(outputData.Count, 3);
                }
                connection.Close();
            }
            File.Delete(provider.DbFile);
            Directory.Delete(folderName, true);
        }