public void BuildSharedAccessSignatureThrowsWhenCalledFromSasClient()
        {
            EventGridClient client = new EventGridClient(
                new Uri("https://exampletopic.westus2-1.eventgrid.azure.net/api/events"),
                new AzureKeyCredential("thisIsNotAFakeCredential"));

            string          sasToken       = client.BuildSharedAccessSignature(DateTimeOffset.UtcNow.AddMinutes(60));
            EventGridClient sasTokenClient = new EventGridClient(
                new Uri("https://exampletopic.westus2-1.eventgrid.azure.net/api/events"),
                new SharedAccessSignatureCredential("thisIsNotAFakeCredential"));

            Assert.That(() => sasTokenClient.BuildSharedAccessSignature(DateTimeOffset.UtcNow.AddMinutes(60)),
                        Throws.InstanceOf <NotSupportedException>(),
                        "Can only create a SAS token when using an EventGridClient created using AzureKeyCredential.");
        }
        public async Task CanPublishEventUsingSAS()
        {
            EventGridClient client = new EventGridClient(
                new Uri(TestEnvironment.TopicHost),
                new AzureKeyCredential(TestEnvironment.TopicKey));

            string sasToken = client.BuildSharedAccessSignature(DateTimeOffset.UtcNow.AddMinutes(60));

            EventGridClient sasTokenClient = InstrumentClient(
                new EventGridClient(
                    new Uri(TestEnvironment.TopicHost),
                    new SharedAccessSignatureCredential(sasToken),
                    Recording.InstrumentClientOptions(new EventGridClientOptions())));
            await sasTokenClient.PublishEventsAsync(GetEventsList());
        }