Esempio n. 1
0
        public async Task Test_FunctionClaimAudit_ShouldHitTheEndPointAndRaiseSqlConnectionException()
        {
            try
            {
                var fakeLogger = new Mock <ILogger>();
                var claimAudit = new ClaimAudit()
                {
                    Id          = 2,
                    Name        = "Test Name",
                    Year        = 2015,
                    DamageCost  = 23.1M,
                    Type        = ClaimType.Collision.GetDescription(),
                    CreatedAt   = DateTime.UtcNow,
                    RequestName = "Add Claim"
                };
                var eventData = new EventGridEvent()
                {
                    Id          = Guid.NewGuid().ToString(),
                    EventType   = claimAudit.RequestName,
                    Data        = JsonConvert.SerializeObject(claimAudit),
                    EventTime   = DateTime.UtcNow,
                    Subject     = claimAudit.Name,
                    DataVersion = "2.0"
                };
                await FunctionClaimAudit.RunAsync(eventData, fakeLogger.Object);

                Assert.True(true);
            }
            catch (Exception exception)
            {
                Assert.Fail($"azure sql server connection string not being accessed {exception.Message}");
            }
        }
Esempio n. 2
0
        public async Task PublishClaimAuditEvent(ClaimAudit claimAudit)
        {
            var events = new List <EventGridEvent>()
            {
                new EventGridEvent
                {
                    Id          = Guid.NewGuid().ToString(),
                    EventType   = claimAudit.RequestName,
                    Data        = JsonConvert.SerializeObject(claimAudit),
                    EventTime   = DateTime.UtcNow,
                    Subject     = claimAudit.Name,
                    DataVersion = "2.0"
                }
            };
            var eventGridTopicHostUri     = _configuration["eventGridTopicHostUri"];
            var topicHostname             = new Uri(@eventGridTopicHostUri).Host;
            var eventGridTopicCredentials = _configuration["eventGridTopicCredentials"];
            var topicCredentials          = new TopicCredentials(eventGridTopicCredentials);
            var client = new EventGridClient(topicCredentials);

            await client.PublishEventsAsync(topicHostname, events);
        }