public void ReadsReplicaSetCorrectly() { string xml = @"<?xml version='1.0' encoding='UTF-8' ?> <objects xmlns='http://www.springframework.net' xmlns:mongo='http://www.springframework.net/mongo'> <mongo:mongo id='Mongo2' replica-set='127.0.0.1:4711,127.0.0.1:4712' /> </objects>"; var factory = new XmlObjectFactory(new StringResource(xml, Encoding.UTF8)); Assert.That(factory.GetObjectDefinitionNames(), Contains.Item("Mongo2")); var server = factory.GetObject <MongoServer>("Mongo2"); Assert.That(server, Is.Not.Null); Assert.That(server.Settings.Servers, Contains.Item(new MongoServerAddress("127.0.0.1", 4711))); Assert.That(server.Settings.Servers, Contains.Item(new MongoServerAddress("127.0.0.1", 4712))); }
public void ReadsMongoAttributesCorrectly() { string xml = @"<?xml version='1.0' encoding='UTF-8' ?> <objects xmlns='http://www.springframework.net' xmlns:mongo='http://www.springframework.net/mongo'> <mongo:mongo url='mongodb://localhost' write-concern='WMajority' /> </objects>"; var factory = new XmlObjectFactory(new StringResource(xml, Encoding.UTF8)); Assert.That(factory.GetObjectDefinitionNames(), Contains.Item("Mongo")); IObjectDefinition definition = factory.GetObjectDefinition("Mongo"); Assert.That(definition, Is.Not.Null); IList <PropertyValue> values = definition.PropertyValues.PropertyValues; Assert.That(values, Contains.Item(new PropertyValue("WriteConcern", "WMajority"))); Assert.That(values, Contains.Item(new PropertyValue("Url", "mongodb://localhost"))); }
public void IfNoIdUseDefault() { string xml = @"<?xml version='1.0' encoding='UTF-8' ?> <objects xmlns='http://www.springframework.net' xmlns:mongo='http://www.springframework.net/mongo'> <mongo:convention-profile /> </objects>"; var factory = new XmlObjectFactory(new StringResource(xml, Encoding.UTF8)); Assert.That(factory.GetObjectDefinitionNames(), Contains.Item("MongoConventionProfile")); var conventionProfile = factory.GetObject("MongoConventionProfile") as ConventionProfile; Assert.That(conventionProfile, Is.Not.Null); Assert.That(conventionProfile.DefaultValueConvention, Is.TypeOf <NullDefaultValueConvention>()); Assert.That(conventionProfile.ElementNameConvention, Is.TypeOf <MemberNameElementNameConvention>()); Assert.That(conventionProfile.ExtraElementsMemberConvention, Is.TypeOf <NamedExtraElementsMemberConvention>()); Assert.That(conventionProfile.IdGeneratorConvention, Is.TypeOf <LookupIdGeneratorConvention>()); Assert.That(conventionProfile.IdMemberConvention, Is.TypeOf <NamedIdMemberConvention>()); Assert.That(conventionProfile.IgnoreExtraElementsConvention, Is.TypeOf <NeverIgnoreExtraElementsConvention>()); Assert.That(conventionProfile.IgnoreIfDefaultConvention, Is.TypeOf <NeverIgnoreIfDefaultConvention>()); Assert.That(conventionProfile.IgnoreIfNullConvention, Is.TypeOf <NeverIgnoreIfNullConvention>()); Assert.That(conventionProfile.MemberFinderConvention, Is.TypeOf <PublicMemberFinderConvention>()); Assert.That(conventionProfile.SerializationOptionsConvention, Is.TypeOf <NullSerializationOptionsConvention>()); }