Permalink
Browse files

Added ViewManager

  • Loading branch information...
1 parent da1b0ef commit 2c04972b135782fc51868a66b533ebde3dfc8812 @hhariri committed Jan 23, 2011
Showing with 402 additions and 220 deletions.
  1. +11 −17 src/EasyCouchDB.Specs/AttachmentSpecs.cs
  2. +51 −70 src/EasyCouchDB.Specs/CRUDSpecs.cs
  3. +2 −0 src/EasyCouchDB.Specs/EasyCouchDB.Specs.csproj
  4. +2 −4 src/EasyCouchDB.Specs/Helpers/User.cs
  5. +4 −17 src/EasyCouchDB.Specs/LinqSpecs.cs
  6. +5 −2 src/EasyCouchDB.Specs/Properties/AssemblyInfo.cs
  7. +25 −0 src/EasyCouchDB.Specs/QueryManagerSpecs.cs
  8. +30 −0 src/EasyCouchDB.Specs/ViewManagerSpecs.cs
  9. +44 −56 src/EasyCouchDB/CouchDatabase.cs
  10. +7 −7 src/EasyCouchDB/CouchServer.cs
  11. +2 −0 src/EasyCouchDB/Document.cs
  12. +15 −8 src/EasyCouchDB/EasyCouchDB.csproj
  13. +1 −1 src/EasyCouchDB/ICouchDatabase.cs
  14. +2 −2 src/EasyCouchDB/{ → Infrastructure}/AllDocsRows.cs
  15. +1 −1 src/EasyCouchDB/{ → Infrastructure}/AttachmentException.cs
  16. +1 −1 src/EasyCouchDB/{ → Infrastructure}/DocsRows.cs
  17. +1 −1 src/EasyCouchDB/{ → Infrastructure}/DocumentConflictException.cs
  18. +1 −1 src/EasyCouchDB/{ → Infrastructure}/DocumentNotFoundException.cs
  19. +24 −0 src/EasyCouchDB/Infrastructure/DocumentUpdateException.cs
  20. +2 −2 src/EasyCouchDB/{ → Infrastructure}/MultiRowResponseWrapperForAllDocs.cs
  21. +2 −2 src/EasyCouchDB/{ → Infrastructure}/MultiRowResponseWrapperForDocs.cs
  22. +24 −0 src/EasyCouchDB/Infrastructure/ViewException.cs
  23. +5 −2 src/EasyCouchDB/Properties/AssemblyInfo.cs
  24. +12 −0 src/EasyCouchDB/Queries/QueryManager.cs
  25. +0 −26 src/EasyCouchDB/ViewManager.cs
  26. +11 −0 src/EasyCouchDB/Views/IViewManager.cs
  27. +19 −0 src/EasyCouchDB/Views/MapReduce.cs
  28. +19 −0 src/EasyCouchDB/Views/ViewDocument.cs
  29. +64 −0 src/EasyCouchDB/Views/ViewManager.cs
  30. +15 −0 src/EasyCouchDB/Views/Views.cs
