public void Update_Multiple_CreatesCorrectly() { var conn = new CouchConnection("http://127.0.0.1", 5984); var svc = new CouchService(conn); var db = svc.GetDatabase("integrationtest"); var card1 = new BusinessCard { Name = "Bob Smith", Employer = "GiantMart", JobTitle = "Manager" }; var card2 = new BusinessCard { Name = "Jack Smith", Employer = "MediumMart", JobTitle = "Manager" }; var card3 = new BusinessCard { Name = "Bill Smith", Employer = "TinyMart", JobTitle = "Manager" }; var resp = db.AddMany(new[] {card1, card2, card3}).ToList(); Assert.IsNotNull(resp); Assert.AreEqual(3, resp.Count); Assert.IsNotNull(db.RawResponse); Assert.AreEqual(HttpStatusCode.Created, db.RawResponse.StatusCode); card1 = db.Get<BusinessCard>(resp[0].Id); card2 = db.Get<BusinessCard>(resp[1].Id); card3 = db.Get<BusinessCard>(resp[2].Id); card1.JobTitle = "Chicken"; card2.JobTitle = "Horse"; card3.JobTitle = "Monkey"; resp = db.SaveMany(new[] {card1, card2, card3}).ToList(); Assert.AreEqual(3, resp.Count); Assert.IsTrue(resp[0].Revision.Contains("2-")); Assert.IsTrue(resp[1].Revision.Contains("2-")); Assert.IsTrue(resp[2].Revision.Contains("2-")); Assert.IsNotNull(db.RawResponse); Assert.AreEqual(HttpStatusCode.Created, db.RawResponse.StatusCode); }
public void Add_Single_ReturnCodeIsCorrect() { var conn = new CouchConnection("http://127.0.0.1", 5984); var svc = new CouchService(conn); var db = svc.GetDatabase("integrationtest"); var card = new BusinessCard { Name = "Bob Smith", Employer = "GiantMart", JobTitle = "Manager" }; var resp = db.Add(card); Assert.IsNotNull(resp); Assert.IsNotNull(db.RawResponse); Assert.AreEqual(HttpStatusCode.Created, db.RawResponse.StatusCode); }
public void ViewSyntaxCheck() { var conn = new CouchConnection("http://www.couchdbtest.com", 5984); var ex = new BusinessCard(); var svc = new CouchService(conn); var db2 = svc["unittest"]; var doc = db2.GetDesignDocument("monkeytennis"); svc["unittest"].GetDesignDocument("monkeyTennis").Views["test"].Execute<BusinessCard>(new CouchViewQuery()); svc["unittest"].GetDesignDocument("monkeyTennis").Shows["test"].Execute("1234"); svc["unittest"].GetDesignDocument("monkeyTennis"); //Long svc.GetDatabase("unittest").GetDesignDocument("moneyTennis").Views["test"].Execute<BusinessCard>(new CouchViewQuery()); //Super short .. svc["unittest"]["moneyTennis"].Views["test"].Execute<BusinessCard>(new CouchViewQuery()); //var show = db.GetDesignDocument("example").Show("test"); //Debug.WriteLine(db.ExecuteShow(show, "e99b84cd49824eaf90b5f5c164b39e12")); //var qs = new NameValueCollection(); //qs.Add("format","xml"); //Debug.WriteLine(db.ExecuteShow(show, "e99b84cd49824eaf90b5f5c164b39e12", qs)); //var doc = db.GetDesignDocument("example"); //var list = doc.List("htmlList"); //var view = doc.View("test"); //var resp = db.ExecuteList(list, view, new CouchViewQuery()); //Debug.WriteLine(resp.ContentType); //Debug.WriteLine(resp.Output); //var docExample = db.GetDesignDocument("example"); //docExample.Info(); //docExample.View("test").Execute<BusinessCard>(); //docExample.Show("test").Execute<BusinessCard>(documentId, queryStringParams); //docExample.View("test").ExecuteList(); //var query = new CouchViewQuery { Key = "e99b84cd49824eaf90b5f5c164b39e12" }; //var results = db.ExecuteView<BusinessCard>(view, query); //if (results.IsOk) //{ // Debug.WriteLine("Error: " + results.Response.ErrorType + " / Reason : " + results.Response.ErrorMessage); // return; //} //if(results.HasResults) //{ // foreach (var result in results) // { // Debug.WriteLine("Name: " + result.Name + " - Id : " + result.Id); // } //} }
public void QuickTest() { var conn = new CouchConnection("http://localhost", 5984); var svc = new CouchService(conn); var db = svc["unittest"]; // -- ADDING FROM NEW --- var card = new BusinessCard { Name = "Bob Smith", Employer = "GiantMart", JobTitle = "Manager" }; var resp = db.Add(card); if (resp.IsOk) { Debug.WriteLine("Added ! Id : " + resp.Id + " / Revision: " + resp.Revision); } else { Debug.WriteLine("Problem updating : " + resp.ErrorType + " / Reason : " + resp.ErrorMessage); } // -- RETREIVEING & UPDATING -- var newCard = db.Get<BusinessCard>(resp.Id); newCard.Name = "Bobbyd Smith"; resp = db.Save(newCard); if (resp.IsOk) { Debug.WriteLine("Updated ! Id : " + resp.Id + " / Revision: " + resp.Revision); } // -- DELETEING -- resp = db.Delete(resp.Id, resp.Revision); if (resp.IsOk) { Debug.WriteLine("Deleted ! Id : " + resp.Id + " / Revision: " + resp.Revision); } }