コード例 #1
0
        public Task <T> GetAsync <T>(AlertContactId id) where T : IAlertContact
        {
            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }

            var uri     = _configs.DocumentCollectionUri;
            var options = new FeedOptions()
            {
                MaxItemCount = 1
            };

            var querySpec = new SqlQuerySpec
            {
                QueryText  = "select * from root r where (r.id = @id and r._type = @type)",
                Parameters = new SqlParameterCollection
                {
                    new SqlParameter("@id", id.ToString()),
                    new SqlParameter("@type", DocumentType)
                }
            };

            return(_client.CreateDocumentQuery <T>(uri, querySpec, options)
                   .AsDocumentQuery()
                   .FirstOrDefaultAsync());
        }
        public async Task GetByIdReturnsNullWhenNotExists()
        {
            // Arrange
            var entityId = AlertContactId.Create();

            // Act
            var readEntity = await _repository.GetAsync(entityId);

            // Assert
            Assert.Null(readEntity);
        }
コード例 #3
0
        public ScheduleDownAlertContact(AlertContactId alertContactId, HttpMonitorId httpMonitorId, MonitorStatus previousStatus, DateTime startTime, DateTime created)
        {
            if (!Enum.IsDefined(typeof(MonitorStatus), previousStatus))
            {
                throw new InvalidEnumArgumentException(nameof(previousStatus), (int)previousStatus,
                                                       typeof(MonitorStatus));
            }

            AlertContactId = alertContactId ?? throw new ArgumentNullException(nameof(alertContactId));
            HttpMonitorId  = httpMonitorId ?? throw new ArgumentNullException(nameof(httpMonitorId));
            PreviousStatus = previousStatus;
            StartTime      = startTime;
            Created        = created;
        }
コード例 #4
0
 public Task <IAlertContact> GetAsync(AlertContactId id)
 {
     return(GetAsync <IAlertContact>(id));
 }
 private static SlackAlertContact GenerateSlackAlertContact()
 {
     return(new SlackAlertContact(AlertContactId.Create(), new Uri("http://slack.example.com/hook")));
 }
 private static EmailAlertContact GenerateEmailAlertContact(AlertContactId id)
 {
     return(new EmailAlertContact(id, "*****@*****.**"));
 }
 private static EmailAlertContact GenerateEmailAlertContact()
 {
     return(GenerateEmailAlertContact(AlertContactId.Create()));
 }