public async Task Setup()
        {
            app    = App.Create(myRealmAppId);
            user   = app.LogInAsync(Credentials.EmailPassword("*****@*****.**", "foobar")).Result;
            config = new SyncConfiguration("My Project", user);

            // :code-block-start: mongo-setup
            mongoClient      = user.GetMongoClient("mongodb-atlas");
            dbPlantInventory = mongoClient.GetDatabase("inventory");
            plantsCollection = dbPlantInventory.GetCollection <Plant>("plants");
            // :code-block-end:

            return;
        }
Beispiel #2
0
        public async Task Setup()
        {
            app  = App.Create(myRealmAppId);
            user = await app.LogInAsync(Credentials.EmailPassword("*****@*****.**", "foobar"));

            config = new SyncConfiguration("myPartition", user);

            mongoClient      = user.GetMongoClient("mongodb-atlas");
            dbPlantInventory = mongoClient.GetDatabase("inventory");
            plantsCollection = dbPlantInventory.GetCollection <Plant>("plants");

            await InsertsOne();
            await InsertsMany();

            return;
        }
Beispiel #3
0
        public async Task Creates()
        {
            app  = App.Create(myRealmAppId);
            user = await app.LogInAsync(Credentials.Anonymous());

            mongoClient   = user.GetMongoClient("mongodb-atlas");
            dbTracker     = mongoClient.GetDatabase("tracker");
            cudCollection = dbTracker.GetCollection <CustomUserData>("user_data");

            var cud = new CustomUserData(user.Id)
            {
                FavoriteColor = "pink",
                LocalTimeZone = "+8",
                IsCool        = true
            };

            var insertResult = await cudCollection.InsertOneAsync(cud);

            Assert.AreEqual(user.Id, insertResult.InsertedId);
        }
Beispiel #4
0
        public async Task Setup()
        {
            app              = App.Create(myRealmAppId);
            user             = app.LogInAsync(Credentials.EmailPassword("*****@*****.**", "foobar")).Result;
            config           = new SyncConfiguration("myPartition", user);
            mongoClient      = user.GetMongoClient("mongodb-atlas");
            dbPlantInventory = mongoClient.GetDatabase("inventory");
            plantsCollection = dbPlantInventory.GetCollection <Plant>("plants");

            venus = new Plant
            {
                Name      = "Venus Flytrap",
                Sunlight  = Sunlight.Full,
                Color     = PlantColor.White,
                Type      = PlantType.Perennial,
                Partition = "Store 42"
            };
            sweetBasil = new Plant
            {
                Name      = "Sweet Basil",
                Sunlight  = Sunlight.Partial,
                Color     = PlantColor.Green,
                Type      = PlantType.Annual,
                Partition = "Store 42"
            };
            thaiBasil = new Plant
            {
                Name      = "Thai Basil",
                Sunlight  = Sunlight.Partial,
                Color     = PlantColor.Green,
                Type      = PlantType.Perennial,
                Partition = "Store 42"
            };
            helianthus = new Plant
            {
                Name      = "Helianthus",
                Sunlight  = Sunlight.Full,
                Color     = PlantColor.Yellow,
                Type      = PlantType.Annual,
                Partition = "Store 42"
            };
            petunia = new Plant
            {
                Name      = "Petunia",
                Sunlight  = Sunlight.Full,
                Color     = PlantColor.Purple,
                Type      = PlantType.Annual,
                Partition = "Store 47"
            };

            var listofPlants = new List <Plant>
            {
                venus,
                sweetBasil,
                thaiBasil,
                helianthus,
                petunia
            };

            var insertResult = await plantsCollection.InsertManyAsync(listofPlants);



            return;
        }
 private void SetupPlantCollection()
 {
     mongoClient      = user.GetMongoClient("mongodb-atlas");
     dbPlantInventory = mongoClient.GetDatabase("inventory");
     plantsCollection = dbPlantInventory.GetCollection <Plant>("plants");
 }