public static void Init(TypeMap types, Class2TypeMap class2type) { RuntimeExceptionSerializer.Init( types.Get(ETCH_RUNTIME_EXCEPTION_TYPE_NAME), class2type); ListSerializer.Init( types.Get(ETCH_LIST_TYPE_NAME), class2type); MapSerializer.Init( types.Get(ETCH_MAP_TYPE_NAME), class2type); /* SetSerializer.Init( * types.Get(ETCH_SET_TYPE_NAME), class2type); */ DateSerializer.Init( types.Get(ETCH_DATETIME_TYPE_NAME), class2type); AuthExceptionSerializer.Init( types.Get(ETCH_AUTH_EXCEPTION_TYPE_NAME), class2type); XType t3 = types.Get(ETCH_EXCEPTION_MESSAGE_NAME); t3.PutValidator(_mf_result, Validator_RuntimeException.Get()); t3.PutValidator(_mf__messageId, Validator_long.Get(0)); t3.PutValidator(_mf__inReplyTo, Validator_long.Get(0)); }
public void DeSerializeNumericType() { var reader = Mock.Of <IBsonReader>(); Mock.Get(reader).Setup(x => x.CurrentBsonType).Returns(BsonType.Int32); var context = BsonDeserializationContext.CreateRoot(reader, null); var serializer = new DateSerializer(); var date = serializer.Deserialize(context); date.Should().Be(Date.MinValue); Mock.Get(reader).Verify(x => x.SkipValue()); }
public void DeSerializeInvalidDate() { var reader = Mock.Of <IBsonReader>(); Mock.Get(reader).Setup(x => x.CurrentBsonType).Returns(BsonType.String); Mock.Get(reader).Setup(x => x.ReadString()).Returns("2019-12-32"); var context = BsonDeserializationContext.CreateRoot(reader, null); var serializer = new DateSerializer(); var date = serializer.Deserialize(context); date.Should().Be(Date.MinValue); }
public void Serialize() { var writer = Mock.Of <IBsonWriter>(); var context = BsonSerializationContext.CreateRoot(writer, null); var serializer = new DateSerializer(); var date = new Date(2019, 12, 01); serializer.Serialize(context, date); Mock.Get(writer).Verify(x => x.WriteString("2019-12-01")); }
public void DeSerializeTimeStampType() { var testDate = new DateTimeOffset(2019, 12, 01, 8, 54, 26, TimeSpan.Zero); var reader = Mock.Of <IBsonReader>(); Mock.Get(reader).Setup(x => x.CurrentBsonType).Returns(BsonType.Timestamp); Mock.Get(reader).Setup(x => x.ReadTimestamp()).Returns(testDate.ToUnixTimeMilliseconds); var context = BsonDeserializationContext.CreateRoot(reader, null); var serializer = new DateSerializer(); var date = serializer.Deserialize(context); date.Should().Be(new Date(2019, 12, 01)); }
/// <summary> /// Checks if time passed /// </summary> /// <returns>True if time passed</returns> public bool Check(string dateInPast) { return(Check(DateSerializer.DeserializeDate(dateInPast))); }
/// <summary> /// Resets last fetch date to actual date on machine /// </summary> public void ResetDate() { Config.AddVariable("LastFeedbackFetchDate", DateSerializer.SerializeDate(DateTime.Now)); }
/// <summary> /// Resets last fetch date to actual date on machine /// </summary> void ResetDate(out string fetchDate) { fetchDate = DateSerializer.SerializeDate(DateTime.Now); Config.AddVariable("LastFeedbackFetchDate", fetchDate); }