Skip to content

Commit

Permalink
Adding passing test
Browse files Browse the repository at this point in the history
  • Loading branch information
ayende committed Nov 1, 2011
1 parent 5d5e87b commit dd77a32
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
66 changes: 66 additions & 0 deletions Raven.Tests/MailingList/transformedresults_customid_test.cs
@@ -0,0 +1,66 @@
using System.Collections.Generic;
using System.Linq;
using Raven.Client.Document;
using Raven.Client.Indexes;
using Xunit;

namespace Raven.Tests.MailingList
{
public class transformedresults_customid_test : RavenTest
{
public class TestItem
{
public string DocId { get; set; }
public string Name { get; set; }
public string City { get; set; }
}

public class TestResultItem
{
public string DocId { get; set; }
public string Name { get; set; }
}


[Fact]
public void Can_project_InternalId_from_transformResults()
{
using(GetNewServer())
using (var store = new DocumentStore { Url = "http://localhost:8080" })
{
store.Initialize();
store.Conventions.FindIdentityProperty = (x => x.Name == "DocId");
store.DatabaseCommands.PutIndex("TestItemsIndex", new IndexDefinitionBuilder<TestItem, TestItem>
{
Map = items => from item in items select new { DocId = item.DocId, Name = item.Name, City = item.City },
TransformResults = (db, results) => from item in results
select new { DocId = item.DocId, Name = item.Name },
}, true);

using (var session = store.OpenSession())
{
session.Store(new TestItem()
{
DocId = "testitems/500",
Name = "My first item",
City = "New york"
});
session.Store(new TestItem()
{
DocId = "testitems/501",
Name = "My second item",
City = "London"
});
session.SaveChanges();

TestResultItem item = session
.Advanced.LuceneQuery<TestResultItem>("TestItemsIndex")
.WaitForNonStaleResults()
.ToList().First();

Assert.NotNull(item.DocId);
}
}
}
}
}
1 change: 1 addition & 0 deletions Raven.Tests/Raven.Tests.csproj
Expand Up @@ -556,6 +556,7 @@
<Compile Include="LocalClientTest.cs" />
<Compile Include="MailingList\NicolasGarfinkiel.cs" />
<Compile Include="MailingList\Stacey.cs" />
<Compile Include="MailingList\transformedresults_customid_test.cs" />
<Compile Include="ManagedStorage\Attachments.cs">
<SubType>Code</SubType>
</Compile>
Expand Down

0 comments on commit dd77a32

Please sign in to comment.