diff --git a/README.rdoc b/README.rdoc
index d74143f..899adcd 100644
--- a/README.rdoc
+++ b/README.rdoc
@@ -39,11 +39,9 @@ in any mono release after 2.4.2.3 (I guess). Then we will remove that check.
== What about documentation?
At the moment documentation is... this file! :) But there are also unit tests in the separate Tests project:
-* CouchTest.cs that runs against a CouchDB server.
+* CouchTest.cs that runs against a CouchDB server, see the class comment for some instructions.
* Lucene/CouchLuceneTest.cs that tests the CouchDB-Lucene integration if you have it, see article below.
-When running the tests they will expect CouchDB running at localhost:5984, unless you copy the App.config.template to App.config and edit it.
-
There is also one sample project "Trivial" showing basic usage. More samples with more advanced usage is coming soon.
* One blog article[http://goran.krampe.se/blog/Divan/divan-plus-couchdb-lucene.rdoc] on how to install Couchdb-Lucene and test it with Divan.
@@ -68,4 +66,4 @@ Apart from polishing and fixing bugs the following pieces are on the todolist:
* Writing a tutorial and a sample project showing the advanced mechanisms.
== Contributing
-...is simple. All contributions should be under the MIT license. Just fork and make pull requests and we will try to integrate. Feel free to bring up anything on the mailinglist. We haven't started using any issue tracker yet, but we will if it gets more popular and we when we do a proper release.
\ No newline at end of file
+...is simple. All contributions should be under the MIT license. Just fork and make pull requests and we will try to integrate. Feel free to bring up anything on the mailinglist. We haven't started using any issue tracker yet, but we will if it gets more popular and we when we do a proper release.
diff --git a/Tests/CouchTest.cs b/Tests/CouchTest.cs
index 228026a..4c64449 100644
--- a/Tests/CouchTest.cs
+++ b/Tests/CouchTest.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
+using System.IO;
using System.Text.RegularExpressions;
using Newtonsoft.Json.Linq;
using NUnit.Framework;
@@ -11,8 +12,12 @@ namespace Divan.Test
{
///
/// Unit tests for Divan. Operates in a separate CouchDB database called divan_unit_tests.
- /// If you are not running a CouchDB on localhost:5984 you will need to edit
- /// the Tests/App.config file.
+ /// If you are not running a CouchDB on localhost:5984 you will need to first edit
+ /// the Tests/App.config file to point somewhere else.
+ ///
+ /// NOTE: App.config is copied to Tests/bin/Debug/Divan.Test.dll.config as a
+ /// Custom Command in the Makefile! if someone can tell me how to handle this better on
+ /// Mono/Monodevelop I am all ears.
///
/// Run from command line using something like:
/// nunit-console2 --labels -run=Divan.Test.CouchTest Tests/bin/Debug/Tests.dll
@@ -202,15 +207,33 @@ public void ShouldStoreGetAndDeleteAttachment()
{
var doc = new CouchJsonDocument("{\"CPU\": \"Intel\"}");
ICouchDocument cd = db.CreateDocument(doc);
- Assert.That(db.HasAttachment(cd), Is.False);
- db.WriteAttachment(cd, "jabbadabba", "text/plain");
- Assert.That(db.HasAttachment(cd), Is.True);
- Assert.That(db.ReadAttachment(cd), Is.EqualTo("jabbadabba"));
- db.WriteAttachment(cd, "jabbadabba-doo", "text/plain");
- Assert.That(db.HasAttachment(cd), Is.True);
- Assert.That(db.ReadAttachment(cd), Is.EqualTo("jabbadabba-doo"));
- db.DeleteAttachment(cd);
- Assert.That(db.HasAttachment(cd), Is.False);
+ var attachmentName = "someAttachment.txt";
+ Assert.That(db.HasAttachment(cd,attachmentName), Is.False);
+ db.WriteAttachment(cd, attachmentName, "jabbadabba", "text/plain");
+ Assert.That(db.HasAttachment(cd,attachmentName), Is.True);
+
+ using (var response = db.ReadAttachment(cd, attachmentName))
+ {
+ using (var reader = new StreamReader(response.GetResponseStream()))
+ {
+ Assert.That(reader.ReadToEnd(), Is.EqualTo("jabbadabba"));
+ }
+ }
+
+ db.WriteAttachment(cd, attachmentName, "jabbadabba-doo", "text/plain");
+ Assert.That(db.HasAttachment(cd,attachmentName), Is.True);
+
+ using (var response = db.ReadAttachment(cd, attachmentName))
+ {
+ using (var reader = new StreamReader(response.GetResponseStream()))
+ {
+ Assert.That(reader.ReadToEnd(), Is.EqualTo("jabbadabba-doo"));
+ }
+ }
+
+ db.DeleteAttachment(cd,attachmentName);
+
+ Assert.That(db.HasAttachment(cd,attachmentName), Is.False);
}
[Test, ExpectedException(typeof (CouchConflictException))]
diff --git a/Tests/Divan.Test.csproj b/Tests/Divan.Test.csproj
index 96045da..1b55939 100644
--- a/Tests/Divan.Test.csproj
+++ b/Tests/Divan.Test.csproj
@@ -57,6 +57,7 @@
+
@@ -69,9 +70,6 @@
Divan
-
-
-