Exemple #1
0
        public override void Serialize_and_deserialize_ListPool_with_objects()
        {
            using ListPool <CustomObject> expectedItems = new ListPool <CustomObject>
                  {
                      s_fixture.Create <CustomObject>(), s_fixture.Create <CustomObject>(), s_fixture.Create <CustomObject>()
                  };
            string serializedItems = JsonSerializer.ToJsonString(expectedItems);

            using ListPool <CustomObject> actualItems =
                      JsonSerializer.Deserialize <ListPool <CustomObject> >(serializedItems);

            Assert.Equal(expectedItems.Count, actualItems.Count);
            Assert.All(expectedItems,
                       expectedItem => actualItems.Any(actualItem => actualItem.Property == expectedItem.Property));
        }