public void TestSerializationRoundTrip() { // Arrange var originalPackages = GenerateServerPackages(100); var serializer = new JsonNetPackagesSerializer(); // Act var deserializedPackages = new List <ServerPackage>(); using (var memoryStream = new MemoryStream()) { serializer.Serialize(originalPackages, memoryStream); memoryStream.Position = 0; deserializedPackages.AddRange(serializer.Deserialize(memoryStream)); } // Assert Assert.Equal(originalPackages.Count, deserializedPackages.Count); for (var i = 0; i < originalPackages.Count; i++) { Assert.True(PublicPropertiesEqual(originalPackages[i], deserializedPackages[i], "DependencySets", "FrameworkAssemblies", "PackageAssemblyReferences", "AssemblyReferences")); } }
public void RoundTripsUncPaths() { var originalPackages = GenerateServerPackages(1); var originalPackage = originalPackages.Single(); originalPackage.IconUrl = new Uri("//testunc/test/a", UriKind.Absolute); originalPackage.LicenseUrl = new Uri("//testunc/test/b", UriKind.Absolute); originalPackage.ProjectUrl = new Uri("//testunc/test/c", UriKind.Absolute); originalPackage.ReportAbuseUrl = new Uri("//testunc/test/d", UriKind.Absolute); var serializer = new JsonNetPackagesSerializer(); // Act var deserializedPackages = new List <ServerPackage>(); using (var memoryStream = new MemoryStream()) { serializer.Serialize(originalPackages, memoryStream); memoryStream.Position = 0; deserializedPackages.AddRange(serializer.Deserialize(memoryStream)); } // Assert AssertPackagesAreEqual(originalPackages, deserializedPackages); var deserializedPackage = deserializedPackages.Single(); Assert.True(deserializedPackage.IconUrl.IsAbsoluteUri, "The icon URL should still be absolute."); Assert.True(deserializedPackage.LicenseUrl.IsAbsoluteUri, "The license URL should still be absolute."); Assert.True(deserializedPackage.ProjectUrl.IsAbsoluteUri, "The project URL should still be absolute."); Assert.True(deserializedPackage.ReportAbuseUrl.IsAbsoluteUri, "The report abuse URL should still be absolute."); }
public void TestSerializationRoundTrip() { // Arrange var originalPackages = GenerateServerPackages(100); var serializer = new JsonNetPackagesSerializer(); // Act var deserializedPackages = new List <ServerPackage>(); using (var memoryStream = new MemoryStream()) { serializer.Serialize(originalPackages, memoryStream); memoryStream.Position = 0; deserializedPackages.AddRange(serializer.Deserialize(memoryStream)); } // Assert AssertPackagesAreEqual(originalPackages, deserializedPackages); }