public void DeleteFile() { using (var database = TestHelper.GetDatabase()) { var user = TestHelper.AddUser(database, "Administrator", "Password!", "administrator"); TestHelper.AddDefaultSettings(database); var john = TestHelper.AddUser(database, "John Doe", "*****@*****.**", "Password!"); var file = TestHelper.AddFile(database, john, "File.png", "image/png", new byte[0]); database.SaveChanges(); var client = new ScribeClient(TestSite, TestService); client.LogIn(new Credentials { UserName = "******", Password = "******" }); client.DeleteFile(file.Id); TestHelper.ExpectedException <Exception>(() => { var result = client.GetPage(file.Id); Assert.AreEqual("Hello Page", result.Title); }, "Bad Request"); Assert.AreEqual(0, database.PageVersions.Count()); } }
public void GetPagesUsingOrder() { using (var database = TestHelper.GetDatabase()) { var user = TestHelper.AddUser(database, "Administrator", "Password!", "administrator"); TestHelper.AddDefaultSettings(database); var john = TestHelper.AddUser(database, "John Doe", "*****@*****.**", "Password!"); TestHelper.AddPage(database, "Hello Page", "Hello World", john, ApprovalStatus.None, false, "myTag"); TestHelper.AddPage(database, "Another Page 2", "Hello World... again", john, ApprovalStatus.None, false, "anotherTag"); database.SaveChanges(); } var client = new ScribeClient(TestSite, TestService); client.LogIn(new Credentials { UserName = "******", Password = "******" }); var pages = client.GetPages(new PagedRequest { Order = "Tags" }).Results.ToList(); Assert.AreEqual(2, pages.Count); Assert.AreEqual("Another Page 2", pages[0].Title); Assert.AreEqual("Hello Page", pages[1].Title); }
public void DeletePage() { using (var database = TestHelper.GetDatabase()) { var user = TestHelper.AddUser(database, "Administrator", "Password!", "administrator"); TestHelper.AddDefaultSettings(database); var john = TestHelper.AddUser(database, "John Doe", "*****@*****.**", "Password!"); var page = TestHelper.AddPage(database, "Hello Page", "Hello World", john, ApprovalStatus.None, false, "myTag"); database.SaveChanges(); var client = new ScribeClient(TestSite, TestService); Assert.IsFalse(client.IsAuthenticated); client.LogIn(new Credentials { UserName = "******", Password = "******" }); Assert.IsTrue(client.IsAuthenticated); client.DeletePage(page.Id); TestHelper.ExpectedException <Exception>(() => { var result = client.GetPage(page.Id); Assert.AreEqual("Hello Page", result.Title); }, "Bad Request"); Assert.AreEqual(0, database.PageVersions.Count()); } }
public void GetPage() { using (var database = TestHelper.GetDatabase()) { var user = TestHelper.AddUser(database, "Administrator", "Password!", "administrator"); TestHelper.AddDefaultSettings(database); var john = TestHelper.AddUser(database, "John Doe", "*****@*****.**", "Password!"); var page = TestHelper.AddPage(database, "Hello Page", "Hello World", john, ApprovalStatus.None, false, "myTag"); database.SaveChanges(); var client = new ScribeClient(TestSite, TestService); client.LogIn(new Credentials { UserName = "******", Password = "******" }); var result = client.GetPage(page.Id); Assert.AreEqual("Hello Page", result.Title); } }
public void CancelEditingPage() { using (var database = TestHelper.GetDatabase()) { var user = TestHelper.AddUser(database, "Administrator", "Password!", "administrator"); TestHelper.AddDefaultSettings(database); var john = TestHelper.AddUser(database, "John Doe", "*****@*****.**", "Password!"); var page = TestHelper.AddPage(database, "Hello Page", "Hello World", john, ApprovalStatus.None, false, "myTag"); database.PageVersions.First().EditingById = john.Id; database.SaveChanges(); var client = new ScribeClient(TestSite, TestService); client.LogIn(new Credentials { UserName = "******", Password = "******" }); Assert.AreEqual(john.Id, database.PageVersions.First().EditingById); client.CancelEditingPage(page.Id); } using (var database = TestHelper.GetDatabase(false)) { Assert.IsNull(database.PageVersions.First().EditingById); } }