예제 #1
0
        public void SuccessfullyUpdateRange()
        {
            var dbSet = new MongoDbSet <MongoDbSetValidationModel>();

            dbSet.SetConnection(TestConfiguration.GetConnection());

            var entities = new[] {
                new MongoDbSetValidationModel
                {
                    RequiredField = "SuccessfullyUpdateRange.1"
                },
                new MongoDbSetValidationModel
                {
                    RequiredField = "SuccessfullyUpdateRange.2"
                }
            };

            dbSet.AddRange(entities);
            dbSet.SaveChanges();

            dbSet.SetConnection(TestConfiguration.GetConnection());

            entities[0].RequiredField = "SuccessfullyUpdateRange.1-Updated";
            entities[1].RequiredField = "SuccessfullyUpdateRange.2-Updated";
            dbSet.UpdateRange(entities);

            Assert.IsFalse(dbSet.Any(m => m.RequiredField == "SuccessfullyUpdateRange.1-Updated" || m.RequiredField == "SuccessfullyUpdateRange.2-Updated"));
            dbSet.SaveChanges();
            Assert.IsTrue(dbSet.Any(m => m.RequiredField == "SuccessfullyUpdateRange.1-Updated"));
            Assert.IsTrue(dbSet.Any(m => m.RequiredField == "SuccessfullyUpdateRange.2-Updated"));
        }
        public void SuccessfullyRemoveRangeByPredicate()
        {
            var dbSet = new MongoDbSet <MongoDbSetValidationModel>();

            dbSet.SetConnection(TestConfiguration.GetConnection());

            var entities = new[]
            {
                new MongoDbSetValidationModel
                {
                    RequiredField = "SuccessfullyRemoveRangeByPredicate"
                },
                new MongoDbSetValidationModel
                {
                    RequiredField = "SuccessfullyRemoveRangeByPredicate",
                    BooleanField  = true
                }
            };

            dbSet.AddRange(entities);
            dbSet.SaveChanges();

            dbSet.SetConnection(TestConfiguration.GetConnection());

            dbSet.RemoveRange(e => e.BooleanField);

            Assert.AreEqual(2, dbSet.Count(m => m.RequiredField == "SuccessfullyRemoveRangeByPredicate"));
            dbSet.SaveChanges();
            Assert.AreEqual(1, dbSet.Count(m => m.RequiredField == "SuccessfullyRemoveRangeByPredicate"));
            Assert.IsNotNull(dbSet.FirstOrDefault(m => m.Id == entities[0].Id));
        }
        public void ExtraElementsSerializationIntegrationTest()
        {
            EntityMapping.AddMappingProcessor(new CollectionNameProcessor());
            EntityMapping.AddMappingProcessor(new ExtraElementsProcessor());
            EntityMapping.RegisterType(typeof(ExtraElementsAttrModel));
            EntityMapping.RegisterType(typeof(ModelWithExtraElements));

            var connection = TestConfiguration.GetConnection();
            var modelWithExtraPropertiesDbSet = new MongoDbSet <ModelWithExtraElements>();

            modelWithExtraPropertiesDbSet.SetConnection(connection);

            var entity = new ModelWithExtraElements
            {
                PropertyOne = "ModelWithExtraElements",
                PropertyTwo = 123
            };

            modelWithExtraPropertiesDbSet.Add(entity);
            modelWithExtraPropertiesDbSet.SaveChanges();

            var extraElementsAttrModelDbSet = new MongoDbSet <ExtraElementsAttrModel>();

            extraElementsAttrModelDbSet.SetConnection(connection);

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

            Assert.AreEqual("ModelWithExtraElements", dbEntity.AdditionalElements[nameof(ModelWithExtraElements.PropertyOne)]);
            Assert.AreEqual(123, dbEntity.AdditionalElements[nameof(ModelWithExtraElements.PropertyTwo)]);
        }
        public async Task AddRelationshipsToNewEntityAsync()
        {
            var connection = TestConfiguration.GetConnection();
            var dbSet      = new MongoDbSet <CollectionIntegrationModel>();

            dbSet.SetConnection(connection);

            var entity = dbSet.Create();

            entity.Description = "AddRelationshipsToNewEntityAsync";

            entity.ObjectIdModelEntities.Add(new ObjectIdIdModel
            {
                Description = "AddRelationshipsToNewEntityAsync-ObjectIdIdModel-1"
            });
            entity.ObjectIdModelEntities.Add(new ObjectIdIdModel
            {
                Description = "AddRelationshipsToNewEntityAsync-ObjectIdIdModel-2"
            });

            await dbSet.SaveChangesAsync().ConfigureAwait(false);

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

            Assert.AreEqual(2, dbEntity.ObjectIdModelEntities.Count);
            Assert.IsTrue(dbEntity.ObjectIdModelEntities.All(e => e.Id != ObjectId.Empty));
        }
        public void ForceLoadEntities()
        {
            var connection = TestConfiguration.GetConnection();
            var dbSet      = new MongoDbSet <CollectionIntegrationModel>();

            dbSet.SetConnection(connection);

            var entity = dbSet.Create();

            entity.Description = "ForceLoadEntities";

            entity.StringModelEntities.Add(new StringIdModel
            {
                Description = "ForceLoadEntities-StringIdModel-1"
            });
            entity.StringModelEntities.Add(new StringIdModel
            {
                Description = "ForceLoadEntities-StringIdModel-2"
            });

            dbSet.SaveChanges();

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

            var navigationCollection = dbEntity.StringModelEntities as EntityNavigationCollection <StringIdModel>;

            Assert.AreEqual(2, navigationCollection.UnloadedCount);

            navigationCollection.LoadEntities();

            Assert.AreEqual(2, navigationCollection.LoadedCount);
            Assert.AreEqual(0, navigationCollection.UnloadedCount);
        }
        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);
        }
        public void SearchText()
        {
            var connection = TestConfiguration.GetConnection();
            var dbSet      = new MongoDbSet <SearchTextModel>();

            dbSet.SetConnection(connection);

            dbSet.AddRange(new SearchTextModel[]
            {
                new SearchTextModel {
                    MiscField = 1, Text = "The quick brown fox jumps over the lazy dog."
                },
                new SearchTextModel {
                    MiscField = 2, Text = "The five boxing wizards jump quickly."
                },
                new SearchTextModel {
                    MiscField = 3, Text = "The quick brown fox jumps over the lazy dog."
                },
                new SearchTextModel {
                    MiscField = 4, Text = "Jived fox nymph grabs quick waltz."
                },
            });
            dbSet.SaveChanges();

            Assert.AreEqual(4, dbSet.SearchText("quick").Count());
            Assert.AreEqual(0, dbSet.SearchText("the").Count());             //Stop words aren't used in text indexes: https://docs.mongodb.com/manual/core/index-text/#supported-languages-and-stop-words
            Assert.AreEqual(2, dbSet.SearchText("dog").Count());
            Assert.AreEqual(1, dbSet.SearchText("jived").Count());

            Assert.AreEqual(1, dbSet.SearchText("quick").Where(e => e.MiscField == 3).Count());
        }
