示例#1
0
 public void ToDomain_WithNullValue_ShouldThrow()
 {
     Assert.Throws <ArgumentNullException>(
         "callback",
         () => EntityCallbackRepository.ToDomain(null)
         );
 }
示例#2
0
 public static Rule ToDomain(EntityModel rule, Callback callback = null)
 {
     return(new Rule
            (
                rule.Id,
                rule.TransactionHash,
                rule.Confirmation,
                rule.OriginalWaitingTime,
                JsonConvert.DeserializeObject <CallbackResult>(rule.SuccessData),
                JsonConvert.DeserializeObject <CallbackResult>(rule.TimeoutData),
                callback != null
             ? callback
             : (rule.Callback == null ? null : EntityCallbackRepository.ToDomain(rule.Callback)),
                DateTime.SpecifyKind(rule.CreatedAt, DateTimeKind.Utc)
            ));
 }
示例#3
0
 public static Rule ToDomain(JsonSerializer serializer, EntityModel rule, Callback callback = null)
 {
     using (var successReader = new JsonTextReader(new StringReader(rule.SuccessData)))
         using (var timeoutReader = new JsonTextReader(new StringReader(rule.TimeoutData)))
         {
             return(new Rule(
                        rule.Id,
                        rule.TransactionHash,
                        rule.Confirmation,
                        rule.OriginalWaitingTime,
                        serializer.Deserialize <CallbackResult>(successReader),
                        serializer.Deserialize <CallbackResult>(timeoutReader),
                        callback ?? EntityCallbackRepository.ToDomain(rule.Callback),
                        DateTime.SpecifyKind(rule.CreatedAt, DateTimeKind.Utc)));
         }
 }
示例#4
0
        public void ToDomain_WithValidValue_ShouldSuccess()
        {
            // Arrange.
            var time   = DateTime.UtcNow;
            var url    = new Uri("https://zcoin.io");
            var entity = new WebApiCallback
            {
                Id             = Guid.NewGuid(),
                RegisteredIp   = IPAddress.Loopback,
                RegisteredTime = time,
                Completed      = true,
                Url            = url
            };

            // Act.
            var model = EntityCallbackRepository.ToDomain(entity);

            // Assert.
            Assert.Equal(entity.Id, model.Id);
            Assert.Equal(IPAddress.Loopback, model.RegisteredIp);
            Assert.Equal(time, model.RegisteredTime);
            Assert.True(model.Completed);
            Assert.Equal(url, model.Url);
        }