Skip to content

Commit

Permalink
Adding passing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ayende committed Feb 29, 2012
1 parent ad6e6a8 commit b182f40
Show file tree
Hide file tree
Showing 2 changed files with 157 additions and 0 deletions.
156 changes: 156 additions & 0 deletions Raven.Tests/MailingList/Everett616.cs
@@ -0,0 +1,156 @@
using System;
using System.IO;
using Raven.Abstractions.Data;
using Raven.Abstractions.Indexing;
using Raven.Json.Linq;
using Xunit;

namespace Raven.Tests.MailingList
{
public class Everett616 : RavenTest
{
[Fact]
public void CanIndexWithNoErrors_DatetimeOffset()
{
using(var store = NewDocumentStore())
{
store.DatabaseCommands.Put("test/1", null,
RavenJObject.Parse(
@"{
'$type': 'Domain.Model.Clicks.ClickAllocation, Domain',
'AccountId': 'accounts/4',
'Quantity': 90,
'Date': '2011-12-12T08:47:44.0706445-05:00',
'Key': null,
'OrderNumber': null,
'PurchaseOrderNumber': null,
'PurchaseDate': '0001-01-01T00:00:00.0000000-05:00',
'ReorderQuantity': 0,
'Type': 'Dealer',
'LastSavedDate': '2011-12-12T08:47:44.1643945-05:00',
'LastSavedUser': 'NLWEB$/NETLABELS (NLWEB)',
'SourceId': '00000000-0000-0000-0000-000000000000'
}"),
new RavenJObject
{
{Constants.RavenEntityName, "ClickAllocations"}
});

store.DatabaseCommands.Put("test/2", null,
RavenJObject.Parse(
@"{
'$type': 'Domain.Model.Clicks.ClickAllocation, Domain',
'AccountId': 'accounts/4',
'Quantity': 20,
'Date': '2012-02-28T16:05:18.7359910Z',
'Key': null,
'OrderNumber': null,
'PurchaseOrderNumber': null,
'PurchaseDate': '0001-01-01T00:00:00.0000000',
'ReorderQuantity': 5,
'Type': 'Dealer',
'LastSavedDate': '2012-02-28T16:05:19.3609910',
'LastSavedUser': 'NLWEB$/NETLABELS (NLWEB)',
'SourceId': '00000000-0000-0000-0000-000000000000'
}"),
new RavenJObject
{
{Constants.RavenEntityName, "ClickAllocations"}
});


store.DatabaseCommands.PutIndex("test",
new IndexDefinition
{
Map =
@"docs.ClickAllocations
.Select(doc => new {AccountId = doc.AccountId, Date = doc.Date, Id = doc.__document_id, Key = doc.Key, LastSavedDate = doc.LastSavedDate, LastSavedUser = doc.LastSavedUser, OrderNumber = doc.OrderNumber, PurchaseDate = doc.PurchaseDate, PurchaseOrderNumber = doc.PurchaseOrderNumber, Quantity = doc.Quantity, ReorderQuantity = doc.ReorderQuantity, Type = doc.Type})
",
Reduce =
@"results
.GroupBy(result => result.AccountId)
.Select(a => new {a = a, clickAllocation = a.OrderByDescending(x => x.Date).FirstOrDefault()})
.Select(__h__TransparentIdentifier0 => new {AccountId = __h__TransparentIdentifier0.clickAllocation.AccountId, Date = __h__TransparentIdentifier0.clickAllocation.Date, Id = __h__TransparentIdentifier0.clickAllocation.Id, Key = __h__TransparentIdentifier0.clickAllocation.Key, LastSavedDate = __h__TransparentIdentifier0.clickAllocation.LastSavedDate, LastSavedUser = __h__TransparentIdentifier0.clickAllocation.LastSavedUser, OrderNumber = __h__TransparentIdentifier0.clickAllocation.OrderNumber, PurchaseDate = __h__TransparentIdentifier0.clickAllocation.PurchaseDate, PurchaseOrderNumber = __h__TransparentIdentifier0.clickAllocation.PurchaseOrderNumber, Quantity = __h__TransparentIdentifier0.clickAllocation.Quantity, ReorderQuantity = __h__TransparentIdentifier0.clickAllocation.ReorderQuantity, Type = __h__TransparentIdentifier0.clickAllocation.Type})"
});

WaitForIndexing(store);

Assert.Empty(store.DocumentDatabase.Statistics.Errors);
}
}

[Fact]
public void CanIndexWithNoErrors_Datetime()
{
using (var store = NewDocumentStore())
{
store.DatabaseCommands.Put("test/1", null,
RavenJObject.Parse(
@"{
'$type': 'Domain.Model.Clicks.ClickAllocation, Domain',
'AccountId': 'accounts/4',
'Quantity': 90,
'Date': '2011-12-12T08:47:44.0706445',
'Key': null,
'OrderNumber': null,
'PurchaseOrderNumber': null,
'PurchaseDate': '0001-01-01T00:00:00.0000000-05:00',
'ReorderQuantity': 0,
'Type': 'Dealer',
'LastSavedDate': '2011-12-12T08:47:44.1643945-05:00',
'LastSavedUser': 'NLWEB$/NETLABELS (NLWEB)',
'SourceId': '00000000-0000-0000-0000-000000000000'
}"),
new RavenJObject
{
{Constants.RavenEntityName, "ClickAllocations"}
});

store.DatabaseCommands.Put("test/2", null,
RavenJObject.Parse(
@"{
'$type': 'Domain.Model.Clicks.ClickAllocation, Domain',
'AccountId': 'accounts/4',
'Quantity': 20,
'Date': '2012-02-28T16:05:18.7359910',
'Key': null,
'OrderNumber': null,
'PurchaseOrderNumber': null,
'PurchaseDate': '0001-01-01T00:00:00.0000000',
'ReorderQuantity': 5,
'Type': 'Dealer',
'LastSavedDate': '2012-02-28T16:05:19.3609910',
'LastSavedUser': 'NLWEB$/NETLABELS (NLWEB)',
'SourceId': '00000000-0000-0000-0000-000000000000'
}"),
new RavenJObject
{
{Constants.RavenEntityName, "ClickAllocations"}
});


store.DatabaseCommands.PutIndex("test",
new IndexDefinition
{
Map =
@"docs.ClickAllocations
.Select(doc => new {AccountId = doc.AccountId, Date = doc.Date, Id = doc.__document_id, Key = doc.Key, LastSavedDate = doc.LastSavedDate, LastSavedUser = doc.LastSavedUser, OrderNumber = doc.OrderNumber, PurchaseDate = doc.PurchaseDate, PurchaseOrderNumber = doc.PurchaseOrderNumber, Quantity = doc.Quantity, ReorderQuantity = doc.ReorderQuantity, Type = doc.Type})
",
Reduce =
@"results
.GroupBy(result => result.AccountId)
.Select(a => new {a = a, clickAllocation = a.OrderByDescending(x => x.Date).FirstOrDefault()})
.Select(__h__TransparentIdentifier0 => new {AccountId = __h__TransparentIdentifier0.clickAllocation.AccountId, Date = __h__TransparentIdentifier0.clickAllocation.Date, Id = __h__TransparentIdentifier0.clickAllocation.Id, Key = __h__TransparentIdentifier0.clickAllocation.Key, LastSavedDate = __h__TransparentIdentifier0.clickAllocation.LastSavedDate, LastSavedUser = __h__TransparentIdentifier0.clickAllocation.LastSavedUser, OrderNumber = __h__TransparentIdentifier0.clickAllocation.OrderNumber, PurchaseDate = __h__TransparentIdentifier0.clickAllocation.PurchaseDate, PurchaseOrderNumber = __h__TransparentIdentifier0.clickAllocation.PurchaseOrderNumber, Quantity = __h__TransparentIdentifier0.clickAllocation.Quantity, ReorderQuantity = __h__TransparentIdentifier0.clickAllocation.ReorderQuantity, Type = __h__TransparentIdentifier0.clickAllocation.Type})"
});

WaitForIndexing(store);

Assert.Empty(store.DocumentDatabase.Statistics.Errors);
}
}

protected override void CreateDefaultIndexes(Client.IDocumentStore documentStore)
{
}
}
}
1 change: 1 addition & 0 deletions Raven.Tests/Raven.Tests.csproj
Expand Up @@ -549,6 +549,7 @@
<Compile Include="LocalClientTest.cs" />
<Compile Include="MailingList\Afif.cs" />
<Compile Include="MailingList\BuildStarted.cs" />
<Compile Include="MailingList\Everett616.cs" />
<Compile Include="MailingList\IndexWhereClause .cs" />
<Compile Include="MailingList\Mark2.cs" />
<Compile Include="MailingList\NestedIndexDynamic.cs" />
Expand Down

0 comments on commit b182f40

Please sign in to comment.