예제 #8
0
        public void SearchGeoNearWithMinMaxDistances()
        {
            var connection = TestConfiguration.GetConnection();
            var dbSet      = new MongoDbSet <SearchGeoModel>();

            dbSet.SetConnection(connection);

            dbSet.AddRange(new SearchGeoModel[]
            {
                new SearchGeoModel {
                    Description = "New York", PrimaryCoordinates = new GeoJsonPoint <GeoJson2DGeographicCoordinates>(
                        new GeoJson2DGeographicCoordinates(-74.005974, 40.712776)
                        )
                },
                new SearchGeoModel {
                    Description = "Adelaide", PrimaryCoordinates = new GeoJsonPoint <GeoJson2DGeographicCoordinates>(
                        new GeoJson2DGeographicCoordinates(138.600739, -34.928497)
                        )
                },
                new SearchGeoModel {
                    Description = "Perth", PrimaryCoordinates = new GeoJsonPoint <GeoJson2DGeographicCoordinates>(
                        new GeoJson2DGeographicCoordinates(115.860458, -31.950527)
                        )
                },
                new SearchGeoModel {
                    Description = "Hobart", PrimaryCoordinates = new GeoJsonPoint <GeoJson2DGeographicCoordinates>(
                        new GeoJson2DGeographicCoordinates(147.327194, -42.882137)
                        )
                }
            });
            dbSet.SaveChanges();

            SearchGeoModel[] GetResults(double?maxDistance = null, double?minDistance = null)
            {
                return(dbSet.SearchGeoNear(e => e.PrimaryCoordinates, new GeoJsonPoint <GeoJson2DGeographicCoordinates>(
                                               new GeoJson2DGeographicCoordinates(138, -30)
                                               ), distanceResultField: e => e.CustomDistanceField, maxDistance: maxDistance, minDistance: minDistance).ToArray());
            }

            var results = GetResults(maxDistance: 3000000);

            Assert.AreEqual(3, results.Count());
            Assert.IsTrue(results.Max(e => e.CustomDistanceField) < 3000000);

            results = GetResults(maxDistance: 600000);
            Assert.AreEqual(1, results.Count());
            Assert.IsTrue(results.Max(e => e.CustomDistanceField) < 600000);

            results = GetResults(maxDistance: 17000000);
            Assert.AreEqual(4, results.Count());

            results = GetResults(minDistance: 600000);
            Assert.AreEqual(3, results.Count());
            Assert.IsTrue(results.Min(e => e.CustomDistanceField) > 600000);

            results = GetResults(maxDistance: 3000000, minDistance: 600000);
            Assert.AreEqual(2, results.Count());
            Assert.IsTrue(results.Max(e => e.CustomDistanceField) < 3000000);
            Assert.IsTrue(results.Min(e => e.CustomDistanceField) > 600000);
        }
