public void TestCreateTimestampUsingConfigurationFile() { byte[] data = Encoding.UTF8.GetBytes(dataToTimestamp); Utils.LoadConfigurationFile(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName + "\\src\\configuration.txt"); TimestampCreator creator = new TimestampCreator(); TimestampObject timestamp = creator .SetDataForTimestamping(data) .CreateTimestamp(); Assert.AreEqual(HashAlgorithm.SHA1, timestamp.HashAlgorithm); timestamp = creator .SetHashAlgorithm(HashAlgorithm.SHA256) .CreateTimestamp(); Assert.AreEqual(HashAlgorithm.SHA256, timestamp.HashAlgorithm); }
public void TestCreateTimestampSimple() { byte[] data = Encoding.UTF8.GetBytes(dataToTimestamp); TimestampCreator creator = new TimestampCreator(); TimestampObject timestamp = creator .SetTsaPrimaryUrl(tsaUrl2) .SetHashAlgorithm(HashAlgorithm.SHA1) .SetOutputFormat(OutputFormat.TSR) .SetDataForTimestamping(data) .CreateTimestamp(); Assert.AreEqual(HashAlgorithm.SHA1, timestamp.HashAlgorithm); timestamp = creator .SetHashAlgorithm(HashAlgorithm.SHA256) .CreateTimestamp(); Assert.AreEqual(HashAlgorithm.SHA256, timestamp.HashAlgorithm); }
public void TestCreateTimestampAndCheckWarning() { byte[] data = Encoding.UTF8.GetBytes(dataToTimestamp); TimestampCreator creator = new TimestampCreator(); TimestampObject timestamp = creator .SetTsaPrimaryUrl(tsaUrl2) .SetHashAlgorithm(HashAlgorithm.SHA1) .SetOutputFormat(OutputFormat.TSR) .SetDataForTimestamping(data) .SetMinimimCertificateValidityPeriod(180) .CreateTimestamp(); Assert.IsNull(timestamp.Warning); timestamp = creator .SetHashAlgorithm(HashAlgorithm.SHA256) .SetMinimimCertificateValidityPeriod(4000) .CreateTimestamp(); Assert.IsNotNull(timestamp.Warning); }