Permalink
Browse files

Merge branch 'master' of github.com:ayende/ravendb

  • Loading branch information...
ayende committed May 4, 2013
2 parents 5ed1eb6 + b4f9bf0 commit 5229070de223fe016e4411553192d4e6a2a7bbf2
Showing with 99,486 additions and 98,975 deletions.
  1. +10 −0 Raven.Client.Lightweight/Document/RavenClientEnlistment.cs
  2. +4 −1 Raven.Database/Bundles/Quotas/Documents/Triggers/DatabaseCountDocumentDeleteTrigger.cs
  3. +4 −1 Raven.Database/Bundles/Quotas/Size/Triggers/DatabaseSizeAttachmentDeleteTrigger.cs
  4. +4 −1 Raven.Database/Bundles/Quotas/Size/Triggers/DatabaseSizeDocumentDeleteTrigger.cs
  5. +12 −12 Raven.Database/Imports/Lucene.Net/FastVectorHightlighter/BaseFragmentsBuilder.cs
  6. +28 −0 Raven.Database/Linq/Ast/TransformGroupByExtensionMethodTransformer.cs
  7. +16 −4 Raven.Database/Linq/DynamicViewCompiler.cs
  8. +5 −0 Raven.Database/Linq/PrivateExtensions/LinqOnDynamic.cs
  9. +1 −0 Raven.Database/Raven.Database.csproj
  10. +19 −0 Raven.Tests.Helpers/RavenTestBase.cs
  11. +74 −74 Raven.Tests.Silverlight/Statistics.cs
  12. +162 −162 Raven.Tests/Bugs/CS1977.cs
  13. +9 −9 Raven.Tests/Bugs/CompiledIndexes/Network.cs
  14. +10 −10 Raven.Tests/Bugs/CompiledIndexes/NetworkList.cs
  15. +19 −19 Raven.Tests/Bugs/ConnectionStringParsing.cs
  16. +43 −43 Raven.Tests/Bugs/DirectoryCreation.cs
  17. +8 −8 Raven.Tests/Bugs/EntityWithNullableDateTimeOffset.cs
  18. +19 −19 Raven.Tests/Bugs/FailDelete.cs
  19. +24 −24 Raven.Tests/Bugs/FailStore.cs
  20. +134 −134 Raven.Tests/Bugs/Identifiers/SpecialCharactersOnIIS.cs
  21. +12 −12 Raven.Tests/Bugs/Image.cs
  22. +12 −12 Raven.Tests/Bugs/ImageByTagSearchModel.cs
  23. +38 −38 Raven.Tests/Bugs/InMemoryOnly.cs
  24. +47 −47 Raven.Tests/Bugs/IndexDefinitionEquality.cs
  25. +6 −6 Raven.Tests/Bugs/Indexing/Transaction.cs
  26. +17 −17 Raven.Tests/Bugs/Indexing/Transaction_ByMrn.cs
  27. +51 −51 Raven.Tests/Bugs/LinqOnUrls.cs
  28. +8 −8 Raven.Tests/Bugs/LiveProjections/Entities/Place.cs
  29. +12 −12 Raven.Tests/Bugs/LiveProjections/Entities/Product.cs
  30. +14 −14 Raven.Tests/Bugs/LiveProjections/Entities/ProductSku.cs
  31. +20 −20 Raven.Tests/Bugs/LiveProjections/Entities/Task.cs
  32. +26 −26 Raven.Tests/Bugs/LiveProjections/Entities/TaskSummary.cs
  33. +8 −8 Raven.Tests/Bugs/LiveProjections/Entities/User.cs
  34. +36 −36 Raven.Tests/Bugs/LiveProjections/Indexes/ProductDetailsReport_ByProductId.cs
  35. +46 −46 Raven.Tests/Bugs/LiveProjections/Indexes/ProductSkuListViewModelReport_ByArticleNumberAndName.cs
  36. +34 −34 Raven.Tests/Bugs/LiveProjections/Indexes/TaskSummaryIndex.cs
  37. +19 −19 Raven.Tests/Bugs/LiveProjections/ParentAndChildrenNames.cs
  38. +7 −7 Raven.Tests/Bugs/LiveProjections/Person.cs
  39. +12 −12 Raven.Tests/Bugs/LiveProjections/Views/ProductDetailsReport.cs
  40. +14 −14 Raven.Tests/Bugs/LiveProjections/Views/ProductSkuListViewModelReport.cs
  41. +12 −12 Raven.Tests/Bugs/LiveProjections/Views/ProductVariant.cs
  42. +25 −25 Raven.Tests/Bugs/MapRedue/DocumentView.cs
  43. +66 −66 Raven.Tests/Bugs/MapRedue/LetInReduceFunction.cs
  44. +25 −25 Raven.Tests/Bugs/MapRedue/VersionedDocument.cs
  45. +7 −7 Raven.Tests/Bugs/MultiTenancy/Test.cs
  46. +13 −13 Raven.Tests/Bugs/NameAndId.cs
  47. +69 −69 Raven.Tests/Bugs/OverwriteIndexRemotely.cs
  48. +64 −64 Raven.Tests/Bugs/QueryWithPercentageSignp.cs
  49. +49 −49 Raven.Tests/Bugs/QueryingOnEmptyString.cs
  50. +98 −98 Raven.Tests/Bugs/SortingWithWildcardQuery.cs
  51. +19 −19 Raven.Tests/Bugs/TransformResults/Answer.cs
  52. +20 −20 Raven.Tests/Bugs/TransformResults/AnswerEntity.cs
  53. +12 −12 Raven.Tests/Bugs/TransformResults/AnswerViewItem.cs
  54. +19 −19 Raven.Tests/Bugs/TransformResults/AnswerVote.cs
  55. +19 −19 Raven.Tests/Bugs/TransformResults/AnswerVoteEntity.cs
  56. +49 −49 Raven.Tests/Bugs/TransformResults/Answers_ByQuestion.cs
  57. +18 −18 Raven.Tests/Bugs/TransformResults/Question.cs
  58. +13 −13 Raven.Tests/Bugs/TransformResults/QuestionView.cs
  59. +7 −7 Raven.Tests/Bugs/TransformResults/QuestionVote.cs
  60. +40 −40 Raven.Tests/Bugs/TransformResults/QuestionWithVoteTotalIndex.cs
  61. +9 −9 Raven.Tests/Bugs/TransformResults/Thor.cs
  62. +16 −16 Raven.Tests/Bugs/TransformResults/ThorIndex.cs
  63. +8 −8 Raven.Tests/Bugs/TransformResults/User.cs
  64. +18 −18 Raven.Tests/Bugs/User.cs
  65. +9 −9 Raven.Tests/Bugs/UserGuid.cs
  66. +7 −7 Raven.Tests/Bugs/UserInt32.cs
  67. +55 −55 Raven.Tests/Document/CasingIssue.cs
  68. +28 −28 Raven.Tests/Document/Company.cs
  69. +15 −15 Raven.Tests/Document/Contact.cs
  70. +38 −38 Raven.Tests/Document/CustomDynamicClass.cs
  71. +48 −48 Raven.Tests/Document/DocumentStoreEmbeddedGranularTests.cs
  72. +20 −20 Raven.Tests/Document/DocumentStoreServerGranularTests.cs
  73. +74 −74 Raven.Tests/Document/Inheritance.cs
  74. +74 −74 Raven.Tests/Document/TotalCountServerTest.cs
  75. +68 −68 Raven.Tests/Document/WhenUsingMultipleUnshardedServers.cs
  76. +12 −12 Raven.Tests/Document/ZoneCountResult.cs
  77. +18 −18 Raven.Tests/Indexes/CustomAnalyzer.cs
  78. +61 −61 Raven.Tests/Indexes/DynamicFieldIndexing.cs
  79. +46 −46 Raven.Tests/Indexes/ExpressionOperatorPrecedenceTest.cs
  80. +19 −19 Raven.Tests/Linq/CommitInfo.cs
  81. +298 −0 Raven.Tests/Linq/GroupByAndDocumentId.cs
  82. +91 −91 Raven.Tests/Linq/PerformingQueries.cs
  83. +27 −27 Raven.Tests/Linq/SampleDynamicCompilationExtension.cs
  84. +14 −14 Raven.Tests/Linq/SampleGeoLocation.cs
  85. +26 −26 Raven.Tests/Linq/User.cs
  86. +58 −58 Raven.Tests/MailingList/Asger.cs
  87. +49 −49 Raven.Tests/MailingList/Benjamin.cs
  88. +29 −29 Raven.Tests/MailingList/BrunoLopes.cs
  89. +38 −38 Raven.Tests/MailingList/EnumAsInts.cs
  90. +28 −28 Raven.Tests/MailingList/EtagUsage.cs
  91. +88 −88 Raven.Tests/MailingList/Idsa/Casino.cs
  92. +42 −42 Raven.Tests/MailingList/Idsa/CasinosSuspensionsIndex.cs
  93. +35 −35 Raven.Tests/MailingList/IndexWithUnion.cs
  94. +111 −111 Raven.Tests/MailingList/Maverix.cs
  95. +88 −88 Raven.Tests/MailingList/NicolasGarfinkiel.cs
  96. +52 −52 Raven.Tests/MailingList/Oregon.cs
  97. +41 −41 Raven.Tests/MailingList/Random.cs
  98. +57 −57 Raven.Tests/MailingList/RecreatingIndexes.cs
  99. +55 −55 Raven.Tests/MailingList/Samina.cs
  100. +37 −37 Raven.Tests/MailingList/ronne.cs
  101. +51 −51 Raven.Tests/Munin/CanWorkWithTwoDicsInSameFile.cs
  102. +73 −73 Raven.Tests/Munin/MyToDoList.cs
  103. +93 −93 Raven.Tests/Munin/Optimize.cs
  104. +49 −49 Raven.Tests/Munin/PutsAfterRestart.cs
  105. +14 −14 Raven.Tests/Munin/ToDo.cs
  106. +125 −0 Raven.Tests/Querying/HighlightesTests.cs
  107. +16 −16 Raven.Tests/Querying/IndexedUser.cs
  108. +2 −0 Raven.Tests/Raven.Tests.csproj
  109. +10 −10 Raven.Tests/RemoteClientTest.cs
  110. +79 −79 Raven.Tests/Security/OAuth/HttpWebRequestExtensions.cs
  111. +7 −7 Raven.Tests/Shard/BlogModel/Blog.cs
  112. +158 −158 Raven.Tests/Shard/BlogModel/CanQueryOnlyPosts.cs
  113. +84 −84 Raven.Tests/Shard/BlogModel/CanQueryOnlyUsers.cs
  114. +14 −14 Raven.Tests/Shard/BlogModel/Post.cs
  115. +34 −34 Raven.Tests/Shard/BlogModel/ShardedDocumentSessionIsWorking.cs
  116. +7 −7 Raven.Tests/Shard/BlogModel/User.cs
  117. +96 −96 Raven.Tests/Shard/SimpleSharding.cs
  118. +44 −44 Raven.Tests/Spatial/Event.cs
  119. +70 −70 Raven.Tests/Storage/AbstractDocumentStorageTest.cs
  120. +127 −127 Raven.Tests/Track/RavenDB053.cs
  121. +14 −14 Raven.Tests/Triggers/AuditAttachmentPutTrigger.cs
  122. +26 −26 Raven.Tests/Triggers/Bugs/AuditContext.cs
  123. +11 −11 Raven.Tests/Triggers/Bugs/Person.cs
  124. +35 −35 Raven.Tests/Triggers/CascadeDeleteTrigger.cs
  125. +16 −16 Raven.Tests/Triggers/RefuseBigAttachmentPutTrigger.cs
  126. +25 −25 Raven.Tests/Triggers/VetoCapitalNamesPutTrigger.cs
  127. +34 −34 Raven.Tests/Util/ReflectionUtilTest.cs
  128. +95 −95 Raven.Tests/Views/ViewCompilation.cs
  129. +29 −29 Raven.Web/Web.Debug.config
  130. +30 −30 Raven.Web/Web.Release.config
  131. +56 −56 Samples/Raven.Bundles.Sample.EventSourcing.ShoppingCartAggregator/ShoppingCart.cs
  132. +18 −18 Samples/Raven.Bundles.Sample.EventSourcing.ShoppingCartAggregator/ShoppingCartCustomer.cs
  133. +63 −63 Samples/Raven.Bundles.Sample.EventSourcing.ShoppingCartAggregator/ShoppingCartEventsToShopingCart.cs
  134. +18 −18 Samples/Raven.Bundles.Sample.EventSourcing.ShoppingCartAggregator/ShoppingCartItem.cs
  135. +19 −19 Samples/Raven.Bundles.Sample.EventSourcing.ShoppingCartAggregator/ShoppingCartItemProduct.cs
  136. +8 −8 Samples/Raven.Sample.EventSourcing/Read Me.txt
  137. +5 −5 Samples/Raven.Sample.EventSourcing/Start Raven.ps1
  138. +35 −35 Samples/Raven.Sample.FSharp/Program.fs
  139. +8 −8 Samples/Raven.Sample.Failover/Read Me.txt
  140. +13 −13 Samples/Raven.Sample.Failover/User.cs
  141. +124 −124 Samples/Raven.Sample.LiveProjections/Program.cs
  142. +37 −37 Samples/Raven.Sample.MultiTenancy/Program.cs
  143. +19 −19 Samples/Raven.Sample.Replication/Read Me.txt
  144. +12 −12 Samples/Raven.Sample.Replication/Start Raven.ps1
  145. +1 −1 Samples/Raven.Sample.ShardClient/.gitignore
  146. +13 −13 Samples/Raven.Sample.ShardClient/Company.cs
  147. +11 −11 Samples/Raven.Sample.ShardClient/Invoice.cs
  148. +35 −35 Samples/Raven.Sample.ShardClient/InvoicesAmountByDate.cs
  149. +11 −11 Samples/Raven.Sample.ShardClient/Read Me.txt
  150. +17 −17 Samples/Raven.Sample.ShardClient/Start Raven.ps1
  151. +21 −21 Samples/Raven.Sample.SimpleClient/Company.cs
  152. +105 −105 Samples/Raven.Sample.Suggestions/Program.cs
  153. +20 −20 Samples/Raven.Samples.Includes/Companies_ByRegion.cs
  154. +15 −15 Samples/Raven.Samples.Includes/Company.cs
  155. +63 −63 Samples/Raven.Samples.Includes/Program.cs
  156. +30,180 −30,180 SharedLibs/Esent.Interop.XML
  157. +5,413 −5,413 SharedLibs/Rhino.Mocks.xml
  158. +1,256 −1,256 SharedLibs/Silverlight/Expression/SL5/Microsoft.Expression.Interactions.xml
  159. +1,025 −1,025 SharedLibs/Silverlight/System.Windows.Interactivity.xml
  160. +1,983 −1,983 SharedLibs/Silverlight/Toolkit v5.0/Microsoft.Xna.Framework.Content.xml
  161. +330 −330 SharedLibs/Silverlight/Toolkit v5.0/Microsoft.Xna.Framework.Toolkit.xml
  162. +11 −11 SharedLibs/Silverlight/Toolkit v5.0/System.Windows.Controls.Data.DataForm.Toolkit.extmap.xml
  163. +2,831 −2,831 SharedLibs/Silverlight/Toolkit v5.0/System.Windows.Controls.Data.DataForm.Toolkit.xml
  164. +11 −11 SharedLibs/Silverlight/Toolkit v5.0/System.Windows.Controls.Data.Toolkit.extmap.xml
  165. +359 −359 SharedLibs/Silverlight/Toolkit v5.0/System.Windows.Controls.Data.Toolkit.xml
  166. +11 −11 SharedLibs/Silverlight/Toolkit v5.0/System.Windows.Controls.DataVisualization.Toolkit.extmap.xml
  167. +11,539 −11,539 SharedLibs/Silverlight/Toolkit v5.0/System.Windows.Controls.DataVisualization.Toolkit.xml
  168. +11 −11 SharedLibs/Silverlight/Toolkit v5.0/System.Windows.Controls.Input.Toolkit.extmap.xml
  169. +7,667 −7,667 SharedLibs/Silverlight/Toolkit v5.0/System.Windows.Controls.Input.Toolkit.xml
  170. +11 −11 SharedLibs/Silverlight/Toolkit v5.0/System.Windows.Controls.Layout.Toolkit.extmap.xml
  171. +2,637 −2,637 SharedLibs/Silverlight/Toolkit v5.0/System.Windows.Controls.Layout.Toolkit.xml
  172. +11 −11 SharedLibs/Silverlight/Toolkit v5.0/System.Windows.Controls.Theming.Toolkit.extmap.xml
  173. +284 −284 SharedLibs/Silverlight/Toolkit v5.0/System.Windows.Controls.Theming.Toolkit.xml
  174. +11 −11 SharedLibs/Silverlight/Toolkit v5.0/System.Windows.Controls.Toolkit.extmap.xml
  175. +9,819 −9,819 SharedLibs/Silverlight/Toolkit v5.0/System.Windows.Controls.Toolkit.xml
  176. +11 −11 SharedLibs/Silverlight/Toolkit v5.0/Testing/Microsoft.Silverlight.Testing.extmap.xml
  177. +14,823 −14,823 SharedLibs/Silverlight/Toolkit v5.0/Testing/Microsoft.Silverlight.Testing.xml
  178. +11 −11 ...light/Toolkit v5.0/Testing/Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.extmap.xml
  179. +3,429 −3,429 .../Silverlight/Toolkit v5.0/Testing/Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.xml
  180. +2 −0 default.ps1
