//[InlineData("ModifyRestoreSettings", true)] = Not really included in the equals and hash code comparisons public void PackageSpecCloneTest(string methodName, bool validateJson) { // Set up var PackageSpec = CreatePackageSpec(); var clonedPackageSpec = PackageSpec.Clone(); //Preconditions Assert.Equal(PackageSpec, clonedPackageSpec); var originalPackageSpecWriter = new JsonObjectWriter(); var clonedPackageSpecWriter = new JsonObjectWriter(); PackageSpecWriter.Write(PackageSpec, originalPackageSpecWriter); PackageSpecWriter.Write(clonedPackageSpec, clonedPackageSpecWriter); Assert.Equal(originalPackageSpecWriter.GetJson().ToString(), clonedPackageSpecWriter.GetJson().ToString()); Assert.False(object.ReferenceEquals(PackageSpec, clonedPackageSpec)); // Act var methodInfo = typeof(PackageSpecModify).GetMethod(methodName); methodInfo.Invoke(null, new object[] { PackageSpec }); // Assert Assert.NotEqual(PackageSpec, clonedPackageSpec); if (validateJson) { var oPackageSpecWriter = new JsonObjectWriter(); var cPackageSpecWriter = new JsonObjectWriter(); PackageSpecWriter.Write(PackageSpec, oPackageSpecWriter); PackageSpecWriter.Write(clonedPackageSpec, cPackageSpecWriter); Assert.NotEqual(oPackageSpecWriter.GetJson().ToString(), cPackageSpecWriter.GetJson().ToString()); } Assert.False(object.ReferenceEquals(PackageSpec, clonedPackageSpec)); }
private static string GetJsonString(PackageSpec packageSpec) { var writer = new JsonObjectWriter(); PackageSpecWriter.Write(packageSpec, writer); return(writer.GetJson()); }
private static void VerifyJsonPackageSpecRoundTrip(string json) { // Arrange & Act var spec = JsonPackageSpecReader.GetPackageSpec(json, "testName", @"C:\fake\path"); var writer = new JsonObjectWriter(); PackageSpecWriter.Write(spec, writer); var actualResult = writer.GetJson(); var expected = JObject.Parse(json).ToString(); // Assert Assert.Equal(expected, actualResult); }
public void GetJson_HasDefaultValue() { var actualResult = _writer.GetJson(); Assert.Equal("{}", actualResult); }