Exemplo n.º 1
0
        public void CanSerializeListWithEmbeddedWithLinks()
        {
            var original = TestListResourceWithLinks.Default1();

            var json = JsonConvert.SerializeObject(original, _settings);

            const string expected     = TestListResourceWithLinks.SerializedDefault1;
            var          deserialized = JsonConvert.DeserializeObject <TestListResourceWithLinks>(json, _settings);

            json.ShouldNotBeNullOrWhiteSpace();
            json.ShouldBe(expected, StringCompareShould.IgnoreCase);
            original.ShouldBe(deserialized);
        }
Exemplo n.º 2
0
        public async Task CanDeserializeListWithEmbeddedWithLinks()
        {
            using (var server = LocalWebServer.ListenInBackground(new XUnitMockLogger(_logger)))
            {
                var uri = server.ListeningUri;
                server.WithNextResponse(new MockHttpResponseMessage().WithContent(TestListResourceWithLinks.SerializedDefault1).WithPrivateCacheHeader().WithDefaultExpiration());

                var result = await CreateBuilder()
                             .WithLink(uri).ResultAsync <TestListResourceWithLinks>();

                result.ShouldNotBeNull();
                result.ShouldBe(TestListResourceWithLinks.Default1());
            }
        }