Exemplo n.º 1
0
        public void ThrowOnInvalidRequest1()
        {
            var client = ApiClientHelper.GetRealApiClient();

            var request = new ApiRequestMessage <object>(
                new RestRequest(Method.GET));

            client.GetMessage(request, true);
        }
        public void AddGroup()
        {
            var groupName = "test-group";

            var project = ApiClientHelper.GetFirstProject();
            var request = _builder.GetAddKeywordGroupRequest(project.Id, groupName);
            var id      = _client.GetMessageResult(request);

            Assert.IsTrue(id > 0, "id > 0");
        }
Exemplo n.º 3
0
        public static IEnumerable <ApiProject> GetProjects(bool onlyEnabled = true)
        {
            var client  = ApiClientHelper.GetRealApiClient();
            var request = _builder.GetProjectsRequest();

            var projects = client.GetObjects <ApiProject>(request);

            return((onlyEnabled)
                ? projects.Where(p => p.On >= 0).ToList()
                : projects.ToList());
        }
Exemplo n.º 4
0
        public void ThrowOnInvalidRequest2()
        {
            var client = ApiClientHelper.GetRealApiClient();

            var builder = new ApiRequestBuilder();
            var request = builder.GetProjectsRequest();

            request.Request.Parameters[1].Name = "invalid-fake-param";

            var res = client.GetObjects <ApiProject>(request);
        }
Exemplo n.º 5
0
        public void GetMessageOnInvalidRequest()
        {
            var client = ApiClientHelper.GetRealApiClient();

            var request = new ApiRequestMessage <object>(
                new RestRequest(Method.GET));

            var message = client.GetMessage(request, false);

            Assert.IsNotNull(message);
        }
Exemplo n.º 6
0
        public void DropProject()
        {
            var dropProject = ApiClientHelper.GetFirstProject();

            var request = _builder.GetDeleteProjectRequest(dropProject.Id);
            var res     = _client.GetBoolResult(request);

            Assert.IsTrue(res);

            var newProjects = ApiClientHelper.GetProjects();

            Assert.IsNull(newProjects.FirstOrDefault(p => p.Id == dropProject.Id));
        }
Exemplo n.º 7
0
        public void AddProject()
        {
            var site = "http://ya.ru";

            var request   = _builder.GetAddProjectRequest(site);
            var projectId = _client.GetMessageResult(request);

            Assert.IsTrue(projectId >= 0, "id >= 0");

            var newProject = ApiClientHelper.GetFirstProject(projectId);

            Assert.AreEqual(site.Replace("http://", ""), newProject.Site);
        }
        public void DropKeyword()
        {
            var project = ApiClientHelper.GetFirstProject();
            var keyword = GetKeywords(project.Id).First();

            var request = _builder.GetDeleteKeywordRequest(keyword.Id);
            var res     = _client.GetBoolResult(request);

            Assert.IsTrue(res);

            var keywords = GetKeywords(project.Id);

            Assert.IsNull(keywords.FirstOrDefault(k => k.Id == keyword.Id));
        }
Exemplo n.º 9
0
        public void EnableDisableProject()
        {
            var project  = ApiClientHelper.GetFirstProject();
            var newState = (project.On == 0) ? -1 : 0;

            var request = _builder.GetUpdateProjectRequest(project.Id, newState);
            var res     = _client.GetBoolResult(request);

            Assert.IsTrue(res);

            var projects   = ApiClientHelper.GetProjects(false);
            var newProject = projects.First(p => project.Id == p.Id);

            Assert.AreEqual(newProject.On, newState);
        }
        public void SetKeywordTarget()
        {
            var project = ApiClientHelper.GetFirstProject();
            var keyword = GetKeywords(project.Id).First();

            var url = "http://ya.ru/phrase" + Environment.TickCount;

            var request = _builder.GetUpdateKeywordTargetRequest(keyword.Id, url);
            var res     = _client.GetBoolResult(request);

            // BUG: непонятно почему, но таргет устанавливается, а возвращает 0
            //Assert.IsTrue(res);

            var keywords = GetKeywords(project.Id);

            Assert.IsNotNull(keywords.FirstOrDefault(k => k.Target == url));
        }
        public void AddSingleKeyword()
        {
            var testPhrase = "test phrase" + Environment.TickCount;

            var project = ApiClientHelper.GetFirstProject();

            var request = _builder.GetAddKeywordRequest(project.Id, testPhrase);
            var id      = _client.GetMessageResult(request);

            Assert.IsTrue(id > 0, "id > 0");

            var keywords = GetKeywords(project.Id);

            var newKeyword = keywords.First(k => k.Id == id);

            Assert.AreEqual(testPhrase, newKeyword.Phrase);
        }
        public void AddSomeKeywords()
        {
            var addKeywords = new List <string>();

            for (int i = 0; i < 5; ++i)
            {
                addKeywords.Add("phrase " + Environment.TickCount);
            }

            var project = ApiClientHelper.GetFirstProject();

            var request = _builder.GetAddKeywordsRequest(project.Id, addKeywords);

            _client.GetMessageResult(request);

            var keywords = GetKeywords(project.Id);

            foreach (var addedWord in addKeywords)
            {
                Assert.IsNotNull(keywords.FirstOrDefault(k => k.Phrase == addedWord));
            }
        }
 public void LoadKeywords()
 {
     var project  = ApiClientHelper.GetFirstProject();
     var keywords = GetKeywords(project.Id);
 }
Exemplo n.º 14
0
 public void LoadProjects()
 {
     var projects = ApiClientHelper.GetProjects();
 }