예제 #1
0
        // find a traveller with booking id "MYS34394"
        // update the details as present in "FindAndUpdatePassenger" of sirtravel test data
        // hint : use the jsection reader to read the data.
        // how to upsert
        public void MongoCrud_07_5_Update_An_AirTraveller()
        {
            #region mongoConnection

            travelCollection = new MongoClient(_runner.ConnectionString).GetDatabase("testdb").GetCollection <AirTravel>("travel");

            #endregion
            #region data preparation
            InsertTravelDetails();
            #endregion

            var airTravelPassenger = testData.GetSection("FindAndUpdatePassenger").GetObject <AirTravel>();
            var beforeUpdate       = travelCollection.Find(Builders <AirTravel> .Filter.Empty).ToList();
            var filter             = Builders <AirTravel> .Filter.ElemMatch(x => x.TravelHistory, his => his.BookingID == "MYS34394");

            var updateOperation = Builders <AirTravel> .Update.Set(x => x, airTravelPassenger);

            var updatedDocuemnt = travelCollection.UpdateOne(filter, updateOperation, new UpdateOptions
            {
                IsUpsert = true
            });


            #region verification
            TravelOperationVerifier.Verify_Add_Food_Preference(_runner.ConnectionString);
            #endregion
            #region data cleanup
            cleanUpTravelCollection();
            #endregion
        }
        // Insert a document in database named "testdb", in a collection named "MovieDetail"
        //The document to be inserted should have a property similar to MovieDetail model
        public void Check_Model_Schema_Validity_001()
        {
            var collection   = getCollection();
            var movieDetails = testData.GetSection("InsertOne").GetObject <MovieDetail>();

            collection.InsertOne(movieDetails);

            MovieDetailsVerifier.VerifyMovieDetaailInsertOne(_runner.ConnectionString, movieDetails);
        }
        private void InsertTravelDetails()
        {
            var travelData = testData.GetSection("AirTravel").GetObject <List <AirTravel> >();

            travelCollection.InsertMany(travelData);
        }
        //design a  schema model for airtravel documents
        //try to read the dat ainto the model
        public void MongoCrud_00_Filters_Document()
        {
            var airTravelDocument = testData.GetSection("AirTravel").GetObject <List <AirTravel> >();

            Assert.AreNotEqual(null, airTravelDocument);
        }