예제 #9
0
        public void SearchGeoNearWithCustomDistanceField()
        {
            var connection = TestConfiguration.GetConnection();
            var dbSet      = new MongoDbSet <SearchGeoModel>();

            dbSet.SetConnection(connection);

            dbSet.AddRange(new SearchGeoModel[]
            {
                new SearchGeoModel {
                    Description = "New York", PrimaryCoordinates = new GeoJsonPoint <GeoJson2DGeographicCoordinates>(
                        new GeoJson2DGeographicCoordinates(-74.005974, 40.712776)
                        )
                },
                new SearchGeoModel {
                    Description = "Adelaide", PrimaryCoordinates = new GeoJsonPoint <GeoJson2DGeographicCoordinates>(
                        new GeoJson2DGeographicCoordinates(138.600739, -34.928497)
                        )
                }
            });
            dbSet.SaveChanges();

            var results = dbSet.SearchGeoNear(e => e.PrimaryCoordinates, new GeoJsonPoint <GeoJson2DGeographicCoordinates>(
                                                  new GeoJson2DGeographicCoordinates(138, -30)
                                                  ), distanceResultField: e => e.CustomDistanceField).ToArray();

            Assert.AreNotEqual(0, results[0].CustomDistanceField);
            Assert.AreNotEqual(0, results[1].CustomDistanceField);
            Assert.IsTrue(results[0].CustomDistanceField < results[1].CustomDistanceField);

            Assert.IsNull(results[0].ExtraElements);
        }
        public void AddRelationshipsToExistingEntity()
        {
            var connection = TestConfiguration.GetConnection();
            var dbSet      = new MongoDbSet <CollectionIntegrationModel>();

            dbSet.SetConnection(connection);

            var entity = dbSet.Create();

            entity.Description = "AddRelationshipsToExistingEntity";

            dbSet.SaveChanges();

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

            dbEntity.StringModelEntities.Add(new StringIdModel
            {
                Description = "AddRelationshipsToExistingEntity-StringIdModel-1"
            });
            dbEntity.StringModelEntities.Add(new StringIdModel
            {
                Description = "AddRelationshipsToExistingEntity-StringIdModel-2"
            });

            dbSet.SaveChanges();

            Assert.AreEqual(2, dbEntity.StringModelEntities.Count);
            Assert.IsTrue(dbEntity.StringModelEntities.All(e => e.Id != null));
        }
예제 #11
0
        public void ValidationExceptionOnInvalidModel()
        {
            var dbSet = new MongoDbSet <MongoDbSetValidationModel>();

            dbSet.SetConnection(TestConfiguration.GetConnection());

            dbSet.Add(new MongoDbSetValidationModel());
            dbSet.SaveChanges();
        }
