Ejemplo n.º 1
0
    [Fact] // Ensures that the class is correctly serialized and deserialized.
    public void TestSaveLoad()
    {
        CapabilityList capabilityList1 = CreateTestCapabilityList(), capabilityList2;

        using (var tempFile = new TemporaryFile("0install-test-capabilities"))
        {
            // Write and read file
            capabilityList1.SaveXml(tempFile);
            capabilityList2 = XmlStorage.LoadXml <CapabilityList>(tempFile);
        }

        // Ensure data stayed the same
        capabilityList2.Should().Be(capabilityList1, because: "Serialized objects should be equal.");
        capabilityList2.GetHashCode().Should().Be(capabilityList1.GetHashCode(), because: "Serialized objects' hashes should be equal.");
        capabilityList2.Should().NotBeSameAs(capabilityList1, because: "Serialized objects should not return the same reference.");
    }