public void GetAfterPostReturnCorrectStatusCode()
        {
            var json = new
            {
                time = DateTimeOffset.Now,
                distance = 8100,
                duration = TimeSpan.FromMinutes(41)
            };
            var expected = json.ToJObject();
            server.HttpClient.PostAsJsonAsync("/journal", json).Wait();

            var response = server.HttpClient.GetAsync("/journal").Result;

            var actual = response.Content.ReadAsJsonAsync().Result;
            Assert.Contains(expected, actual.entries);
        }
示例#2
0
        public void GetAfterPostReturnsResponseWithPostedEntry()
        {
            using (var client = _httpApplication.GetClient())
            {
                var json = new
                {
                    name = "Customer 2"
                };

                var expected = json.ToJObject();
                client.PostAsJsonAsync("customer", json).Wait();

                var response = client.GetAsync("customer").Result;

                var actual = response.Content.ReadAsJsonAsync().Result;

                Assert.Contains(expected, actual);
            }
        }
示例#3
0
        public void return_a_posted_entry_after_a_post_request()
        {
            using (var httpClient = new HttpClientFactory().Create())
            {
                var json =
                    new 
                    {
                        id = new Guid(),
                        name = "John Smith",
                        email = "*****@*****.**",
                        active = true,
                        creationTime = new DateTime(2016, 1, 1)
                    };
                var expected = json.ToJObject();
                httpClient.PostAsJsonAsync("", json).Wait();

                var response = httpClient.GetAsync("").Result;

                var actual = response.Content.ReadAsJsonAsync().Result;
                Assert.Contains(expected, actual.appUsers);
            }
        }
        public void GetPostShouldReturnPostedEntry()
        {
            using (var client = HttpClientFactory.Create())
            {
                var json = new
                {
                    Name = "Rafael",
                    Number = "9888888",
                    Birthday = DateTimeOffset.Now
                };

                var expectedValue = json.ToJObject();

                client.PostAsJsonAsync("", json).Wait();

                var response = client.GetAsync("").Result;

                var actual = response.Content.ReadAsJsonAsync().Result;

                Assert.Contains(expectedValue, actual.entries);
            }
        }
        public void GET_documents_resouce_returns_document_stored_in_database(
            string userName, 
            string title, 
            string content,
            string checkedOutBy)
        {
            var document = new
            {
                Id = Guid.NewGuid(),
                Title = title,
                Content = content,
                CheckedOutBy = checkedOutBy
            };

            var expected = document.ToJObject();

            var db = Simple.Data.Database.OpenNamedConnection(ConnectionStringName);
            db.Documents.Insert(document);

            using (var client = TestServerHttpClientFactory.Create(userName))
            {
                var response = client.GetAsync("/api/documents").Result;
                var actual = response.Content.ReadAsJsonAsync().Result;

                Assert.Contains(expected, actual.documents);
            }
        }