예제 #12
0
        public void SearchGeoNearRecordLimits()
        {
            var connection = TestConfiguration.GetConnection();
            var dbSet      = new MongoDbSet <SearchGeoModel>();

            dbSet.SetConnection(connection);

            for (var i = 0; i < 100; i++)
            {
                dbSet.Add(new SearchGeoModel
                {
                    Description        = $"Adelaide ({i})",
                    PrimaryCoordinates = new GeoJsonPoint <GeoJson2DGeographicCoordinates>(
                        new GeoJson2DGeographicCoordinates(138.600739, -34.928497)
                        )
                });
            }

            dbSet.AddRange(new SearchGeoModel[]
            {
                new SearchGeoModel {
                    Description = "New York", PrimaryCoordinates = new GeoJsonPoint <GeoJson2DGeographicCoordinates>(
                        new GeoJson2DGeographicCoordinates(-74.005974, 40.712776)
                        )
                },
                new SearchGeoModel {
                    Description = "Perth", PrimaryCoordinates = new GeoJsonPoint <GeoJson2DGeographicCoordinates>(
                        new GeoJson2DGeographicCoordinates(115.860458, -31.950527)
                        )
                },
                new SearchGeoModel {
                    Description = "Hobart", PrimaryCoordinates = new GeoJsonPoint <GeoJson2DGeographicCoordinates>(
                        new GeoJson2DGeographicCoordinates(147.327194, -42.882137)
                        )
                }
            });
            dbSet.SaveChanges();

            IQueryable <SearchGeoModel> WithGeoQuery()
            {
                return(dbSet.SearchGeoNear(e => e.PrimaryCoordinates, new GeoJsonPoint <GeoJson2DGeographicCoordinates>(
                                               new GeoJson2DGeographicCoordinates(138, -30)
                                               )));
            }

            Assert.AreEqual(103, WithGeoQuery().Count());
            Assert.AreEqual(3, WithGeoQuery().Skip(100).Count());

            var afterSkipResult = WithGeoQuery().Skip(100).FirstOrDefault();

            Assert.AreEqual("Hobart", afterSkipResult.Description);

            var afterTakeResult = WithGeoQuery().Take(3).ToArray();

            Assert.AreEqual(3, afterTakeResult.Length);
            Assert.AreEqual("Adelaide (0)", afterTakeResult[0].Description);
        }
예제 #13
0
        public void SuccessfullyRemoveEntityById()
        {
            var dbSet = new MongoDbSet <MongoDbSetValidationModel>();

            dbSet.SetConnection(TestConfiguration.GetConnection());

            var entity = new MongoDbSetValidationModel
            {
                RequiredField = "SuccessfullyRemoveEntityById"
            };

            dbSet.Add(entity);
            dbSet.SaveChanges();

            dbSet.SetConnection(TestConfiguration.GetConnection());

            dbSet.RemoveById(entity.Id);

            Assert.IsTrue(dbSet.Any(m => m.RequiredField == "SuccessfullyRemoveEntityById"));
            dbSet.SaveChanges();
            Assert.IsFalse(dbSet.Any(m => m.RequiredField == "SuccessfullyRemoveEntityById"));
        }
예제 #14
0
        public void SuccessfulInsertAndQueryBack()
        {
            var dbSet = new MongoDbSet <MongoDbSetValidationModel>();

            dbSet.SetConnection(TestConfiguration.GetConnection());

            dbSet.Add(new MongoDbSetValidationModel
            {
                RequiredField = "ValueSync"
            });

            Assert.IsFalse(dbSet.Any(m => m.RequiredField == "ValueSync"));
            dbSet.SaveChanges();
            Assert.IsTrue(dbSet.Any(m => m.RequiredField == "ValueSync"));
        }
예제 #15
0
        public async Task SuccessfulInsertAndQueryBackAsync()
        {
            var dbSet = new MongoDbSet <MongoDbSetValidationModel>();

            dbSet.SetConnection(TestConfiguration.GetConnection());

            dbSet.Add(new MongoDbSetValidationModel
            {
                RequiredField = "ValueAsync"
            });

            Assert.IsFalse(dbSet.Any(m => m.RequiredField == "ValueAsync"));
            await dbSet.SaveChangesAsync().ConfigureAwait(false);

            Assert.IsTrue(dbSet.Any(m => m.RequiredField == "ValueAsync"));
        }
예제 #16
0
#pragma warning disable CRR0026 // Unused member - used via Reflection
        private void CommitRelationship <TRelatedEntity>(EntityRelationship relationship, IEnumerable <TEntity> entities) where TRelatedEntity : class
        {
            var collection = BuildRelatedEntityCollection <TRelatedEntity>(relationship, entities);

            if (collection.Any())
            {
                var dbSet = new MongoDbSet <TRelatedEntity>();
                dbSet.SetConnection(Connection);
                dbSet.AddRange(collection);
                dbSet.SaveChanges();
            }

            if (!relationship.IsCollection)
            {
                ApplyForeignKeyChanges <TRelatedEntity>(relationship, entities);
            }
        }
        public void SaveWithNullNavigationProperty()
        {
            var connection = TestConfiguration.GetConnection();
            var dbSet      = new MongoDbSet <CollectionIntegrationModel>();

            dbSet.SetConnection(connection);

            var entity = new CollectionIntegrationModel
            {
                Description = "SaveWithNullNavigationProperty"
            };

            dbSet.Add(entity);
            dbSet.SaveChanges();

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

            Assert.AreEqual(0, dbEntity.StringModelEntities.Count);
        }
