Skip to content

Commit

Permalink
Añadido test de para auto id de Documentos Emebebidos
Browse files Browse the repository at this point in the history
  • Loading branch information
emiliotorrens committed Feb 6, 2012
1 parent 4fac8f2 commit f1f5bbb
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 9 deletions.
Expand Up @@ -9,7 +9,6 @@
<OutputType>Library</OutputType>
<RootNamespace>EtoolTech.MongoDB.Mapper.Test.NUnit</RootNamespace>
<AssemblyName>EtoolTech.MongoDB.Mapper.Test.NUnit</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -30,21 +29,21 @@
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
<Reference Include="nunit.framework, Version=2.5.10.11092, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL" />
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="MongoDB.Bson, Version=1.4.4349.31168, Culture=neutral, PublicKeyToken=f686731cfb9cc103">
<SpecificVersion>False</SpecificVersion>
<Reference Include="MongoDB.Bson">
<HintPath>..\Dependencies\MongoDB.Bson.dll</HintPath>
</Reference>
<Reference Include="MongoDB.Driver, Version=1.4.4349.31169, Culture=neutral, PublicKeyToken=f686731cfb9cc103">
<SpecificVersion>False</SpecificVersion>
<Reference Include="MongoDB.Driver">
<HintPath>..\Dependencies\MongoDB.Driver.dll</HintPath>
</Reference>
<Reference Include="ServiceStack.Text, Version=3.1.7.1816, Culture=neutral, PublicKeyToken=null">
<SpecificVersion>False</SpecificVersion>
<Reference Include="ServiceStack.Text">
<HintPath>..\Dependencies\ServiceStack.Text.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=2.5.10.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77">
<Private>False</Private>
<Package>mono-nunit</Package>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="InsertModifyDeleteTest.cs" />
Expand Down
54 changes: 53 additions & 1 deletion EtoolTech.MongoDB.Mapper.Test.NUnit/IncrementalIdTest.cs
Expand Up @@ -22,8 +22,60 @@ public void TestIncId()
c.Save<Country>();
Assert.AreEqual(c.MongoMapper_Id, i+1);
}


}

[Test()]
public void TestChildIncrementalId()
{
Helper.DropAllCollections();

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>();

List<Person> Persons = new List<Person>();
Persons.MongoFind();

long index = 1;
foreach(Person person in Persons)
{
foreach(Child child in person.Childs)
{
Assert.AreEqual(child._id,index);
index ++;
}
}

}
}
}

0 comments on commit f1f5bbb

Please sign in to comment.