Пример #1
0
        public void BeforeEach()
        {
            couch = new Couch("localhost", 5984);

            // use my own routines -- even though I would be using my own code as a testing predicate,
            // bugs would still cause obvious failures, and I would only have to use a small slice of my code

            SallyFixture = new Person {Name = "Sally Acorn", Id = "sally", DocumentType = "Person"};
            HayekFixture = new Person {Name = "Frederich Hayek", DocumentType = "Person"}; // hayek gets a generated Id

            PersonFixtures = new List<Person>() {
                SallyFixture,
                HayekFixture
            };
            couch.EnsureDatabaseDeleted(TEST_DATABASE).Wait();
            couch.EnsureDatabaseDeleted(CREATION_TEST_DATABASE).Wait();
            couch.CreateDatabase(TEST_DATABASE).Wait();

            var dbOpenTask = couch.OpenDatabase(TEST_DATABASE);
            dbOpenTask.Wait();
            TestDatabase = dbOpenTask.Result;

            foreach (var personFixture in PersonFixtures) {
                TestDatabase.CreateDocument<Person>(personFixture).Wait();
            }
        }
Пример #2
0
 public void ShouldCreateADocumentWithoutAProvidedId()
 {
     var lispGuru = new Person() { Name = "John McCarthy" };
     var t = TestDatabase.CreateDocument<Person>(lispGuru);
     t.Wait();
     Assert.AreSame(lispGuru, t.Result);
     Assert.NotNull(t.Result.Id);
     Assert.NotNull(t.Result.Rev);
 }
Пример #3
0
 public void ShouldRefuseToUpdateDocumentWithoutRev()
 {
     var gotException = false;
     try {
         var p = new Person { Name = "MissingNo", Id = "missigno"};
         var t = TestDatabase.UpdateDocument<Person>(p);
         t.Wait();
     } catch (AggregateException ae) {
         ae.Handle((e) => {
             if (e is ArgumentOutOfRangeException) {
                 gotException = true;
                 return true;
             }
             return false;
         });
     }
     Assert.IsTrue(gotException);
 }
Пример #4
0
 public void ShouldCreateADocumentWithAProvidedId()
 {
     var alanTuring = new Person() { Name = "Alan Turing", Id = "alanturing" };
     var t = TestDatabase.CreateDocument<Person>(alanTuring);
     t.Wait();
     Assert.AreSame(alanTuring, t.Result);
     Assert.NotNull(t.Result.Id);
     Assert.NotNull(t.Result.Rev);
 }