Ejemplo n.º 1
0
        public void Put_Should_Update_Page()
        {
            // Arrange
            PageContent   pageContent = AddPage("test", "this is page 1");
            PageViewModel viewModel   = new PageViewModel(pageContent.Page);

            viewModel.Title = "New title";

            WebApiClient apiclient = new WebApiClient();

            apiclient.Login();

            // Act
            WebApiResponse response = apiclient.Put <PageViewModel>("Pages/Put", viewModel);

            // Assert
            IRepository repository = GetRepository();
            Page        page       = repository.AllPages().FirstOrDefault();

            Assert.That(page.Title, Is.EqualTo("New title"), response);
        }
Ejemplo n.º 2
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());
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);
        }