forked from ravendb/ravendb
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
157 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters