public void ShouldParseDifferentTimezonesDate(string expiryDate) { byte[] byteValue = CreateSerializedThirdPartyAttribute("token", expiryDate); AttributeIssuanceDetails result = ThirdPartyAttributeConverter.ParseThirdPartyAttribute(byteValue); Assert.AreEqual(new DateTime(2019, 1, 2, 3, 4, 5, 678, DateTimeKind.Utc), result.ExpiryDate); }
public void ShouldReturnNullForExpiryDateEmpty() { byte[] byteValue = CreateSerializedThirdPartyAttribute("token", expiryDate: ""); AttributeIssuanceDetails result = ThirdPartyAttributeConverter.ParseThirdPartyAttribute(byteValue); Assert.IsNull(result.ExpiryDate); }
public void ShouldThrowExtraDataExceptionForEmptyToken() { byte[] byteValue = CreateSerializedThirdPartyAttribute("", expiryDate: _someExpiryDate); Assert.ThrowsException <ExtraDataException>(() => { ThirdPartyAttributeConverter.ParseThirdPartyAttribute(byteValue); }); }
public void ShouldParseAllValidRFC3339Dates(string expiryDate, string expectedValue) { byte[] byteValue = CreateSerializedThirdPartyAttribute("token", expiryDate); AttributeIssuanceDetails result = ThirdPartyAttributeConverter.ParseThirdPartyAttribute(byteValue); DateTime nonNullableExpiryDate = (DateTime)result.ExpiryDate; string actualString = nonNullableExpiryDate.ToString(Format.RFC3339PatternMicro, DateTimeFormatInfo.InvariantInfo); Assert.AreEqual(expectedValue, actualString); }
private static object ConvertValue(ProtoBuf.Share.DataEntry.Types.Type dataEntryType, ByteString value) { NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); switch (dataEntryType) { case ProtoBuf.Share.DataEntry.Types.Type.ThirdPartyAttribute: return(ThirdPartyAttributeConverter.ParseThirdPartyAttribute(value.ToByteArray())); default: logger.Warn($"Unsupported data entry '{dataEntryType.ToString()}', skipping..."); return(null); } }