예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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());
        }
예제 #6
0
        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);
        }