예제 #1
0
        public async Task Delete_Collection(string collectionName, string id, string json)
        {
            IObjectService service = new MongoService(_fixture.MongoClient, _fixture.Logger);

            // Try getting items in the collection. Collection doesn't exist yet, should get a 404
            var getFirstCollectionResult = await service.GetAllAsync("bookstore", collectionName);

            Assert.Equal(404, getFirstCollectionResult.Status);

            // Add an item to collection; Mongo auto-creates the collection
            var insertResult = await service.InsertAsync("bookstore", collectionName, id, json);

            // // Try getting items in collection a 2nd time. Now it should return a 200.
            var getSecondCollectionResult = await service.GetAllAsync("bookstore", collectionName);

            Assert.Equal(200, getSecondCollectionResult.Status);

            // Delete the collection
            var deleteCollectionResult = await service.DeleteCollectionAsync("bookstore", collectionName);

            Assert.Equal(200, deleteCollectionResult.Status);

            // Try getting items in collection a 3rd time. It was just deleted so we should get a 404.
            var getThirdCollectionResult = await service.GetAllAsync("bookstore", collectionName);

            Assert.Equal(404, getThirdCollectionResult.Status);
        }