Exemple #1
0
        public void TestStoreElement(List <XElement> keys)
        {
            var repository = new MongoDbXmlRepository(KeyCollection);

            foreach (var key in keys)
            {
                repository.StoreElement(key, null);
            }
            var allDocuments = KeyCollection.Find(FilterDefinition <MongoDbXmlKey> .Empty).ToList();

            Assert.Equal(keys.Count, allDocuments.Count);
            Assert.Single(allDocuments, document => document.Key == Key);
        }
Exemple #2
0
        public void TestGetAllElements(List <XElement> keys)
        {
            var mongodbKeys = keys.Select(key => new MongoDbXmlKey
            {
                Id    = ObjectId.GenerateNewId(),
                Key   = key.ToString(SaveOptions.DisableFormatting),
                KeyId = key.Attribute(IdName)?.Value
            }).ToList();

            KeyCollection.InsertMany(mongodbKeys);
            var repository  = new MongoDbXmlRepository(KeyCollection);
            var allElements = repository.GetAllElements();

            Assert.Equal(keys.Count, allElements.Count);
            Assert.Single(allElements, element => element.ToString(SaveOptions.DisableFormatting) == Key);
            Assert.Single(KeyCollection.Find(document => document.Id == mongodbKeys.First().Id).ToEnumerable());
        }