public void LoadRelationship()
        {
            var connection = TestConfiguration.GetConnection();

            var relatedEntity = new StringIdModel
            {
                Description = "LoadRelationship-RelatedItem"
            };
            var writerPipeline   = new EntityWriterPipeline <StringIdModel>(connection);
            var entityCollection = new EntityCollection <StringIdModel>()
            {
                relatedEntity
            };

            writerPipeline.AddCollection(entityCollection);
            writerPipeline.Write();

            var entity = new SingleEntityIntegrationModel
            {
                RelatedItemId = relatedEntity.Id
            };

            new NavigationPropertyMutator <SingleEntityIntegrationModel>().MutateEntity(entity, MutatorType.Select, connection);

            Assert.AreEqual("LoadRelationship-RelatedItem", entity.RelatedItem.Description);
        }
        public void LoadRelationship()
        {
            var database = TestConfiguration.GetDatabase();

            var relatedEntity = new StringIdModel
            {
                Description = "LoadRelationship-RelatedItem"
            };
            var dbEntityWriter = new DbEntityWriter <StringIdModel>(database);
            var collection     = new DbEntityCollection <StringIdModel>
            {
                relatedEntity
            };

            dbEntityWriter.Write(collection);

            var entity = new SingleEntityIntegrationModel
            {
                RelatedItemId = relatedEntity.Id
            };

            var entityMapper = new EntityMapper <SingleEntityIntegrationModel>();

            new NavigationPropertyMutator <SingleEntityIntegrationModel>().MutateEntity(entity, MutatorType.Select, entityMapper, database);

            Assert.AreEqual("LoadRelationship-RelatedItem", entity.RelatedItem.Description);
        }
        public void RemoveRelationshipToEntity()
        {
            var connection = TestConfiguration.GetConnection();
            var dbSet      = new MongoDbSet <CollectionIntegrationModel>();

            dbSet.SetConnection(connection);

            var entity = dbSet.Create();

            entity.Description = "RemoveRelationshipToEntity";

            var item = new StringIdModel
            {
                Description = "RemoveRelationshipToEntity-StringIdModel-1"
            };

            entity.StringModelEntities.Add(item);

            dbSet.SaveChanges();

            entity.StringModelEntities.Remove(item);

            dbSet.SaveChanges();

            var dbEntity = dbSet.Where(e => e.Id == entity.Id).FirstOrDefault();

            Assert.AreEqual(0, dbEntity.StringModelEntities.Count);

            var collectionDbSet = new MongoDbSet <StringIdModel>();

            collectionDbSet.SetConnection(connection);
            var itemDbEntity = collectionDbSet.Where(e => e.Id == item.Id).FirstOrDefault();

            Assert.IsNotNull(itemDbEntity);
        }