Permalink
Browse files

Merge kolosy

  • Loading branch information...
2 parents d4e06f3 + bdb8960 commit bdd7080c4ff46ad79e31eb80c76d0eeb90813054 @henrikwallstrom henrikwallstrom committed Mar 24, 2010
@@ -63,7 +63,7 @@ public override void ReadJson(JObject obj)
HorsePowers = obj["Hps"].Value<int>();
}
- public override IReconcilingDocument GetDatabaseCopy(CouchDatabase db)
+ public override IReconcilingDocument GetDatabaseCopy(ICouchDatabase db)
{
return db.GetDocument<Car>(Id);
}
@@ -79,13 +79,20 @@ public void SetUp()
var host = ConfigurationManager.AppSettings["CouchHost"] ?? "localhost";
var port = Convert.ToInt32(ConfigurationManager.AppSettings["CouchPort"] ?? "5984");
server = new CouchServer(host, port);
+ DbName = GetNewDbName();
db = server.GetNewDatabase(DbName);
}
[TearDown]
public void TearDown()
{
- db.Delete();
+ try
+ {
+ db.Delete();
+ }
+ catch
+ {
+ }
}
#endregion
@@ -153,8 +160,14 @@ public void ShouldCauseConflictOnNewDoc()
db.SaveDocument(doc2);
}
- private CouchServer server;
- private CouchDatabase db;
- private const string DbName = "divan_reconcile_unit_tests";
+ private ICouchServer server;
+ private ICouchDatabase db;
+ private string DbName;
+
+ private static string GetNewDbName()
+ {
+ return "divan_reconcile_unit_tests" + DateTime.Now.Ticks;
+ }
+
}
}
View
@@ -33,20 +33,32 @@ public void SetUp()
var host = ConfigurationManager.AppSettings["CouchHost"] ?? "localhost";
var port = Convert.ToInt32(ConfigurationManager.AppSettings["CouchPort"] ?? "5984");
server = new CouchServer(host, port);
+ DbName = GetNewDbName();
db = server.GetNewDatabase(DbName);
}
[TearDown]
public void TearDown()
{
- db.Delete();
+ try
+ {
+ db.Delete();
+ }
+ catch
+ {
+ }
}
#endregion
- private CouchServer server;
- private CouchDatabase db;
- private const string DbName = "divan_unit_tests";
+ private ICouchServer server;
+ private ICouchDatabase db;
+ private string DbName;
+
+ private static string GetNewDbName()
+ {
+ return "divan_unit_tests" + DateTime.Now.Ticks;
+ }
[Test]
public void ShouldCheckChangedDocument()
@@ -74,6 +74,7 @@ public void SetUp()
var host = ConfigurationManager.AppSettings["CouchHost"] ?? "localhost";
var port = Convert.ToInt32(ConfigurationManager.AppSettings["CouchPort"] ?? "5984");
server = new CouchServer(host, port);
+ DbName = GetNewDbName();
db = server.GetNewDatabase(DbName);
Car car = null;
@@ -119,14 +120,26 @@ public void ShouldHandleTransformationQuery()
[TearDown]
public void TearDown()
{
- db.Delete();
+ try
+ {
+ db.Delete();
+ }
+ catch
+ {
+ }
}
#endregion
- private CouchServer server;
- private CouchDatabase db;
- private CouchViewDefinition tempView;
- private const string DbName = "divan_linq_unit_tests";
+ private ICouchServer server;
+ private ICouchDatabase db;
+ private ICouchViewDefinition tempView;
+ private string DbName;
+
+ private static string GetNewDbName()
+ {
+ return "divan_linq_unit_tests" + DateTime.Now.Ticks;
+ }
+
}
}
@@ -31,14 +31,21 @@ public void SetUp()
[TearDown]
public void TearDown()
{
- db.Delete();
+ try
+ {
+ db.Delete();
+ }
+ catch
+ {
+ }
}
#endregion
- private CouchServer server;
- private CouchDatabase db;
- private const string DbName = "divan_lucene_unit_tests";
+ private ICouchServer server;
+ private ICouchDatabase db;
+ private string DbName { get { return "divan_lucene_unit_tests" + DateTime.Now.Ticks; } }
+
[Test]
public void ShouldHandleTrivialQuery()
View
@@ -1,4 +1,4 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Net;
@@ -15,7 +15,7 @@ namespace Divan
/// This is the main API to work with CouchDB. One useful approach is to create your own subclasses
/// for your different databases.
/// </summary>
- public class CouchDatabase
+ public class CouchDatabase : Divan.ICouchDatabase
{
private string name;
public readonly IList<CouchDesignDocument> DesignDocuments = new List<CouchDesignDocument>();
@@ -25,13 +25,13 @@ public CouchDatabase()
Name = "default";
}
- public CouchDatabase(CouchServer server)
+ public CouchDatabase(ICouchServer server)
: this()
{
Server = server;
}
- public CouchDatabase(string name, CouchServer server)
+ public CouchDatabase(string name, ICouchServer server)
{
Name = name;
Server = server;
@@ -51,7 +51,7 @@ public string Name
}
}
- public CouchServer Server { get; set; }
+ public ICouchServer Server { get; set; }
public bool RunningOnMono()
{
@@ -68,7 +68,7 @@ public CouchDesignDocument NewDesignDocument(string aName)
/// <summary>
/// Only to be used when developing.
/// </summary>
- public CouchViewDefinition NewTempView(string designDoc, string viewName, string mapText)
+ public ICouchViewDefinition NewTempView(string designDoc, string viewName, string mapText)
{
var doc = NewDesignDocument(designDoc);
var view = doc.AddView(viewName, "function (doc) {" + mapText + "}");
@@ -89,12 +89,12 @@ public void SynchDesignDocuments()
}
}
- public CouchRequest Request()
+ public ICouchRequest Request()
{
return new CouchRequest(this);
}
- public CouchRequest Request(string path)
+ public ICouchRequest Request(string path)
{
return (new CouchRequest(this)).Path(path);
}
@@ -104,7 +104,7 @@ public int CountDocuments()
return (Request().Parse())["doc_count"].Value<int>();
}
- public CouchRequest RequestAllDocuments()
+ public ICouchRequest RequestAllDocuments()
{
return Request("_all_docs");
}
@@ -512,7 +512,7 @@ public void SaveDocuments(IEnumerable<ICouchDocument> documents, bool allOrNothi
}
}
- public void SaveArbitraryDocuments<T>(IEnumerable<T> documents, int chunkCount, List<CouchViewDefinition> views, bool allOrNothing)
+ public void SaveArbitraryDocuments<T>(IEnumerable<T> documents, int chunkCount, IEnumerable<ICouchViewDefinition> views, bool allOrNothing)
{
SaveDocuments(
documents.Select(doc => new CouchDocumentWrapper<T>(doc)).Cast<ICouchDocument>(),
@@ -528,7 +528,7 @@ public void SaveArbitraryDocuments<T>(IEnumerable<T> documents, int chunkCount,
/// <param name="documents">List of documents to store.</param>
/// <param name="chunkCount">Number of documents to store per "POST"</param>
/// <param name="views">List of views to touch per chunk.</param>
- public void SaveDocuments(IEnumerable<ICouchDocument> documents, int chunkCount, List<CouchViewDefinition> views, bool allOrNothing)
+ public void SaveDocuments(IEnumerable<ICouchDocument> documents, int chunkCount, IEnumerable<ICouchViewDefinition> views, bool allOrNothing)
{
var chunk = new List<ICouchDocument>(chunkCount);
int counter = 0;
@@ -558,12 +558,12 @@ public void SaveDocuments(IEnumerable<ICouchDocument> documents, int chunkCount,
TouchViews(views);
}
- public void TouchViews(List<CouchViewDefinition> views)
+ public void TouchViews(IEnumerable<ICouchViewDefinition> views)
{
//var timer = new Stopwatch();
if (views != null)
{
- foreach (CouchViewDefinition view in views)
+ foreach (var view in views)
{
if (view != null)
{
@@ -665,7 +665,7 @@ public CouchQuery Query(string designName, string viewName)
return Query(new CouchViewDefinition(viewName, NewDesignDocument(designName)));
}
- public CouchQuery Query(CouchViewDefinition view)
+ public CouchQuery Query(ICouchViewDefinition view)
{
return new CouchQuery(view);
}
@@ -866,4 +866,4 @@ public void Copy(ICouchDocument sourceDocument, ICouchDocument destinationDocume
Copy(sourceDocument.Id, destinationDocument.Id, destinationDocument.Rev);
}
}
-}
+}
@@ -18,9 +18,9 @@ public class CouchDesignDocument : CouchDocument, IEquatable<CouchDesignDocument
public IList<CouchLuceneViewDefinition> LuceneDefinitions = new List<CouchLuceneViewDefinition>();
public string Language = "javascript";
- public CouchDatabase Owner;
+ public ICouchDatabase Owner;
- public CouchDesignDocument(string documentId, CouchDatabase owner)
+ public CouchDesignDocument(string documentId, ICouchDatabase owner)
: base("_design/" + documentId)
{
Owner = owner;
View
@@ -198,7 +198,7 @@ public virtual void Reconcile(ICouchDocument databaseCopy)
Rev = databaseCopy.Rev;
}
- public virtual IReconcilingDocument GetDatabaseCopy(CouchDatabase db)
+ public virtual IReconcilingDocument GetDatabaseCopy(ICouchDatabase db)
{
return db.GetDocument<CouchDocument>(Id);
}
View
@@ -13,15 +13,15 @@ namespace Divan
/// </summary>
public class CouchQuery
{
- public readonly CouchViewDefinition View;
+ public readonly ICouchViewDefinition View;
// Special options
public bool checkETagUsingHead;
public Dictionary<string, string> Options = new Dictionary<string, string>();
public string postData;
public CouchViewResult Result;
- public CouchQuery(CouchViewDefinition view)
+ public CouchQuery(ICouchViewDefinition view)
{
View = view;
}
@@ -211,7 +211,7 @@ public bool IsCachedAndValid()
{
return false;
}
- CouchRequest req = View.Request().QueryOptions(Options);
+ ICouchRequest req = View.Request().QueryOptions(Options);
req.Etag(Result.etag);
return req.Head().Send().IsETagValid();
}
@@ -223,7 +223,7 @@ public string String()
}
- public CouchRequest Request()
+ public ICouchRequest Request()
{
var req = View.Request().QueryOptions(Options);
if (postData != null)
Oops, something went wrong.

0 comments on commit bdd7080

Please sign in to comment.