public void Constructor_Empty() { CipherData cipherData = new CipherData(); Assert.Null(cipherData.CipherReference); Assert.Null(cipherData.CipherValue); Assert.Throws <CryptographicException>(() => cipherData.GetXml()); }
public void Constructor_CipherValue(byte[] cipherValue) { CipherData cipherData = new CipherData(cipherValue); Assert.Equal(cipherValue, cipherData.CipherValue); Assert.Null(cipherData.CipherReference); XmlElement xmlElement = cipherData.GetXml(); Assert.NotNull(xmlElement); Assert.Equal( $"<CipherData xmlns=\"http://www.w3.org/2001/04/xmlenc#\"><CipherValue>{Convert.ToBase64String(cipherValue)}</CipherValue></CipherData>", xmlElement.OuterXml); }
public void LoadXml_CipherReference(XmlElement xmlElement, string uri) { CipherData cipherData = new CipherData(); cipherData.LoadXml(xmlElement); Assert.Equal(uri, cipherData.CipherReference.Uri); Assert.Null(cipherData.CipherValue); XmlElement gotXmlElement = cipherData.GetXml(); Assert.NotNull(gotXmlElement); Assert.Equal(xmlElement.OuterXml, gotXmlElement.OuterXml); }
public void Constructor_CipherReference(CipherReference cipherReference) { CipherData cipherData = new CipherData(cipherReference); Assert.Null(cipherData.CipherValue); Assert.Equal(cipherReference, cipherData.CipherReference); XmlElement xmlElement = cipherData.GetXml(); Assert.NotNull(xmlElement); if (cipherReference.Uri != string.Empty) { Assert.Equal( $"<CipherData xmlns=\"http://www.w3.org/2001/04/xmlenc#\"><CipherReference URI=\"{cipherReference.Uri}\" /></CipherData>", xmlElement.OuterXml); } else { Assert.Equal( "<CipherData xmlns=\"http://www.w3.org/2001/04/xmlenc#\"><CipherReference /></CipherData>", xmlElement.OuterXml); } }