Exemplo n.º 1
0
        public void CreateDB_1()//Verifies a DB created and exists
        {
            appConnection.ConnectServer("mongodb://127.0.0.1:27017", null);
            string newDbName     = "stasdb55";
            string newcollection = "StasUnitTCreateColl5";

            UnitTest1 existingdbname = new UnitTest1();
            var       result         = existingdbname.DatabaseExists(newDbName);

            if (result == true)// DB already exists check
            {
                Fail("DB already exists");
            }
            else
            {
                CreateDB create = new CreateDB();
                create.CreateDBs(newDbName, newcollection, appConnection, "Field", "Value");
                var result1 = existingdbname.DatabaseExists(newDbName);

                Assert.True(result1);//Checks true/false saved in "result"
            }
        }
Exemplo n.º 2
0
        [Fact]                    //The False result is expected. Passed if fails.
        public void DeleteDoc_4() //The "method test" tests the DeleteDoc method by its id from specific collection
                                  //Verifies it doesn't exist
        {
            appConnection.ConnectServer("mongodb://127.0.0.1:27017", null);
            string db   = "stasdb55";
            string coll = "StasUnitTCreateColl6";
            string id   = "5d28b17813301f69d4cd33ba";

            DeleteDoc del = new DeleteDoc();

            del.DeleteDocs
            (
                db,
                coll,
                id,
                appConnection
            );
            UnitTest1 docID  = new UnitTest1();
            var       result = docID.SelectDoc(db, coll, id);

            Assert.False(result);
        }
Exemplo n.º 3
0
        public void CreateCollection_2()//Verifies a collection created in specific db
        {
            string newDbName1     = "stasdb55";
            string newcollection1 = "StasUnitTCreateColl6";

            appConnection.ConnectServer("mongodb://127.0.0.1:27017", null);

            UnitTest1 existingcollname = new UnitTest1();
            var       result           = existingcollname.CollectionExists(newcollection1);

            if (result == true)// Collection already exists check
            {
                Fail("The Collectionn already exists");
            }
            else
            {
                CreateDB create = new CreateDB();
                create.CreateDBs(newDbName1, newcollection1, appConnection, "Field", "Value");
                var result1 = existingcollname.DatabaseExists(newDbName1);

                Assert.True(result1);//Checks true/false saved in "result"
            }
        }