Пример #1
0
        public void EchoDatabaseTest()
        {
            const string uriBase = "http://localhost:5984/";
            IUserCredential crd = new UserCredential("Professor", "Farnsworth");

            var sessionFactory = new CouchSessionFactory(uriBase, crd, AuthenticationLevel.Cookie);
            var response = sessionFactory.EchoCouch();

            Assert.IsTrue(response.StatusCode == HttpStatusCode.OK);
        }
Пример #2
0
        public void CreateDatabaseTest()
        {
            const string uriBase = "http://localhost:5984/";
            IUserCredential crd = new UserCredential("Professor", "Farnsworth");

            var sessionFactory = new CouchSessionFactory(uriBase, crd, AuthenticationLevel.Cookie);

            var response1 = sessionFactory.CreateDataBase("ciccio");
            Assert.IsTrue(response1.StatusCode == HttpStatusCode.Created);

            var response2 = sessionFactory.DeleteDataBase("ciccio");
            Assert.IsTrue(response2.StatusCode == HttpStatusCode.OK);
        }
Пример #3
0
        public void FailedCreateDatabaseTest()
        {
            const string uriBase = "http://localhost:5984/";
            IUserCredential crd = new UserCredential("Professor", "Farnsworth");

            var sessionFactory = new CouchSessionFactory(uriBase, crd, AuthenticationLevel.Cookie);

            var response = sessionFactory.CreateDataBase("_ciccio");
            var rr = response.ResponseAs<HttpErrorResponse>();

            Assert.IsNotNull(rr);
            Assert.IsTrue(rr.Reason.StartsWith("Name:"));
            Assert.IsTrue(response.StatusCode == HttpStatusCode.BadRequest);
        }
Пример #4
0
        public void ExistsDatabaseTest()
        {
            const string uriBase = "http://localhost:5984/";
            IUserCredential crd = new UserCredential("Professor", "Farnsworth");

            var sessionFactory = new CouchSessionFactory(uriBase, crd, AuthenticationLevel.Cookie);

            var response1 = sessionFactory.ExistsDataBase("db");
            var rr = response1.ResponseAs<HttpErrorResponse>();

            Assert.IsNotNull(rr);
            Assert.IsTrue(rr.Reason.StartsWith("no_db_file"));
            Assert.IsTrue(response1.StatusCode == HttpStatusCode.NotFound);

            var response2 = sessionFactory.ExistsDataBase("_users");
            Assert.IsTrue(response2.StatusCode == HttpStatusCode.OK);
        }
Пример #5
0
        public void FailedDeleteDatabaseTest()
        {
            const string uriBase = "http://localhost:5984/";
            IUserCredential crd = new UserCredential("Professor", "Farnsworth");

            var sessionFactory = new CouchSessionFactory(uriBase, crd, AuthenticationLevel.Cookie);
            var response = sessionFactory.DeleteDataBase("nodb");

            var rr = response.ResponseAs<HttpErrorResponse>();

            Assert.IsNotNull(rr);
            Assert.AreEqual(rr.Reason, "missing");
            Assert.IsNotNull(response.StatusCode == HttpStatusCode.NotFound);
        }
Пример #6
0
        public void FailedEchoDatabaseTest()
        {
            const string uriBase = "http://localhost:5900/";
            IUserCredential crd = new UserCredential("Professor", "Farnsworth");

            new CouchSessionFactory(uriBase, crd, AuthenticationLevel.Cookie);
        }