public void Logout_Should_Remove_Auth_Cookie() { // Arrange WebApiClient apiclient = new WebApiClient(); apiclient.Login(); apiclient.Get("Logout"); apiclient.Get("User"); // Act apiclient.Login(); apiclient.Get("Logout"); WebApiResponse response = apiclient.Get("User"); // Assert Assert.That(response.HttpStatusCode, Is.EqualTo(HttpStatusCode.Unauthorized), response); }
public void Search_Should_Return_Result_Based_On_Query() { // Arrange AddPage("test", "this is page 1"); AddPage("page 2", "this is page 2"); var queryString = new Dictionary <string, string>() { { "query", "test" } }; WebApiClient apiclient = new WebApiClient(); apiclient.Login(); // Act apiclient.Get("Search/CreateIndex"); WebApiResponse <List <PageViewModel> > response = apiclient.Get <List <PageViewModel> >("Search", queryString); // Assert IEnumerable <PageViewModel> pages = response.Result; Assert.That(pages.Count(), Is.EqualTo(1), response); }
public void GetUsers_Should_Return_All_Users() { // Arrange WebApiClient apiclient = new WebApiClient(); apiclient.Login(); // Act WebApiResponse <List <UserViewModel> > response = apiclient.Get <List <UserViewModel> >("User"); // Assert List <UserViewModel> results = response.Result; Assert.That(results.Count(), Is.EqualTo(2), response); }
public void Get_Should_Return_All_Pages() { // Arrange AddPage("test", "this is page 1"); AddPage("page 2", "this is page 2"); WebApiClient apiclient = new WebApiClient(); apiclient.Login(); // Act WebApiResponse <List <PageViewModel> > response = apiclient.Get <List <PageViewModel> >("Pages"); // Assert IEnumerable <PageViewModel> pages = response.Result; Assert.That(pages.Count(), Is.EqualTo(2), response); }
public void Get_With_Id_Should_Return_Correct_Page() { // Arrange PageContent expectedPage = AddPage("test", "this is page 1"); var queryString = new Dictionary <string, string>() { { "Id", expectedPage.Page.Id.ToString() } }; WebApiClient apiclient = new WebApiClient(); apiclient.Login(); // Act WebApiResponse <PageViewModel> response = apiclient.Get <PageViewModel>("Pages", queryString); // Assert PageViewModel actualPage = response.Result; Assert.That(actualPage, Is.Not.Null, response.ToString()); Assert.That(actualPage.Id, Is.EqualTo(expectedPage.Page.Id), response.ToString()); }
public void GetUser_Should_Return_Admin_User() { // Arrange var queryString = new Dictionary <string, string>() { { "Id", ADMIN_ID.ToString() } }; WebApiClient apiclient = new WebApiClient(); apiclient.Login(); // Act WebApiResponse <UserViewModel> response = apiclient.Get <UserViewModel>("User", queryString); // Assert UserViewModel userViewModel = response.Result; Assert.That(userViewModel, Is.Not.Null, response); Assert.That(userViewModel.Id, Is.EqualTo(ADMIN_ID), response); }