예제 #18
0
#pragma warning restore CRR0026 // Unused member - used via Reflection

#pragma warning disable CRR0026 // Unused member - used via Reflection
        private async Task CommitRelationshipAsync <TRelatedEntity>(EntityRelationship relationship, IEnumerable <TEntity> entities, CancellationToken cancellationToken) where TRelatedEntity : class
        {
            var collection = BuildRelatedEntityCollection <TRelatedEntity>(relationship, entities);

            cancellationToken.ThrowIfCancellationRequested();

            if (collection.Any())
            {
                var dbSet = new MongoDbSet <TRelatedEntity>();
                dbSet.SetConnection(Connection);
                dbSet.AddRange(collection);
                await dbSet.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
            }

            if (!relationship.IsCollection)
            {
                ApplyForeignKeyChanges <TRelatedEntity>(relationship, entities);
            }
        }
예제 #19
0
        public void SearchGeoNear()
        {
            var connection = TestConfiguration.GetConnection();
            var dbSet      = new MongoDbSet <SearchGeoModel>();

            dbSet.SetConnection(connection);

            dbSet.AddRange(new SearchGeoModel[]
            {
                new SearchGeoModel {
                    Description = "New York", PrimaryCoordinates = new GeoJsonPoint <GeoJson2DGeographicCoordinates>(
                        new GeoJson2DGeographicCoordinates(-74.005974, 40.712776)
                        )
                },
                new SearchGeoModel {
                    Description = "Adelaide", PrimaryCoordinates = new GeoJsonPoint <GeoJson2DGeographicCoordinates>(
                        new GeoJson2DGeographicCoordinates(138.600739, -34.928497)
                        )
                },
                new SearchGeoModel {
                    Description = "Perth", PrimaryCoordinates = new GeoJsonPoint <GeoJson2DGeographicCoordinates>(
                        new GeoJson2DGeographicCoordinates(115.860458, -31.950527)
                        )
                },
                new SearchGeoModel {
                    Description = "Hobart", PrimaryCoordinates = new GeoJsonPoint <GeoJson2DGeographicCoordinates>(
                        new GeoJson2DGeographicCoordinates(147.327194, -42.882137)
                        )
                }
            });
            dbSet.SaveChanges();

            var results = dbSet.SearchGeoNear(e => e.PrimaryCoordinates, new GeoJsonPoint <GeoJson2DGeographicCoordinates>(
                                                  new GeoJson2DGeographicCoordinates(138, -30)
                                                  )).ToArray();

            Assert.AreEqual(4, results.Count());
            Assert.AreEqual("Adelaide", results[0].Description);
            Assert.AreEqual("New York", results[3].Description);

            Assert.IsTrue(results[0].ExtraElements.ContainsKey("Distance"));
        }
        public void ReadAndWriteUnknownPropertyTypeEntity()
        {
            var connection = TestConfiguration.GetConnection();
            var dbSet      = new MongoDbSet <UnknownPropertyTypeModel>();

            dbSet.SetConnection(connection);

            var entities = new[]
            {
                new UnknownPropertyTypeModel(),
                new UnknownPropertyTypeModel
                {
                    UnknownItem = new UnknownPropertyTypeChildModel
                    {
                        Description = "UnknownPropertyTypeChildModel"
                    }
                },
                new UnknownPropertyTypeModel
                {
                    UnknownItem = new Dictionary <string, int>
                    {
                        { "Age", 1 }
                    }
                }
            };

            dbSet.AddRange(entities);
            dbSet.SaveChanges();

            ResetMongoDb();
            dbSet = new MongoDbSet <UnknownPropertyTypeModel>();
            dbSet.SetConnection(connection);

            var dbEntities = dbSet.ToArray();

            Assert.IsNull(dbEntities[0].UnknownItem);
            Assert.IsInstanceOfType(dbEntities[1].UnknownItem, typeof(UnknownPropertyTypeChildModel));
            Assert.IsInstanceOfType(dbEntities[2].UnknownItem, typeof(Dictionary <string, object>));
        }
        public void ReadAndWriteRootEntity()
        {
            var connection = TestConfiguration.GetConnection();
            var dbSet      = new MongoDbSet <RootKnownBaseModel>();

            dbSet.SetConnection(connection);

            var rootEntity = new RootKnownBaseModel
            {
                Description = "ReadAndWriteRootEntity-RootKnownBaseModel"
            };

            dbSet.Add(rootEntity);

            var childEntity = new UnknownChildToRootModel
            {
                Description = "ReadAndWriteRootEntity-UnknownChildToRootModel"
            };

            dbSet.Add(childEntity);

            dbSet.SaveChanges();

            ResetMongoDb();
            dbSet = new MongoDbSet <RootKnownBaseModel>();
            dbSet.SetConnection(connection);

            var dbRootEntity = dbSet.Where(e => e.Id == rootEntity.Id).FirstOrDefault();

            Assert.IsNotNull(dbRootEntity);
            Assert.IsInstanceOfType(dbRootEntity, typeof(RootKnownBaseModel));

            var dbChildEntity = dbSet.Where(e => e.Id == childEntity.Id).FirstOrDefault();

            Assert.IsNotNull(dbChildEntity);
            Assert.IsInstanceOfType(dbChildEntity, typeof(UnknownChildToRootModel));
        }
