Exemplo n.º 1
0
        public void Serialize1()
        {
            var date = new DateTime(2015, 01, 01);

            var a = RequestId.Create(1, date, 3);

            var data = a.Serialize();

            Assert.Equal(16, data.Length);

            var b = Uid.Deserialize(data);

            Assert.Equal(4588768ul, a.Upper);

            Assert.Equal(date, RequestId.GetTimestamp(a));
            Assert.Equal(3, RequestId.GetSequenceNumber(a));
        }
Exemplo n.º 2
0
        public void UidTest()
        {
            var id = Uid.Deserialize(Convert.FromBase64String("ZKWQKAIkHUiA4MGBMfFiGg=="));

            var value = AttributeCollection.FromObject(new Entity {
                Id = id
            });



            Assert.Equal(@"{
  ""id"": {
    ""B"": ""ZKWQKAIkHUiA4MGBMfFiGg==""
  }
}", value.ToJson().ToString());

            var a = AttributeCollection.FromJson(value.ToJson()).As <Entity>();

            Assert.Equal(id, a.Id);
        }
Exemplo n.º 3
0
        public void Uid1()
        {
            var date = new DateTime(2000, 01, 01);

            var id = RequestId.Create(1, date, 1);

            Assert.Equal("0000000iHxu00000000001", id.ToString());

            var data = id.Serialize();
            var id2  = Uid.Deserialize(data);

            Assert.Equal(date, RequestId.GetTimestamp(id2));
            Assert.Equal(4457272ul, id2.Upper);

            Assert.Equal(1, RequestId.GetSequenceNumber(id2));

            var a = Uid.Parse(id.ToString());

            Assert.Equal("0000000iHxu00000000001", a.ToString());
        }