@@ -4,43 +4,37 @@
namespace EasyCouchDB.Specs
{
-
-
- [Subject(typeof(CouchDatabase<User, string>), "given a document database")]
- public class when_adding_an_attachment_to_an_existing_document : DatabaseContext
+ [Subject(typeof (CouchDatabase<User, string>), "given a document database")]
+ public class when_adding_an_attachment_to_an_existing_document : ServerAndDatabaseContext
{
Because of = () =>
{
- var imageFile = Path.Combine("Helpers", "test.jpg");
+ string imageFile = Path.Combine("Helpers", "test.jpg");
- couchDb.SaveAttachment(DocumentId, imageFile, "image/jpeg");
+ Database.SaveAttachment(DocumentId, imageFile, "image/jpeg");
};
It should_add_it = () => { };
static User user;
static string id;
- }
-
- [Subject(typeof(CouchDatabase<User, string>), "given a document database")]
- public class when_deleting_an_attachment : DatabaseContext
+ }
+
+ [Subject(typeof (CouchDatabase<User, string>), "given a document database")]
+ public class when_deleting_an_attachment : ServerAndDatabaseContext
{
Establish context = () =>
{
- var imageFile = Path.Combine("Helpers", "test.jpg");
+ string imageFile = Path.Combine("Helpers", "test.jpg");
- couchDb.SaveAttachment(DocumentId, imageFile, "image/jpeg");
+ Database.SaveAttachment(DocumentId, imageFile, "image/jpeg");
};
- Because of = () =>
- {
- couchDb.DeleteAttachment(DocumentId, "test.jpg");
- };
+ Because of = () => { Database.DeleteAttachment(DocumentId, "test.jpg"); };
It should_delete_it = () => { };
static User user;
static string id;
}
-
}
@@ -1,20 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using EasyCouchDB.Infrastructure;
using EasyCouchDB.Specs.Helpers;
using Machine.Specifications;
namespace EasyCouchDB.Specs
{
- [Subject(typeof(CouchDatabase<User, string>), "given a document database")]
- public class when_creating_a_new_document_with_no_id: DatabaseContext
+ [Subject(typeof (CouchDatabase<User, string>), "given a document database")]
+ public class when_creating_a_new_document_with_no_id : ServerAndDatabaseContext
{
Because of = () =>
{
user = new User {Fullname = "Jackson"};
- id = couchDb.Save(user);
-
+ id = Database.Save(user);
};
It should_create_the_document_and_return_a_generated_id = () => id.ShouldNotBeEmpty();
@@ -23,17 +23,16 @@ public class when_creating_a_new_document_with_no_id: DatabaseContext
static string id;
}
- [Subject(typeof(CouchDatabase<User, string>), "given a document database")]
- public class when_creating_a_new_document_provided_an_id: DatabaseContext
+ [Subject(typeof (CouchDatabase<User, string>), "given a document database")]
+ public class when_creating_a_new_document_provided_an_id : ServerAndDatabaseContext
{
Because of = () =>
{
- var randomDocumentId = GetRandomDocumentId();
-
- user = new User {Id = randomDocumentId , Fullname = "Jackson"};
+ string randomDocumentId = GetRandomDocumentId();
- id = couchDb.Save(user);
+ user = new User {Id = randomDocumentId, Fullname = "Jackson"};
+ id = Database.Save(user);
};
It should_create_the_document_and_return_the_given_id = () => id.ShouldEqual(user.Id);
@@ -42,49 +41,43 @@ public class when_creating_a_new_document_provided_an_id: DatabaseContext
static string id;
}
- [Subject(typeof(CouchDatabase<User, string>), "given a document database")]
- public class when_updating_an_existing_document: DatabaseContext
+ [Subject(typeof (CouchDatabase<User, string>), "given a document database")]
+ public class when_updating_an_existing_document : ServerAndDatabaseContext
{
Establish context = () =>
{
- var randomDocumentId = GetRandomDocumentId();
-
- user = new User { Id = randomDocumentId, Fullname = "Jackson" };
+ string randomDocumentId = GetRandomDocumentId();
- id = couchDb.Save(user);
+ user = new User {Id = randomDocumentId, Fullname = "Jackson"};
+ id = Database.Save(user);
};
Because of = () =>
{
- var document = couchDb.Load(id);
+ User document = Database.Load(id);
document.Fullname = "New Name";
- couchDb.Save(document);
-
+ Database.Save(document);
};
It should_update_the_document = () =>
{
- var updatedDocument = couchDb.Load(id);
+ User updatedDocument = Database.Load(id);
updatedDocument.Fullname.ShouldEqual("New Name");
};
+
static User user;
static string id;
}
-
-
- [Subject(typeof(CouchDatabase<User, string>), "given a document database")]
- public class when_getting_a_document_by_id_that_exists: DatabaseContext
- {
- Because of = () =>
- {
- user = couchDb.Load(DocumentId);
- };
+ [Subject(typeof (CouchDatabase<User, string>), "given a document database")]
+ public class when_getting_a_document_by_id_that_exists : ServerAndDatabaseContext
+ {
+ Because of = () => { user = Database.Load(DocumentId); };
It should_retrieve_the_document = () => user.ShouldNotBeNull();
@@ -97,97 +90,85 @@ public class when_getting_a_document_by_id_that_exists: DatabaseContext
static User user;
}
- [Subject(typeof(CouchDatabase<User, string>), "given a document database")]
- public class when_deleting_an_existing_document: DatabaseContext
+ [Subject(typeof (CouchDatabase<User, string>), "given a document database")]
+ public class when_deleting_an_existing_document : ServerAndDatabaseContext
{
Establish context = () =>
{
randomDocumentId = string.Format("{0}DeleteTest", GetRandomDocumentId());
- couchDb.Save(new User() { Id = randomDocumentId });
+ Database.Save(new User {Id = randomDocumentId});
};
- Because of = () =>
- {
- couchDb.Delete(randomDocumentId);
- };
+ Because of = () => { Database.Delete(randomDocumentId); };
It should_delete_the_document = () =>
{
try
{
- couchDb.Load(randomDocumentId);
+ Database.Load(randomDocumentId);
}
catch (DocumentNotFoundException)
{
true.ShouldBeTrue();
}
- };
+ };
static string randomDocumentId;
}
- [Subject(typeof(CouchDatabase<User, string>), "given a document database")]
- public class when_getting_a_list_of_documents: DatabaseContext
+ [Subject(typeof (CouchDatabase<User, string>), "given a document database")]
+ public class when_getting_a_list_of_documents : ServerAndDatabaseContext
{
Because of = () =>
{
- documents = from d in couchDb.Documents()
+ documents = from d in Database.GetDocuments()
select d;
-
};
- It should_return_all_documents = () =>
- {
- documents.ShouldNotBeEmpty();
- };
+ It should_return_all_documents = () => { documents.ShouldNotBeEmpty(); };
- It should_set_document_properties = () =>
- {
- documents.First().Fullname.ShouldNotBeEmpty();
- };
+ It should_set_document_properties = () => { documents.First().Fullname.ShouldNotBeEmpty(); };
static IEnumerable<User> documents;
}
-
- public class DatabaseContext
+ public class ServerAndDatabaseContext
{
- Establish context = () =>
- {
- DocumentId = GetRandomDocumentId();
-
- var connection = new CouchServer("localhost", 5984, "easycouchdb");
-
- couchDb = new CouchDatabase<User, string>(connection);
-
- var user = new User { Id = DocumentId, Fullname = "My First User", EmailAddress = "MyEmail@MyDomain.com" };
-
- couchDb.Save(user);
-
- };
+ protected static ICouchDatabase<User, string> Database;
+ protected static ICouchServer Server;
+ protected static string DocumentId;
Cleanup cleanup = () =>
{
try
{
- couchDb.Delete("_design/easycouchdb_views");
+ Database.Delete("_design/easycouchdb_view_all");
}
catch (Exception)
{
-
throw;
}
};
- protected static ICouchDatabase<User, string> couchDb;
- protected static string DocumentId;
+ Establish context = () =>
+ {
+ DocumentId = GetRandomDocumentId();
+
+ Server = new CouchServer("localhost", 5984, "easycouchdb");
+
+ Database = new CouchDatabase<User, string>(Server);
+
+ var user = new User {Id = DocumentId, Fullname = "My First User", EmailAddress = "MyEmail@MyDomain.com"};
+
+ Database.Save(user);
+ };
protected static string GetRandomDocumentId()
{
var random = new Random();
-
+
return String.Format("{0}{1}", DateTime.Now.Ticks, random.Next(10, 10000));
}
}
@@ -49,6 +49,8 @@
<Compile Include="LinqSpecs.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="CRUDSpecs.cs" />
+ <Compile Include="QueryManagerSpecs.cs" />
+ <Compile Include="ViewManagerSpecs.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\EasyCouchDB\EasyCouchDB.csproj">
@@ -1,8 +1,6 @@
-using System;
-
-namespace EasyCouchDB.Specs.Helpers
+namespace EasyCouchDB.Specs.Helpers
{
- public class User: Document<string>
+ public class User : Document<string>
{
public string Fullname { get; set; }
public string EmailAddress { get; set; }
@@ -2,26 +2,13 @@
namespace EasyCouchDB.Specs
{
- [Subject( "given document database")]
+ [Subject("given document database")]
public class when_context
{
- Establish context = () =>
- {
+ Establish context = () => { };
- };
-
- Because of = () =>
- {
-
-
- };
-
- It should_objective = () =>
- {
-
- };
+ Because of = () => { };
+ It should_objective = () => { };
}
-
-
}
@@ -1,10 +1,10 @@
using System.Reflection;
-using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
+
[assembly: AssemblyTitle("EasyCouchDB.Specs")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
@@ -17,9 +17,11 @@
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
+
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
+
[assembly: Guid("1a70a720-7373-4687-bcba-f06c0b92d01f")]
// Version information for an assembly consists of the following four values:
@@ -32,5 +34,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
+
[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
Oops, something went wrong.

0 comments on commit 2c04972

Please sign in to comment.