コード例 #1
0
        public void Can_Cache_AllFields()
        {
            JsConfig.DateHandler = DateHandler.ISO8601;

            var dto = new AllFields
            {
                Id               = 1,
                NullableId       = 2,
                Byte             = 3,
                Short            = 4,
                Int              = 5,
                Long             = 6,
                UShort           = 7,
                UInt             = 8,
                Float            = 1.1f,
                Double           = 2.2d,
                Decimal          = 3.3m,
                String           = "String",
                DateTime         = DateTime.Now,
                TimeSpan         = new TimeSpan(1, 1, 1, 1, 1),
                Guid             = Guid.NewGuid(),
                NullableTimeSpan = new TimeSpan(2, 2, 2),
                NullableGuid     = new Guid("4B6BB8AE-57B5-4B5B-8632-0C35AF0B3168"),
            };

            Cache.Set("allfields", dto);
            var fromCache = Cache.Get <AllFields>("allfields");

            Assert.That(fromCache.DateTime, Is.EqualTo(dto.DateTime));

            Assert.That(fromCache.Equals(dto));

            JsConfig.Reset();
        }
コード例 #2
0
 protected bool Equals(AllFields other)
 {
     return Id == other.Id &&
         NullableId == other.NullableId &&
         Byte == other.Byte &&
         Short == other.Short &&
         Int == other.Int &&
         Long == other.Long &&
         UShort == other.UShort &&
         UInt == other.UInt &&
         ULong == other.ULong &&
         Float.Equals(other.Float) &&
         Double.Equals(other.Double) &&
         Decimal == other.Decimal &&
         string.Equals(String, other.String) &&
         DateTime.Equals(other.DateTime) &&
         TimeSpan.Equals(other.TimeSpan) &&
         Guid.Equals(other.Guid) &&
         NullableDateTime.Equals(other.NullableDateTime) &&
         NullableTimeSpan.Equals(other.NullableTimeSpan) &&
         NullableGuid.Equals(other.NullableGuid);
 }
コード例 #3
0
 protected bool Equals(AllFields other)
 {
     return(Id == other.Id &&
            NullableId == other.NullableId &&
            Byte == other.Byte &&
            Short == other.Short &&
            Int == other.Int &&
            Long == other.Long &&
            UShort == other.UShort &&
            UInt == other.UInt &&
            ULong == other.ULong &&
            Float.Equals(other.Float) &&
            Double.Equals(other.Double) &&
            Decimal == other.Decimal &&
            string.Equals(String, other.String) &&
            DateTime.Equals(other.DateTime) &&
            TimeSpan.Equals(other.TimeSpan) &&
            Guid.Equals(other.Guid) &&
            NullableDateTime.Equals(other.NullableDateTime) &&
            NullableTimeSpan.Equals(other.NullableTimeSpan) &&
            NullableGuid.Equals(other.NullableGuid));
 }
コード例 #4
0
        public void Can_Cache_AllFields()
        {
            JsConfig.DateHandler = DateHandler.ISO8601;

            var dto = new AllFields
            {
                Id = 1,
                NullableId = 2,
                Byte = 3,
                Short = 4,
                Int = 5,
                Long = 6,
                UShort = 7,
                UInt = 8,
                Float = 1.1f,
                Double = 2.2d,
                Decimal = 3.3m,
                String = "String",
                DateTime = DateTime.Now,
                TimeSpan = new TimeSpan(1, 1, 1, 1, 1),
                Guid = Guid.NewGuid(),
                NullableTimeSpan = new TimeSpan(2, 2, 2),
                NullableGuid = new Guid("4B6BB8AE-57B5-4B5B-8632-0C35AF0B3168"),
            };

            Cache.Set("allfields", dto);
            var fromCache = Cache.Get<AllFields>("allfields");

            Assert.That(fromCache.DateTime, Is.EqualTo(dto.DateTime));

            Assert.That(fromCache.Equals(dto));

            JsConfig.Reset();
        }