예제 #22
0
        public void SearchGeoIntersects()
        {
            var connection = TestConfiguration.GetConnection();
            var dbSet      = new MongoDbSet <SearchGeoModel>();

            dbSet.SetConnection(connection);

            dbSet.AddRange(new SearchGeoModel[]
            {
                new SearchGeoModel {
                    Description = "New York", PrimaryCoordinates = new GeoJsonPoint <GeoJson2DGeographicCoordinates>(
                        new GeoJson2DGeographicCoordinates(-74.005974, 40.712776)
                        )
                },
                new SearchGeoModel {
                    Description = "Adelaide", PrimaryCoordinates = new GeoJsonPoint <GeoJson2DGeographicCoordinates>(
                        new GeoJson2DGeographicCoordinates(138.600739, -34.928497)
                        )
                },
                new SearchGeoModel {
                    Description = "Sydney", PrimaryCoordinates = new GeoJsonPoint <GeoJson2DGeographicCoordinates>(
                        new GeoJson2DGeographicCoordinates(151.209290, -33.868820)
                        )
                },
                new SearchGeoModel {
                    Description = "Melbourne", PrimaryCoordinates = new GeoJsonPoint <GeoJson2DGeographicCoordinates>(
                        new GeoJson2DGeographicCoordinates(144.963058, -37.813629)
                        )
                },
                new SearchGeoModel {
                    Description = "Darwin", PrimaryCoordinates = new GeoJsonPoint <GeoJson2DGeographicCoordinates>(
                        new GeoJson2DGeographicCoordinates(-95.582413, 37.095142)
                        )
                },
                new SearchGeoModel {
                    Description = "Brisbane", PrimaryCoordinates = new GeoJsonPoint <GeoJson2DGeographicCoordinates>(
                        new GeoJson2DGeographicCoordinates(153.025131, -27.469770)
                        )
                }
            });
            dbSet.SaveChanges();

            var results = dbSet.SearchGeoIntersecting(e => e.PrimaryCoordinates, new GeoJsonPolygon <GeoJson2DGeographicCoordinates>(
                                                          new GeoJsonPolygonCoordinates <GeoJson2DGeographicCoordinates>(
                                                              new GeoJsonLinearRingCoordinates <GeoJson2DGeographicCoordinates>(
                                                                  new[]
            {
                new GeoJson2DGeographicCoordinates(115.860458, -31.950527),                                        //Perth
                new GeoJson2DGeographicCoordinates(147.327194, -42.882137),                                        //Hobart
                new GeoJson2DGeographicCoordinates(153.399994, -28.016666),                                        //Gold Coast

                new GeoJson2DGeographicCoordinates(115.860458, -31.950527)                                         //Wrap back to first point
            }
                                                                  )
                                                              )
                                                          )).ToArray();

            Assert.AreEqual(3, results.Count());
            Assert.IsTrue(results.Any(e => e.Description == "Adelaide"));
            Assert.IsTrue(results.Any(e => e.Description == "Melbourne"));
            Assert.IsTrue(results.Any(e => e.Description == "Sydney"));
        }