Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Modificada la Configuracion, valores no obligatorios

  • Loading branch information...
commit 4903825d4c797e50e5883c99e59d9fb823bb9f46 1 parent d07b2ee
@emiliotorrens authored
View
8 EtoolTech.MongoDB.Mapper.Test.NUnit/App.config
@@ -4,12 +4,12 @@
<section name="MongoMapperConfig" type="EtoolTech.MongoDB.Mapper.Configuration.MongoMapperConfiguration, EtoolTech.MongoDB.Mapper"/>
</configSections>
<MongoMapperConfig>
- <Server Host="127.0.0.1" ReplicaSetName="" MinReplicaServersToWrite="1" BalancedReading="false" PoolSize="50" WaitQueueTimeout="1"/>
- <Database Name="TestDotNET" User="" Password=""/>
- <Context Generated="true" MaxDocumentSize="8" SafeMode="true" FSync="true" ExceptionOnDuplicateKey="true" EnableOriginalObject="true" UseIncrementalId="true" UseChidlsIncrementalId="false"/>
+ <Server Host="127.0.0.1" MinReplicaServersToWrite="1" PoolSize="50" WaitQueueTimeout="1"/>
+ <Database Name="TestDotNET" />
+ <Context Generated="true" MaxDocumentSize="8" FSync="true" ExceptionOnDuplicateKey="true" EnableOriginalObject="true" UseIncrementalId="true" UseChidlsIncrementalId="false"/>
<CollectionConfig>
<add Name="TestConf1">
- <Server Host="host1,host2,host3:1234" ReplicaSetName="Set" MinReplicaServersToWrite="9" BalancedReading="true" PoolSize="1" WaitQueueTimeout="2"/>
+ <Server Host="host1,host2,host3:1234" BalancedReading="true" PoolSize="1" WaitQueueTimeout="2"/>
<Database Name="Conf1" User="user" Password="pass"/>
<Context Generated="true" MaxDocumentSize="8" SafeMode="true" FSync="true" ExceptionOnDuplicateKey="true" EnableOriginalObject="true" UseIncrementalId="false" UseChidlsIncrementalId="true"/>
</add>
View
40 EtoolTech.MongoDB.Mapper.Test.NUnit/Classes/Country.cs
@@ -1,21 +1,21 @@
-using System;
-using EtoolTech.MongoDB.Mapper.Attributes;
-
-namespace EtoolTech.MongoDB.Mapper.Test.NUnit
-{
- [MongoKey(KeyFields = "Code")]
- public class Country: MongoMapper
- {
- [MongoDownRelation(ObjectName = "Person", FieldName = "Country")]
- public string Code { get; set; }
- public string Name { get; set; }
-
- [MongoPropertyValidator(PropertyName="Code")]
- public void CodeIsUp(string CountryCode)
- {
- if (CountryCode != CountryCode.ToUpper())
- throw new Exception(String.Format("{0} must be {1}", CountryCode, CountryCode.ToUpper()));
- }
-
- }
+using System;
+using EtoolTech.MongoDB.Mapper.Attributes;
+
+namespace EtoolTech.MongoDB.Mapper.Test.NUnit
+{
+ [MongoKey(KeyFields = "Code")]
+ public class Country: MongoMapper
+ {
+ [MongoDownRelation(ObjectName = "Person", FieldName = "Country")]
+ public string Code { get; set; }
+ public string Name { get; set; }
+
+ [MongoPropertyValidator(PropertyName="Code")]
+ public void CodeIsUp(string CountryCode)
+ {
+ if (CountryCode != CountryCode.ToUpper())
+ throw new Exception(String.Format("{0} must be {1}", CountryCode, CountryCode.ToUpper()));
+ }
+
+ }
}
View
92 EtoolTech.MongoDB.Mapper.Test.NUnit/ConfigTest.cs
@@ -1,46 +1,46 @@
-using NUnit.Framework;
-using EtoolTech.MongoDB.Mapper.Configuration;
-
-namespace EtoolTech.MongoDB.Mapper.Test.NUnit
-{
- [TestFixture]
- public class ConfigTest
- {
- [Test]
- public void TestReadConfig()
- {
-
- Assert.AreEqual(ConfigManager.GetConnectionString("TestConf1"),
- "mongodb://user:pass@host1,host2,host3:1234/Conf1?replicaSet=Set;w=9;slaveOk=true;maxpoolsize=1;waitQueueTimeout=2000ms;safe=true;fsync=true");
-
- Assert.AreEqual(ConfigManager.GetConnectionString("Country"),
- "mongodb://127.0.0.1/TestDotNET?w=1;maxpoolsize=50;waitQueueTimeout=1000ms;safe=true;fsync=true");
-
- Assert.AreEqual(ConfigManager.GetConnectionString("Person"),
- "mongodb://127.0.0.1/TestDotNETPerson?w=1;maxpoolsize=50;waitQueueTimeout=1000ms;safe=true;fsync=true");
-
- Assert.AreEqual(ConfigManager.GetConnectionString("XXX"),
- "mongodb://127.0.0.1/TestDotNET?w=1;maxpoolsize=50;waitQueueTimeout=1000ms;safe=true;fsync=true");
-
-
- /*
- * Assert.AreEqual(ConfigManager.GetConnectionString("Country"),
- "mongodb://10.176.194.191,10.176.195.254,10.176.196.5/TestDotNET?replicaSet=dingusSet1;w=2;slaveOk=true;maxpoolsize=50;waitQueueTimeout=1000ms;safe=true;fsync=true");
- Assert.AreEqual(ConfigManager.GetConnectionString("Person"),
- "mongodb://10.176.194.191,10.176.195.254,10.176.196.5/TestDotNETPerson?replicaSet=dingusSet1;w=2;slaveOk=true;maxpoolsize=50;waitQueueTimeout=2000ms;safe=true;fsync=true");
- Assert.AreEqual(ConfigManager.GetConnectionString("Fake"),
- "mongodb://user:pass@fake.com:27017/Test?maxpoolsize=100;waitQueueTimeout=2000ms;safe=true;fsync=false");
-
- Assert.AreEqual(ConfigManager.GetConnectionString("XXX"),
- "mongodb://192.168.1.218:27017,192.168.1.216:27017,192.168.1.14:27017/TestDotNET?replicaSet=devSet;w=1;slaveOk=true;maxpoolsize=50;waitQueueTimeout=1000ms;safe=true;fsync=true");
- Assert.AreEqual(ConfigManager.GetConnectionString("Country"),
- "mongodb://192.168.1.218:27017,192.168.1.216:27017,192.168.1.14:27017/TestDotNET?replicaSet=devSet;w=1;slaveOk=true;maxpoolsize=50;waitQueueTimeout=1000ms;safe=true;fsync=true");
- Assert.AreEqual(ConfigManager.GetConnectionString("Person"),
- "mongodb://192.168.1.218:27017,192.168.1.216:27017,192.168.1.14:27017/TestDotNETPerson?replicaSet=devSet;w=1;slaveOk=true;maxpoolsize=50;waitQueueTimeout=2000ms;safe=true;fsync=true");
- Assert.AreEqual(ConfigManager.GetConnectionString("Fake"),
- "mongodb://user:pass@fake.com:27017/Test?maxpoolsize=100;waitQueueTimeout=2000ms;safe=true;fsync=false");
- */
-
- }
- }
-}
+using NUnit.Framework;
+using EtoolTech.MongoDB.Mapper.Configuration;
+
+namespace EtoolTech.MongoDB.Mapper.Test.NUnit
+{
+ [TestFixture]
+ public class ConfigTest
+ {
+ [Test]
+ public void TestReadConfig()
+ {
+
+ Assert.AreEqual("mongodb://user:pass@host1,host2,host3:1234/Conf1?slaveOk=true;maxpoolsize=1;waitQueueTimeout=2000ms;safe=true;fsync=true",
+ ConfigManager.GetConnectionString("TestConf1"));
+
+ Assert.AreEqual("mongodb://127.0.0.1/TestDotNET?w=1;maxpoolsize=50;waitQueueTimeout=1000ms;safe=false;fsync=true",
+ ConfigManager.GetConnectionString("Country"));
+
+ Assert.AreEqual("mongodb://127.0.0.1/TestDotNETPerson?w=1;maxpoolsize=50;waitQueueTimeout=1000ms;safe=true;fsync=true",
+ ConfigManager.GetConnectionString("Person"));
+
+ Assert.AreEqual("mongodb://127.0.0.1/TestDotNET?w=1;maxpoolsize=50;waitQueueTimeout=1000ms;safe=false;fsync=true",
+ ConfigManager.GetConnectionString("XXX"));
+
+
+ /*
+ * Assert.AreEqual(ConfigManager.GetConnectionString("Country"),
+ "mongodb://10.176.194.191,10.176.195.254,10.176.196.5/TestDotNET?replicaSet=dingusSet1;w=2;slaveOk=true;maxpoolsize=50;waitQueueTimeout=1000ms;safe=true;fsync=true");
+ Assert.AreEqual(ConfigManager.GetConnectionString("Person"),
+ "mongodb://10.176.194.191,10.176.195.254,10.176.196.5/TestDotNETPerson?replicaSet=dingusSet1;w=2;slaveOk=true;maxpoolsize=50;waitQueueTimeout=2000ms;safe=true;fsync=true");
+ Assert.AreEqual(ConfigManager.GetConnectionString("Fake"),
+ "mongodb://user:pass@fake.com:27017/Test?maxpoolsize=100;waitQueueTimeout=2000ms;safe=true;fsync=false");
+
+ Assert.AreEqual(ConfigManager.GetConnectionString("XXX"),
+ "mongodb://192.168.1.218:27017,192.168.1.216:27017,192.168.1.14:27017/TestDotNET?replicaSet=devSet;w=1;slaveOk=true;maxpoolsize=50;waitQueueTimeout=1000ms;safe=true;fsync=true");
+ Assert.AreEqual(ConfigManager.GetConnectionString("Country"),
+ "mongodb://192.168.1.218:27017,192.168.1.216:27017,192.168.1.14:27017/TestDotNET?replicaSet=devSet;w=1;slaveOk=true;maxpoolsize=50;waitQueueTimeout=1000ms;safe=true;fsync=true");
+ Assert.AreEqual(ConfigManager.GetConnectionString("Person"),
+ "mongodb://192.168.1.218:27017,192.168.1.216:27017,192.168.1.14:27017/TestDotNETPerson?replicaSet=devSet;w=1;slaveOk=true;maxpoolsize=50;waitQueueTimeout=2000ms;safe=true;fsync=true");
+ Assert.AreEqual(ConfigManager.GetConnectionString("Fake"),
+ "mongodb://user:pass@fake.com:27017/Test?maxpoolsize=100;waitQueueTimeout=2000ms;safe=true;fsync=false");
+ */
+
+ }
+ }
+}
View
166 EtoolTech.MongoDB.Mapper.Test.NUnit/EtoolTech.MongoDB.Mapper.Test.NUnit.csproj
@@ -1,84 +1,84 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>10.0.0</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{52C9E717-6218-47A2-AEB5-0C179DB90AA5}</ProjectGuid>
- <OutputType>Library</OutputType>
- <RootNamespace>EtoolTech.MongoDB.Mapper.Test.NUnit</RootNamespace>
- <AssemblyName>EtoolTech.MongoDB.Mapper.Test.NUnit</AssemblyName>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\Debug</OutputPath>
- <DefineConstants>DEBUG;</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <ConsolePause>false</ConsolePause>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>none</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\Release</OutputPath>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <ConsolePause>false</ConsolePause>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="MongoDB.Bson, Version=1.4.4420.28927, Culture=neutral, PublicKeyToken=f686731cfb9cc103, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\Dependencies\MongoDB.Bson.dll</HintPath>
- </Reference>
- <Reference Include="MongoDB.Driver, Version=1.4.4420.22836, Culture=neutral, PublicKeyToken=f686731cfb9cc103, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\Dependencies\MongoDB.Driver.dll</HintPath>
- </Reference>
- <Reference Include="nunit.framework, Version=2.6.0.12051, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\Dependencies\nunit.framework.dll</HintPath>
- </Reference>
- <Reference Include="ServiceStack.Text">
- <HintPath>..\Dependencies\ServiceStack.Text.dll</HintPath>
- </Reference>
- <Reference Include="System" />
- <Reference Include="System.Configuration" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="AmbiguousDiscriminatorTest.cs" />
- <Compile Include="InsertModifyDeleteTest.cs" />
- <Compile Include="ConfigTest.cs" />
- <Compile Include="FindTest.cs" />
- <Compile Include="EventsTest.cs" />
- <Compile Include="ExtensionTest.cs" />
- <Compile Include="IncrementalIdTest.cs" />
- <Compile Include="OriginalObjectTest.cs" />
- <Compile Include="ReadmeTest.cs" />
- <Compile Include="ReflectionUtilityTest.cs" />
- <Compile Include="RelationsTest.cs" />
- <Compile Include="Classes\Child.cs" />
- <Compile Include="Classes\Country.cs" />
- <Compile Include="Classes\Helper.cs" />
- <Compile Include="Classes\Person.cs" />
- <Compile Include="TestReplicaSet.cs" />
- </ItemGroup>
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
- <ItemGroup>
- <None Include="App.config">
- <SubType>Designer</SubType>
- </None>
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\EtoolTech.MongoDB.Mapper\EtoolTech.MongoDB.Mapper.csproj">
- <Project>{9189E04F-8BC5-4219-B706-F986444474A0}</Project>
- <Name>EtoolTech.MongoDB.Mapper</Name>
- </ProjectReference>
- </ItemGroup>
- <PropertyGroup>
- <PostBuildEvent>
- </PostBuildEvent>
- </PropertyGroup>
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>10.0.0</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{52C9E717-6218-47A2-AEB5-0C179DB90AA5}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <RootNamespace>EtoolTech.MongoDB.Mapper.Test.NUnit</RootNamespace>
+ <AssemblyName>EtoolTech.MongoDB.Mapper.Test.NUnit</AssemblyName>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug</OutputPath>
+ <DefineConstants>DEBUG;</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <ConsolePause>false</ConsolePause>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>none</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Release</OutputPath>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <ConsolePause>false</ConsolePause>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="MongoDB.Bson, Version=1.4.4420.28927, Culture=neutral, PublicKeyToken=f686731cfb9cc103, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\Dependencies\MongoDB.Bson.dll</HintPath>
+ </Reference>
+ <Reference Include="MongoDB.Driver, Version=1.4.4420.22836, Culture=neutral, PublicKeyToken=f686731cfb9cc103, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\Dependencies\MongoDB.Driver.dll</HintPath>
+ </Reference>
+ <Reference Include="nunit.framework, Version=2.6.0.12051, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\Dependencies\nunit.framework.dll</HintPath>
+ </Reference>
+ <Reference Include="ServiceStack.Text">
+ <HintPath>..\Dependencies\ServiceStack.Text.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Configuration" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="AmbiguousDiscriminatorTest.cs" />
+ <Compile Include="InsertModifyDeleteTest.cs" />
+ <Compile Include="ConfigTest.cs" />
+ <Compile Include="FindTest.cs" />
+ <Compile Include="EventsTest.cs" />
+ <Compile Include="ExtensionTest.cs" />
+ <Compile Include="IncrementalIdTest.cs" />
+ <Compile Include="OriginalObjectTest.cs" />
+ <Compile Include="ReadmeTest.cs" />
+ <Compile Include="ReflectionUtilityTest.cs" />
+ <Compile Include="RelationsTest.cs" />
+ <Compile Include="Classes\Child.cs" />
+ <Compile Include="Classes\Country.cs" />
+ <Compile Include="Classes\Helper.cs" />
+ <Compile Include="Classes\Person.cs" />
+ <Compile Include="TestReplicaSet.cs" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <ItemGroup>
+ <None Include="App.config">
+ <SubType>Designer</SubType>
+ </None>
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\EtoolTech.MongoDB.Mapper\EtoolTech.MongoDB.Mapper.csproj">
+ <Project>{9189E04F-8BC5-4219-B706-F986444474A0}</Project>
+ <Name>EtoolTech.MongoDB.Mapper</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <PropertyGroup>
+ <PostBuildEvent>
+ </PostBuildEvent>
+ </PropertyGroup>
</Project>
View
58 EtoolTech.MongoDB.Mapper.Test.NUnit/EventsTest.cs
@@ -1,29 +1,29 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-
-
-using NUnit.Framework;
-
-namespace EtoolTech.MongoDB.Mapper.Test.NUnit
-{
- [TestFixture()]
- public class EventsTest
- {
- [Test()]
- public void TestEvents()
- {
- Helper.DropAllCollections();
-
- Country c = new Country { Code = "FR", Name = "España" };
- c.OnBeforeInsert += (s, e) => { ((Country)s).Name = "Francia"; };
- c.Save<Country>();
-
- Country c3 = Country.FindByKey<Country>("FR");
-
- Assert.AreEqual(c3.Name, "Francia");
-
- }
- }
-}
+using System;
+using System.Text;
+using System.Collections.Generic;
+using System.Linq;
+
+
+using NUnit.Framework;
+
+namespace EtoolTech.MongoDB.Mapper.Test.NUnit
+{
+ [TestFixture()]
+ public class EventsTest
+ {
+ [Test()]
+ public void TestEvents()
+ {
+ Helper.DropAllCollections();
+
+ Country c = new Country { Code = "FR", Name = "España" };
+ c.OnBeforeInsert += (s, e) => { ((Country)s).Name = "Francia"; };
+ c.Save<Country>();
+
+ Country c3 = Country.FindByKey<Country>("FR");
+
+ Assert.AreEqual(c3.Name, "Francia");
+
+ }
+ }
+}
View
330 EtoolTech.MongoDB.Mapper.Test.NUnit/FindTest.cs
@@ -1,165 +1,165 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-
-
-using NUnit.Framework;
-using MongoDB.Driver.Builders;
-
-namespace EtoolTech.MongoDB.Mapper.Test.NUnit
-{
- using EtoolTech.MongoDB.Mapper.Configuration;
-
- [TestFixture()]
- public class FindTest
- {
-
- [Test()]
- public void TestFindByPk()
- {
- //Llenamos datos
- Helper.DropAllCollections();
-
- ConfigManager.Out = Console.Out;
-
- Country c = new Country { Code = "ES", Name = "España" };
- c.Save<Country>();
-
- //Insert de personas
- Person p = new Person
- {
- Name = "Pepito Perez",
- Age = 35,
- BirthDate = DateTime.Now.AddDays(57).AddYears(-35),
- Married = true,
- Country = "ES",
- BankBalance = decimal.Parse("3500,00")
- };
-
- p.Childs.Add(new Child() { ID = 1, Age = 10, BirthDate = DateTime.Now.AddDays(57).AddYears(-10), Name = "Juan Perez" });
- p.Childs.Add(new Child() { ID = 2, Age = 7, BirthDate = DateTime.Now.AddDays(57).AddYears(-7), Name = "Ana Perez" });
-
- p.Save<Person>();
-
- p = new Person
- {
- Name = "Juanito Sanchez",
- Age = 25,
- BirthDate = DateTime.Now.AddDays(52).AddYears(-38),
- Married = true,
- Country = "ES",
- BankBalance = decimal.Parse("1500,00")
- };
-
- p.Childs.Add(new Child() { ID = 1, Age = 5, BirthDate = DateTime.Now.AddDays(7).AddYears(-5), Name = "Toni Sanchez" });
-
- p.Save<Person>();
-
- p = new Person
- {
- Name = "Andres Perez",
- Age = 25,
- BirthDate = DateTime.Now.AddDays(25).AddYears(-25),
- Married = false,
- Country = "ES",
- BankBalance = decimal.Parse("500,00")
- };
-
-
- p.Save<Person>();
-
-
- p = new Person
- {
- Name = "Marta Serrano",
- Age = 28,
- BirthDate = DateTime.Now.AddDays(28).AddYears(-28),
- Married = false,
- Country = "ES",
- BankBalance = decimal.Parse("9500,00")
- };
-
- p.Childs.Add(new Child() { ID = 1, Age = 2, BirthDate = DateTime.Now.AddDays(2).AddYears(-2), Name = "Toni Serrano" });
- p.Save<Person>();
-
- p = new Person
- {
- Name = "Jonh Smith",
- Age = 21,
- BirthDate = DateTime.Now.AddDays(21).AddYears(-21),
- Married = false,
- Country = "ES",
- BankBalance = decimal.Parse("100,00")
- };
-
- p.Save<Person>();
-
-
- List<Person> plist = Person.AllAsList<Person>();
-
- Person p2 = Person.FindByKey<Person>(plist[0].MongoMapper_Id);
- p2.Name = "FindBYKey Name";
- p2.Save<Person>();
-
- plist = Person.FindAsList<Person>("_id", p2.MongoMapper_Id);
-
- Assert.AreEqual(plist.Count,1);
- Assert.AreEqual(plist[0].Name, "FindBYKey Name");
-
- }
-
-
- [Test()]
- public void TestFindAnddOr()
- {
- //Llenamos datos
- (new InsertModifyDeleteTest()).TestInsert();
-
- ConfigManager.Out = Console.Out;
-
- List<Country> Countries = Country.FindAsList<Country>(Query.Or(MongoQuery.Eq((Country c) => c.Code, "ES"), Query.EQ("Code", "UK")));
- Assert.AreEqual(Countries.Count, 2);
-
- List<Person> Persons = Person.FindAsList<Person>(Query.And(MongoQuery.Eq(((Person p) => p.Age ) , 25), Query.EQ("Country", "ES")));
- Assert.AreEqual(Persons.Count, 2);
-
- foreach (Person p in Persons)
- {
- Assert.AreEqual(p.Age, 25);
- Assert.AreEqual(p.Country, "ES");
- }
-
-
- }
-
-
- [Test()]
- public void TestMongoCursor()
- {
- //llenamos datos
- (new InsertModifyDeleteTest()).TestInsert();
-
- //TODO: Falla el OutPut cuando ya hemos pedido el cursor ver como hacerlo
- //A MongoCursor object cannot be modified once it has been frozen
- ConfigManager.Out = null;
-
- List<Country> Countries = Country.FindAsCursor<Country>().ToList();
- Assert.AreEqual(Countries.Count, 3);
-
- Countries = Country.FindAsCursor<Country>().SetSkip(2).ToList();
- Assert.AreEqual(Countries.Count, 1);
-
-
- Countries = Country.FindAsCursor<Country>().SetLimit(1).ToList();
- Assert.AreEqual(Countries.Count, 1);
-
- Countries = Country.FindAsCursor<Country>(Query.EQ("Code", "ES")).SetFields(Fields.Include("Code")).ToList();
- Assert.AreEqual(Countries.Count, 1);
- Assert.AreEqual(Countries.First().Name, null);
-
- }
-
-
- }
-}
+using System;
+using System.Text;
+using System.Collections.Generic;
+using System.Linq;
+
+
+using NUnit.Framework;
+using MongoDB.Driver.Builders;
+
+namespace EtoolTech.MongoDB.Mapper.Test.NUnit
+{
+ using EtoolTech.MongoDB.Mapper.Configuration;
+
+ [TestFixture()]
+ public class FindTest
+ {
+
+ [Test()]
+ public void TestFindByPk()
+ {
+ //Llenamos datos
+ Helper.DropAllCollections();
+
+ ConfigManager.Out = Console.Out;
+
+ Country c = new Country { Code = "ES", Name = "España" };
+ c.Save<Country>();
+
+ //Insert de personas
+ Person p = new Person
+ {
+ Name = "Pepito Perez",
+ Age = 35,
+ BirthDate = DateTime.Now.AddDays(57).AddYears(-35),
+ Married = true,
+ Country = "ES",
+ BankBalance = decimal.Parse("3500,00")
+ };
+
+ p.Childs.Add(new Child() { ID = 1, Age = 10, BirthDate = DateTime.Now.AddDays(57).AddYears(-10), Name = "Juan Perez" });
+ p.Childs.Add(new Child() { ID = 2, Age = 7, BirthDate = DateTime.Now.AddDays(57).AddYears(-7), Name = "Ana Perez" });
+
+ p.Save<Person>();
+
+ p = new Person
+ {
+ Name = "Juanito Sanchez",
+ Age = 25,
+ BirthDate = DateTime.Now.AddDays(52).AddYears(-38),
+ Married = true,
+ Country = "ES",
+ BankBalance = decimal.Parse("1500,00")
+ };
+
+ p.Childs.Add(new Child() { ID = 1, Age = 5, BirthDate = DateTime.Now.AddDays(7).AddYears(-5), Name = "Toni Sanchez" });
+
+ p.Save<Person>();
+
+ p = new Person
+ {
+ Name = "Andres Perez",
+ Age = 25,
+ BirthDate = DateTime.Now.AddDays(25).AddYears(-25),
+ Married = false,
+ Country = "ES",
+ BankBalance = decimal.Parse("500,00")
+ };
+
+
+ p.Save<Person>();
+
+
+ p = new Person
+ {
+ Name = "Marta Serrano",
+ Age = 28,
+ BirthDate = DateTime.Now.AddDays(28).AddYears(-28),
+ Married = false,
+ Country = "ES",
+ BankBalance = decimal.Parse("9500,00")
+ };
+
+ p.Childs.Add(new Child() { ID = 1, Age = 2, BirthDate = DateTime.Now.AddDays(2).AddYears(-2), Name = "Toni Serrano" });
+ p.Save<Person>();
+
+ p = new Person
+ {
+ Name = "Jonh Smith",
+ Age = 21,
+ BirthDate = DateTime.Now.AddDays(21).AddYears(-21),
+ Married = false,
+ Country = "ES",
+ BankBalance = decimal.Parse("100,00")
+ };
+
+ p.Save<Person>();
+
+
+ List<Person> plist = Person.AllAsList<Person>();
+
+ Person p2 = Person.FindByKey<Person>(plist[0].MongoMapper_Id);
+ p2.Name = "FindBYKey Name";
+ p2.Save<Person>();
+
+ plist = Person.FindAsList<Person>("_id", p2.MongoMapper_Id);
+
+ Assert.AreEqual(plist.Count,1);
+ Assert.AreEqual(plist[0].Name, "FindBYKey Name");
+
+ }
+
+
+ [Test()]
+ public void TestFindAnddOr()
+ {
+ //Llenamos datos
+ (new InsertModifyDeleteTest()).TestInsert();
+
+ ConfigManager.Out = Console.Out;
+
+ List<Country> Countries = Country.FindAsList<Country>(Query.Or(MongoQuery.Eq((Country c) => c.Code, "ES"), Query.EQ("Code", "UK")));
+ Assert.AreEqual(Countries.Count, 2);
+
+ List<Person> Persons = Person.FindAsList<Person>(Query.And(MongoQuery.Eq(((Person p) => p.Age ) , 25), Query.EQ("Country", "ES")));
+ Assert.AreEqual(Persons.Count, 2);
+
+ foreach (Person p in Persons)
+ {
+ Assert.AreEqual(p.Age, 25);
+ Assert.AreEqual(p.Country, "ES");
+ }
+
+
+ }
+
+
+ [Test()]
+ public void TestMongoCursor()
+ {
+ //llenamos datos
+ (new InsertModifyDeleteTest()).TestInsert();
+
+ //TODO: Falla el OutPut cuando ya hemos pedido el cursor ver como hacerlo
+ //A MongoCursor object cannot be modified once it has been frozen
+ ConfigManager.Out = null;
+
+ List<Country> Countries = Country.FindAsCursor<Country>().ToList();
+ Assert.AreEqual(Countries.Count, 3);
+
+ Countries = Country.FindAsCursor<Country>().SetSkip(2).ToList();
+ Assert.AreEqual(Countries.Count, 1);
+
+
+ Countries = Country.FindAsCursor<Country>().SetLimit(1).ToList();
+ Assert.AreEqual(Countries.Count, 1);
+
+ Countries = Country.FindAsCursor<Country>(Query.EQ("Code", "ES")).SetFields(Fields.Include("Code")).ToList();
+ Assert.AreEqual(Countries.Count, 1);
+ Assert.AreEqual(Countries.First().Name, null);
+
+ }
+
+
+ }
+}
View
116 EtoolTech.MongoDB.Mapper.Test.NUnit/OriginalObjectTest.cs
@@ -1,58 +1,58 @@
-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using NUnit.Framework;
-
-namespace EtoolTech.MongoDB.Mapper.Test.NUnit
-{
-
-
- [TestFixture()]
- public class OriginalObjectTest
- {
- [Test()]
- public void TestOriginalObject()
- {
- (new InsertModifyDeleteTest()).TestInsert();
- Person p = Person.AllAsList<Person>().First();
- p.Name = "hola 25";
- p.Save<Person>();
-
- Person p2 = p.GetOriginalObject<Person>();
- Assert.AreEqual("Pepito Perez", p2.Name);
- }
-
- [Test()]
- public void TestOriginalValue()
- {
-
- Helper.DropAllCollections();
-
- Country c = new Country { Code = "ES", Name = "España" };
- c.Save<Country>();
-
- Person p = new Person
- {
- Name = "Pepito Perez",
- Age = 35,
- BirthDate = DateTime.Now.AddDays(57).AddYears(-35),
- Married = true,
- Country = "ES",
- BankBalance = decimal.Parse("3500,00")
- };
-
- p.Childs.Add(new Child() { ID = 1, Age = 10, BirthDate = DateTime.Now.AddDays(57).AddYears(-10), Name = "Juan Perez" });
- p.Childs.Add(new Child() { ID = 2, Age = 7, BirthDate = DateTime.Now.AddDays(57).AddYears(-7), Name = "Ana Perez" });
- p.Save<Person>();
-
- p.Name = "Juan Sin Miedo";
-
- object OriginalName = p.GetOriginalObject<Person>().Name;
-
- Assert.AreEqual(OriginalName.ToString(), "Pepito Perez");
-
-
- }
- }
-}
+using System;
+using System.Text;
+using System.Collections.Generic;
+using System.Linq;
+using NUnit.Framework;
+
+namespace EtoolTech.MongoDB.Mapper.Test.NUnit
+{
+
+
+ [TestFixture()]
+ public class OriginalObjectTest
+ {
+ [Test()]
+ public void TestOriginalObject()
+ {
+ (new InsertModifyDeleteTest()).TestInsert();
+ Person p = Person.AllAsList<Person>().First();
+ p.Name = "hola 25";
+ p.Save<Person>();
+
+ Person p2 = p.GetOriginalObject<Person>();
+ Assert.AreEqual("Pepito Perez", p2.Name);
+ }
+
+ [Test()]
+ public void TestOriginalValue()
+ {
+
+ Helper.DropAllCollections();
+
+ Country c = new Country { Code = "ES", Name = "España" };
+ c.Save<Country>();
+
+ Person p = new Person
+ {
+ Name = "Pepito Perez",
+ Age = 35,
+ BirthDate = DateTime.Now.AddDays(57).AddYears(-35),
+ Married = true,
+ Country = "ES",
+ BankBalance = decimal.Parse("3500,00")
+ };
+
+ p.Childs.Add(new Child() { ID = 1, Age = 10, BirthDate = DateTime.Now.AddDays(57).AddYears(-10), Name = "Juan Perez" });
+ p.Childs.Add(new Child() { ID = 2, Age = 7, BirthDate = DateTime.Now.AddDays(57).AddYears(-7), Name = "Ana Perez" });
+ p.Save<Person>();
+
+ p.Name = "Juan Sin Miedo";
+
+ object OriginalName = p.GetOriginalObject<Person>().Name;
+
+ Assert.AreEqual(OriginalName.ToString(), "Pepito Perez");
+
+
+ }
+ }
+}
View
58 EtoolTech.MongoDB.Mapper/Configuration/MongoMapperConfiguration.cs
@@ -60,7 +60,7 @@ public string Host
}
}
- [ConfigurationProperty("ReplicaSetName", IsKey = false, IsRequired = true)]
+ [ConfigurationProperty("ReplicaSetName", IsKey = false, IsRequired = false)]
public string ReplicaSetName
{
get
@@ -69,21 +69,21 @@ public string ReplicaSetName
}
}
- [ConfigurationProperty("MinReplicaServersToWrite", IsKey = false, IsRequired = true)]
+ [ConfigurationProperty("MinReplicaServersToWrite", IsKey = false, IsRequired = false)]
public int MinReplicaServersToWrite
{
get
- {
- return int.Parse(this["MinReplicaServersToWrite"].ToString());
+ {
+ return int.Parse(this["MinReplicaServersToWrite"].ToString());
}
}
- [ConfigurationProperty("BalancedReading", IsKey = false, IsRequired = true)]
+ [ConfigurationProperty("BalancedReading", IsKey = false, IsRequired = false)]
public bool BalancedReading
{
get
{
- return bool.Parse(this["BalancedReading"].ToString());
+ return bool.Parse(this["BalancedReading"].ToString());
}
}
@@ -118,7 +118,7 @@ public string Name
}
}
- [ConfigurationProperty("User", IsKey = false, IsRequired = true)]
+ [ConfigurationProperty("User", IsKey = false, IsRequired = false)]
public string User
{
get
@@ -127,7 +127,7 @@ public string User
}
}
- [ConfigurationProperty("Password", IsKey = false, IsRequired = true)]
+ [ConfigurationProperty("Password", IsKey = false, IsRequired = false)]
public string Password
{
get
@@ -139,12 +139,12 @@ public string Password
public class Context : ConfigurationElement
{
- [ConfigurationProperty("Generated", IsKey = false, IsRequired = true)]
+ [ConfigurationProperty("Generated", IsKey = false, IsRequired = false)]
public bool Generated
{
get
- {
- return bool.Parse(this["Generated"].ToString());
+ {
+ return bool.Parse(this["Generated"].ToString());
}
}
@@ -157,58 +157,58 @@ public int MaxDocumentSize
}
}
- [ConfigurationProperty("SafeMode", IsKey = false, IsRequired = true)]
+ [ConfigurationProperty("SafeMode", IsKey = false, IsRequired = false)]
public bool SafeMode
{
get
- {
- return bool.Parse(this["SafeMode"].ToString());
+ {
+ return bool.Parse(this["SafeMode"].ToString());
}
}
- [ConfigurationProperty("FSync", IsKey = false, IsRequired = true)]
+ [ConfigurationProperty("FSync", IsKey = false, IsRequired = false)]
public bool FSync
{
get
- {
- return bool.Parse(this["FSync"].ToString());
+ {
+ return bool.Parse(this["FSync"].ToString());
}
}
- [ConfigurationProperty("ExceptionOnDuplicateKey", IsKey = false, IsRequired = true)]
+ [ConfigurationProperty("ExceptionOnDuplicateKey", IsKey = false, IsRequired = false)]
public bool ExceptionOnDuplicateKey
{
get
- {
- return bool.Parse(this["ExceptionOnDuplicateKey"].ToString());
+ {
+ return bool.Parse(this["ExceptionOnDuplicateKey"].ToString());
}
}
- [ConfigurationProperty("EnableOriginalObject", IsKey = false, IsRequired = true)]
+ [ConfigurationProperty("EnableOriginalObject", IsKey = false, IsRequired = false)]
public bool EnableOriginalObject
{
get
- {
- return bool.Parse(this["EnableOriginalObject"].ToString());
+ {
+ return bool.Parse(this["EnableOriginalObject"].ToString());
}
}
- [ConfigurationProperty("UseIncrementalId", IsKey = false, IsRequired = true)]
+ [ConfigurationProperty("UseIncrementalId", IsKey = false, IsRequired = false)]
public bool UseIncrementalId
{
get
- {
- return bool.Parse(this["UseIncrementalId"].ToString());
+ {
+ return bool.Parse(this["UseIncrementalId"].ToString());
}
}
- [ConfigurationProperty("UseChidlsIncrementalId", IsKey = false, IsRequired = true)]
+ [ConfigurationProperty("UseChidlsIncrementalId", IsKey = false, IsRequired = false)]
public bool UseChidlsIncrementalId
{
get
- {
- return bool.Parse(this["UseChidlsIncrementalId"].ToString());
+ {
+ return bool.Parse(this["UseChidlsIncrementalId"].ToString());
}
}
}
View
58 MongoMapper.NET.sln
@@ -1,29 +1,29 @@
-
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EtoolTech.MongoDB.Mapper", "EtoolTech.MongoDB.Mapper\EtoolTech.MongoDB.Mapper.csproj", "{9189E04F-8BC5-4219-B706-F986444474A0}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EtoolTech.MongoDB.Mapper.Test.NUnit", "EtoolTech.MongoDB.Mapper.Test.NUnit\EtoolTech.MongoDB.Mapper.Test.NUnit.csproj", "{52C9E717-6218-47A2-AEB5-0C179DB90AA5}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {9189E04F-8BC5-4219-B706-F986444474A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {9189E04F-8BC5-4219-B706-F986444474A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {9189E04F-8BC5-4219-B706-F986444474A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {9189E04F-8BC5-4219-B706-F986444474A0}.Release|Any CPU.Build.0 = Release|Any CPU
- {52C9E717-6218-47A2-AEB5-0C179DB90AA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {52C9E717-6218-47A2-AEB5-0C179DB90AA5}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {52C9E717-6218-47A2-AEB5-0C179DB90AA5}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {52C9E717-6218-47A2-AEB5-0C179DB90AA5}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(MonoDevelopProperties) = preSolution
- StartupItem = EtoolTech.MongoDB.Mapper\EtoolTech.MongoDB.Mapper.csproj
- EndGlobalSection
-EndGlobal
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EtoolTech.MongoDB.Mapper", "EtoolTech.MongoDB.Mapper\EtoolTech.MongoDB.Mapper.csproj", "{9189E04F-8BC5-4219-B706-F986444474A0}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EtoolTech.MongoDB.Mapper.Test.NUnit", "EtoolTech.MongoDB.Mapper.Test.NUnit\EtoolTech.MongoDB.Mapper.Test.NUnit.csproj", "{52C9E717-6218-47A2-AEB5-0C179DB90AA5}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {9189E04F-8BC5-4219-B706-F986444474A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9189E04F-8BC5-4219-B706-F986444474A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9189E04F-8BC5-4219-B706-F986444474A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9189E04F-8BC5-4219-B706-F986444474A0}.Release|Any CPU.Build.0 = Release|Any CPU
+ {52C9E717-6218-47A2-AEB5-0C179DB90AA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {52C9E717-6218-47A2-AEB5-0C179DB90AA5}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {52C9E717-6218-47A2-AEB5-0C179DB90AA5}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {52C9E717-6218-47A2-AEB5-0C179DB90AA5}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(MonoDevelopProperties) = preSolution
+ StartupItem = EtoolTech.MongoDB.Mapper\EtoolTech.MongoDB.Mapper.csproj
+ EndGlobalSection
+EndGlobal
Please sign in to comment.
Something went wrong with that request. Please try again.