public void TestInitialize() { base.Setup(); // Instanciate the manager only 1 time if (CouchBaseLiteLiteManager == null) { CouchBaseLiteLiteManager = Mvx.Resolve <ICouchBaseLite>(); } // Add Sqlite plugin register. Do it only for unit tests (https://github.com/CouchBaseLite/CouchBaseLite-lite-net/wiki/Error-Dictionary#cblcs0001) //CouchBaseLite.Lite.Storage.SystemSQLite.Plugin.Register(); entityRepo = new CouchBaseLiteRepository <TestEntity>(CouchBaseLiteLiteManager, dbName); entityRepo2 = new CouchBaseLiteRepository <TestEntity>(CouchBaseLiteLiteManager, dbName); collectionEntityRepo = new CouchBaseLiteRepository <CollectionTest>(CouchBaseLiteLiteManager, dbName); entityExtraEltRepo = new CouchBaseLiteRepository <TestExtraEltEntity>(CouchBaseLiteLiteManager, dbName); // Define mapping for polymorphism entityRepo.PolymorphicTypes["TestExtraEltEntity"] = typeof(TestExtraEltEntity); entityRepo2.PolymorphicTypes["TestExtraEltEntity"] = typeof(TestExtraEltEntity); test = new NoSQLCoreUnitTests(entityRepo, entityRepo2, entityExtraEltRepo, collectionEntityRepo, NoSQLCoreUnitTests.testContext.DeploymentDirectory, dbName); }
private void MvvX_CBLite_CreateViews(CouchBaseLiteRepository <TestEntity> entityRepo) { entityRepo.CreateView <int>(nameof(TestEntity.NumberOfChildenInt), "1"); entityRepo.CreateView <string>(nameof(TestEntity.Cities), "1"); // Ensure that if we create a view two time that doen't raise an exception entityRepo.CreateView <int>(nameof(TestEntity.NumberOfChildenInt), "1"); }
public bool ConnectCBDatabase() { var couchBaseLite = Mvx.Resolve <ICouchBaseLite>(); couchBaseLite.Initialize(ConnectionUrl); var repo = new CouchBaseLiteRepository <Log>(couchBaseLite, DatabaseName); Mvx.Resolve <ILogFetcher>().LoadRepo(repo); Mvx.Resolve <IMvxMessenger>().Publish <UpdateLogListMessage>(new UpdateLogListMessage(this, null)); return(true); }
public void MvvX_CBLite_ExistingViewTests() { testContext.DeployDirectory(@"Ressources\nosqltestcbldb.cblite2", @"ExistingRepo\nosqltestcbldb.cblite2"); var existingRepoManager = new CouchBaseLite(); existingRepoManager.Initialize(Path.Combine(NoSQLCoreUnitTests.testContext.DeploymentDirectory, "ExistingRepo")); entityRepo = new CouchBaseLiteRepository <TestEntity>(existingRepoManager, dbName); MvvX_CBLite_CreateViews(entityRepo); var res3 = entityRepo.GetAll(); Assert.AreEqual(4, res3.Count, "Existing view TestEntity contains 5 docs"); var res1 = entityRepo.GetByField <int>(nameof(TestEntity.NumberOfChildenInt), 0); Assert.AreEqual(2, res1.Count, "Existing view TestEntity-NumberOfChildenInt contains 2 docs"); var res2 = entityRepo.GetByField <string>(nameof(TestEntity.Cities), "Andernos"); Assert.AreEqual(1, res2.Count, "Existing view TestEntity-Cities contains 1 docs"); var entity6 = new TestEntity { Id = "6", Birthday = new DateTime(1985, 08, 12, 0, 0, 0, DateTimeKind.Utc), IsAMan = true, Name = "Balan", PoidsFloat = 70.15F, PoidsDouble = 70.15, NumberOfChildenInt = 0, NumberOfChildenLong = 9999999999999999 }; entityRepo.InsertOne(entity6); var res4 = entityRepo.GetByField <int>(nameof(TestEntity.NumberOfChildenInt), 0); Assert.AreEqual(3, res4.Count, "Existing view TestEntity-NumberOfChildenInt contains 5 docs"); var res5 = entityRepo.GetByField <string>(nameof(TestEntity.Cities), "Andernos"); Assert.AreEqual(1, res5.Count, "Existing view TestEntity-Cities contains 1 docs"); var res6 = entityRepo.GetAll(); Assert.AreEqual(5, res6.Count, "Existing view TestEntity contains 5 docs"); }
public void TestInitialize() { var dbName = "NoSQLTestDb"; // Add Sqlite plugin register. Do it only for unit tests (https://github.com/CouchBaseLite/CouchBaseLite-lite-net/wiki/Error-Dictionary#cblcs0001) //CouchBaseLite.Lite.Storage.SystemSQLite.Plugin.Register(); Couchbase.Lite.Support.NetDesktop.Activate(); var entityRepo = new CouchBaseLiteRepository <TestEntity>(Directory.GetCurrentDirectory(), dbName); var entityRepo2 = new CouchBaseLiteRepository <TestEntity>(Directory.GetCurrentDirectory(), dbName); //var collectionEntityRepo = new CouchBaseLiteRepository<CollectionTest>(Directory.GetCurrentDirectory(), dbName); var entityExtraEltRepo = new CouchBaseLiteRepository <TestExtraEltEntity>(Directory.GetCurrentDirectory(), dbName); test = new NoSQLCoreUnitTests(entityRepo, entityRepo2, entityExtraEltRepo, Directory.GetCurrentDirectory(), dbName); }
public void MvvX_CBLite_NewBaseTests() { var dbFolderPath = Path.Combine(NoSQLCoreUnitTests.testContext.DeploymentDirectory, "DB2"); var fileStore = new MvxWpfFileStore(dbFolderPath); // Ensure that the db file doesn't exists if (fileStore.FolderExists(dbFolderPath)) { fileStore.DeleteFolder(dbFolderPath, true); } var cbl = new CouchBaseLite(); cbl.Initialize(dbFolderPath); // Create a new db (the db file is missing) entityRepo = new CouchBaseLiteRepository <TestEntity>(CouchBaseLiteLiteManager, "DB2"); Assert.AreEqual(false, entityRepo.Exist("123456")); }