Ejemplo n.º 1
0
        public async Task TestSearch()
        {
            using (var client = new TestClientProvider().Client)
            {
                var response = await client.GetAsync("/api/faq/search/some string");

                response.EnsureSuccessStatusCode();
                response.StatusCode.Should().Be(HttpStatusCode.OK);
            }
        }
Ejemplo n.º 2
0
        public async Task TestGetAllGroupsWithQuestions()
        {
            using (var client = new TestClientProvider().Client)
            {
                var response = await client.GetAsync("/api/faq/groupsWithQuestions");

                response.EnsureSuccessStatusCode();
                response.StatusCode.Should().Be(HttpStatusCode.OK);
            }
        }
Ejemplo n.º 3
0
        public async Task TestCreateGroup()
        {
            using (var client = new TestClientProvider().Client)
            {
                var response = await client.PostAsync("/api/faq/groups",
                                                      new StringContent(JsonConvert.SerializeObject("TestGroup"), Encoding.UTF8, "application/json"));

                response.EnsureSuccessStatusCode();
                response.StatusCode.Should().Be(HttpStatusCode.OK);
            }
        }
Ejemplo n.º 4
0
        public async Task TestCreateQuestion()
        {
            using (var client = new TestClientProvider().Client)
            {
                var response = await client.PostAsync("/api/faq/questions",
                                                      new StringContent(JsonConvert.SerializeObject(new FaqQuestionCreateUpdateVM
                {
                    Question = "TestQuestion",
                    Answer = "TestAnswer",
                    FaqGroupId = 1
                }),
                                                                        Encoding.UTF8,
                                                                        "application/json"));

                response.EnsureSuccessStatusCode();
                response.StatusCode.Should().Be(HttpStatusCode.OK);
            }
        }
Ejemplo n.º 5
0
        public async Task TestDeleteGroup()
        {
            using (var client = new TestClientProvider().Client)
            {
                var response = await client.DeleteAsync("/api/faq/groups/" + this.testGroupIdForDelete.ToString());

                response.EnsureSuccessStatusCode();
                response.StatusCode.Should().Be(HttpStatusCode.OK);

                var json = await response.Content.ReadAsStringAsync();

                var serializerSettings = new JsonSerializerSettings
                {
                    ContractResolver = new CamelCasePropertyNamesContractResolver()
                };

                json.Should().Be(JsonConvert.SerializeObject(new FaqGroupVMWithoutNavigationProperty
                {
                    FaqGroupId = this.testGroupIdForDelete,
                    Title      = "TestGroup"
                }, serializerSettings));
            }
        }