コード例 #1
0
        private static async Task RoundtripCatalogSerializationAsync(ComposableCatalog catalog, ITestOutputHelper output)
        {
            Requires.NotNull(catalog, nameof(catalog));
            Requires.NotNull(output, nameof(output));

            var catalogSerialization = new CachedCatalog();
            var ms = new MemoryStream();

            catalogSerialization.SaveAsync(catalog, ms).Wait();
            ms.Position = 0;
            var deserializedCatalog = await catalogSerialization.LoadAsync(ms, TestUtilities.Resolver);

            var before = new StringWriter();

            catalog.ToString(before);
            var after = new StringWriter();

            deserializedCatalog.ToString(after);

            PrintDiff("BeforeSerialization", "AfterSerialization", before.ToString(), after.ToString(), output);

            Assert.True(catalog.Equals(deserializedCatalog));
        }