@@ -63,6 +63,16 @@ public void Prepare(PreparingEnlistment preparingEnlistment)
catch (Exception e)
{
logger.ErrorException("Could not prepare distributed transaction", e);
+ try
+ {
+ session.Rollback(PromotableRavenClientEnlistment.GetLocalOrDistributedTransactionId(transaction));
+ DeleteFile();
+ }
+ catch (Exception e2)
+ {
+ logger.ErrorException("Could not roll back transaction after prepare failed", e2);
+ }
+
preparingEnlistment.ForceRollback(e);
return;
}
@@ -11,7 +11,10 @@ public class DatabaseCountDocumentDeleteTrigger : AbstractDeleteTrigger
{
public override void AfterDelete(string key, Abstractions.Data.TransactionInformation transactionInformation)
{
- DocQuotaConfiguration.GetConfiguration(Database).AfterDelete();
+ using (Database.DisableAllTriggersForCurrentThread())
+ {
+ DocQuotaConfiguration.GetConfiguration(Database).AfterDelete();
+ }
}
}
}
@@ -9,7 +9,10 @@ public class DatabaseSizeAttachmentDeleteTrigger : AbstractAttachmentDeleteTrigg
{
public override void AfterDelete(string key)
{
- SizeQuotaConfiguration.GetConfiguration(Database).AfterDelete();
+ using (Database.DisableAllTriggersForCurrentThread())
+ {
+ SizeQuotaConfiguration.GetConfiguration(Database).AfterDelete();
+ }
}
}
}
@@ -9,7 +9,10 @@ public class DatabaseSizeDocumentDeleteTrigger : AbstractDeleteTrigger
{
public override void AfterDelete(string key, Abstractions.Data.TransactionInformation transactionInformation)
{
- SizeQuotaConfiguration.GetConfiguration(Database).AfterDelete();
+ using (Database.DisableAllTriggersForCurrentThread())
+ {
+ SizeQuotaConfiguration.GetConfiguration(Database).AfterDelete();
+ }
}
}
}
@@ -271,19 +271,19 @@ private string TrimEdges(StringBuilder buffer, int startOffset, int endOffset, o
localStart = startOffset;
}
- if (endOffset != buffer.Length && buffer[endOffset] != ' ')
- {
- while (buffer[localEnd] != ' ' && localEnd != localStart && localEnd > minEnd)
- {
- localEnd--;
- }
+ if (endOffset + 1 < buffer.Length && buffer[endOffset + 1] != ' ')
+ {
+ while (buffer[localEnd] != ' ' && localEnd != localStart && localEnd > minEnd)
+ {
+ localEnd--;
+ }
- if (localEnd == localStart)
- {
- localEnd = endOffset;
- localStart = startOffset;
- }
- }
+ if (localEnd == localStart)
+ {
+ localEnd = endOffset;
+ localStart = startOffset;
+ }
+ }
retStartOffset = localStart;
return buffer.ToString(localStart, localEnd - localStart);
@@ -0,0 +1,28 @@
+using System;
+using System.Linq;
+using ICSharpCode.NRefactory.CSharp;
+using Raven.Database.Linq.PrivateExtensions;
+
+namespace Raven.Database.Linq.Ast
+{
+ [CLSCompliant(false)]
+ public class TransformGroupByExtensionMethodTransformer : DepthFirstAstVisitor<object,object>
+ {
+ public override object VisitInvocationExpression(InvocationExpression invocationExpression, object data)
+ {
+ var memberReferenceExpression = invocationExpression.Target as MemberReferenceExpression;
+ if (memberReferenceExpression != null && memberReferenceExpression.MemberName == "GroupBy")
+ {
+ var newInvocation = new InvocationExpression(
+ new MemberReferenceExpression(
+ new TypeReferenceExpression(new SimpleType(typeof (LinqOnDynamic).FullName)),
+ memberReferenceExpression.MemberName),
+ invocationExpression.Arguments.Select(x => x.Clone())
+ );
+ invocationExpression.ReplaceWith(newInvocation);
+ }
+
+ return base.VisitInvocationExpression(invocationExpression, data);
+ }
+ }
+}
@@ -355,7 +355,7 @@ private static LambdaExpression GetLambdaExpression(InvocationExpression invocat
private void ValidateMapReduceFields(List<string> mapFields)
{
- mapFields.Remove("__document_id");
+ mapFields.Remove(Constants.DocumentIdFieldName);
var reduceFields = captureSelectNewFieldNamesVisitor.FieldNames;
if (reduceFields.SetEquals(mapFields) == false)
{
@@ -425,12 +425,24 @@ private bool AddDocumentIdFieldToLambdaIfCreatingNewObject(LambdaExpression lamb
return false;
var initializers = objectCreateExpression.Initializers;
-
- var identifierExpression = new IdentifierExpression(lambdaExpression.Parameters.First().Name);
-
if (initializers.OfType<NamedExpression>().Any(x => x.Name == Constants.DocumentIdFieldName))
return false;
+ var parameter = lambdaExpression.Parameters.First();
+ var identifier = parameter.Name;
+
+ // Support getting the __document_id from IGrouping parameter
+ var castExpression = parameter.Parent.Parent.Parent as CastExpression;
+ if (castExpression != null)
+ {
+ var simpleType = castExpression.Type as SimpleType;
+ if (simpleType != null && simpleType.Identifier == "Func<IGrouping<dynamic,dynamic>, dynamic>")
+ {
+ identifier += ".Key";
+ }
+ }
+
+ var identifierExpression = new IdentifierExpression(identifier);
objectCreateExpression.Initializers.Add(new NamedExpression
{
Name = Constants.DocumentIdFieldName,
@@ -42,6 +42,11 @@ IEnumerator IEnumerable.GetEnumerator()
return Enumerable.GroupBy(source, keySelector).Select(inner => new WrapperGrouping(inner));
}
+ public static IEnumerable<IGrouping<dynamic, dynamic>> GroupBy(this IEnumerable<dynamic> source, Func<dynamic, dynamic> keySelector, Func<dynamic, dynamic> resultSelector)
+ {
+ return Enumerable.GroupBy(source, keySelector, resultSelector).Select(inner => new WrapperGrouping(inner));
+ }
+
private static IEnumerable<dynamic> Select(this object self)
{
if (self == null || self is DynamicNullObject)
@@ -238,6 +238,7 @@
<Compile Include="Indexing\RavenPerFieldAnalyzerWrapper.cs" />
<Compile Include="Indexing\Spatial\RecursivePrefixTreeStrategyThatSupportsWithin.cs" />
<Compile Include="Json\ScriptsCache.cs" />
+ <Compile Include="Linq\Ast\TransformGroupByExtensionMethodTransformer.cs" />
<Compile Include="Linq\Ast\ThrowOnInvalidMethodCallsForTransformResults.cs" />
<Compile Include="Linq\Ast\TransformObsoleteMethods.cs" />
<Compile Include="Linq\CodeVerifier.cs" />
@@ -29,6 +29,7 @@
using Raven.Json.Linq;
using Raven.Server;
using Xunit;
+using Xunit.Sdk;
namespace Raven.Tests.Helpers
{
@@ -356,5 +357,23 @@ protected static void PrintServerErrors(ServerError[] serverErrors)
else
Console.WriteLine("No server errors");
}
+
+ protected void AssertNoIndexErrors(IDocumentStore documentStore)
+ {
+ var embeddableDocumentStore = documentStore as EmbeddableDocumentStore;
+ var errors = embeddableDocumentStore != null
+ ? embeddableDocumentStore.DocumentDatabase.Statistics.Errors
+ : documentStore.DatabaseCommands.GetStatistics().Errors;
+
+ try
+ {
+ Assert.Empty(errors);
+ }
+ catch (EmptyException)
+ {
+ Console.WriteLine(errors.First().Error);
+ throw;
+ }
+ }
}
}
@@ -1,75 +1,75 @@
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using Microsoft.Silverlight.Testing;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Raven.Abstractions.Indexing;
-using Raven.Client.Document;
-using Raven.Client.Extensions;
-using Raven.Tests.Document;
-
-namespace Raven.Tests.Silverlight
-{
- public class Statistics : RavenTestBase
- {
- [Asynchronous]
- public IEnumerable<Task> CanRetrieveStatisticsForTheDefaultDatabase()
- {
- using (var documentStore = new DocumentStore {Url = Url + Port}.Initialize())
- {
- var getStats = documentStore.AsyncDatabaseCommands
- .GetStatisticsAsync();
- yield return getStats;
-
- Assert.IsNotNull(getStats.Result);
- }
- }
-
- [Asynchronous]
- public IEnumerable<Task> CanRetrieveStatisticsForADatabase()
- {
- var dbname = GenerateNewDatabaseName();
- using (var documentStore = new DocumentStore {Url = Url + Port}.Initialize())
- {
- yield return documentStore.AsyncDatabaseCommands.EnsureDatabaseExistsAsync(dbname);
-
- yield return documentStore.AsyncDatabaseCommands.ForDatabase(dbname).PutIndexAsync("test", new IndexDefinition
- {
- Map = "from doc in docs select new { doc.Name}"
- }, true);
-
- var getStats = documentStore.AsyncDatabaseCommands.ForDatabase(dbname).GetStatisticsAsync();
- yield return getStats;
-
- var stats = getStats.Result;
- Assert.AreEqual(0, stats.CountOfDocuments);
- Assert.IsTrue(stats.CountOfIndexes > 0);
- }
- }
-
- [Asynchronous]
- public IEnumerable<Task> StatisticsShouldNotBeCached()
- {
- var dbname = GenerateNewDatabaseName();
- using (var documentStore = new DocumentStore {Url = Url + Port}.Initialize())
- {
- yield return documentStore.AsyncDatabaseCommands.EnsureDatabaseExistsAsync(dbname);
-
- var getStats = documentStore.AsyncDatabaseCommands.ForDatabase(dbname).GetStatisticsAsync();
- yield return getStats;
-
- Assert.AreEqual(0, getStats.Result.CountOfDocuments);
-
- using (var session = documentStore.OpenAsyncSession(dbname))
- {
- session.Store(new Company {Name = "Change the Stats, Inc."});
- yield return session.SaveChangesAsync();
- }
-
- var verifyStats = documentStore.AsyncDatabaseCommands.ForDatabase(dbname).GetStatisticsAsync();
- yield return verifyStats;
-
- Assert.AreEqual(1, verifyStats.Result.CountOfDocuments);
- }
- }
- }
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using Microsoft.Silverlight.Testing;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Raven.Abstractions.Indexing;
+using Raven.Client.Document;
+using Raven.Client.Extensions;
+using Raven.Tests.Document;
+
+namespace Raven.Tests.Silverlight
+{
+ public class Statistics : RavenTestBase
+ {
+ [Asynchronous]
+ public IEnumerable<Task> CanRetrieveStatisticsForTheDefaultDatabase()
+ {
+ using (var documentStore = new DocumentStore {Url = Url + Port}.Initialize())
+ {
+ var getStats = documentStore.AsyncDatabaseCommands
+ .GetStatisticsAsync();
+ yield return getStats;
+
+ Assert.IsNotNull(getStats.Result);
+ }
+ }
+
+ [Asynchronous]
+ public IEnumerable<Task> CanRetrieveStatisticsForADatabase()
+ {
+ var dbname = GenerateNewDatabaseName();
+ using (var documentStore = new DocumentStore {Url = Url + Port}.Initialize())
+ {
+ yield return documentStore.AsyncDatabaseCommands.EnsureDatabaseExistsAsync(dbname);
+
+ yield return documentStore.AsyncDatabaseCommands.ForDatabase(dbname).PutIndexAsync("test", new IndexDefinition
+ {
+ Map = "from doc in docs select new { doc.Name}"
+ }, true);
+
+ var getStats = documentStore.AsyncDatabaseCommands.ForDatabase(dbname).GetStatisticsAsync();
+ yield return getStats;
+
+ var stats = getStats.Result;
+ Assert.AreEqual(0, stats.CountOfDocuments);
+ Assert.IsTrue(stats.CountOfIndexes > 0);
+ }
+ }
+
+ [Asynchronous]
+ public IEnumerable<Task> StatisticsShouldNotBeCached()
+ {
+ var dbname = GenerateNewDatabaseName();
+ using (var documentStore = new DocumentStore {Url = Url + Port}.Initialize())
+ {
+ yield return documentStore.AsyncDatabaseCommands.EnsureDatabaseExistsAsync(dbname);
+
+ var getStats = documentStore.AsyncDatabaseCommands.ForDatabase(dbname).GetStatisticsAsync();
+ yield return getStats;
+
+ Assert.AreEqual(0, getStats.Result.CountOfDocuments);
+
+ using (var session = documentStore.OpenAsyncSession(dbname))
+ {
+ session.Store(new Company {Name = "Change the Stats, Inc."});
+ yield return session.SaveChangesAsync();
+ }
+
+ var verifyStats = documentStore.AsyncDatabaseCommands.ForDatabase(dbname).GetStatisticsAsync();
+ yield return verifyStats;
+
+ Assert.AreEqual(1, verifyStats.Result.CountOfDocuments);
+ }
+ }
+ }
}
Oops, something went wrong.

0 comments on commit 5229070

Please sign in to comment.