diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index 3b3119a4026e6..4881715dc9842 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -274,7 +274,7 @@
/sdk/communication/Azure.Communication.ShortCodes/ @guilhermeluizsp @danielav7
# PRLabel: %Communication - SMS
-/sdk/communication/Azure.Communication.Sms/ @RoyHerrod @arifibrahim4
+/sdk/communication/Azure.Communication.Sms/ @DimaKolomiiets @ozgurcivi-msft @gfeitosa-msft @phermanov-msft @ilyapaliakou-msft
# PRLabel: %Communication - Resource Manager
/sdk/communication/Azure.ResourceManager.Communication/ @archerzz @ArcturusZhang @ArthurMa1978
diff --git a/sdk/communication/Azure.Communication.Sms/src/Properties/AssemblyInfo.cs b/sdk/communication/Azure.Communication.Sms/src/Properties/AssemblyInfo.cs
index 16e77c9ad7e4e..84ba5171f883a 100644
--- a/sdk/communication/Azure.Communication.Sms/src/Properties/AssemblyInfo.cs
+++ b/sdk/communication/Azure.Communication.Sms/src/Properties/AssemblyInfo.cs
@@ -4,3 +4,4 @@
using System.Runtime.CompilerServices;
[assembly: Azure.Core.AzureResourceProviderNamespace("Communication")]
+[assembly: InternalsVisibleTo("Azure.Communication.Sms.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d15ddcb29688295338af4b7686603fe614abd555e09efba8fb88ee09e1f7b1ccaeed2e8f823fa9eef3fdd60217fc012ea67d2479751a0b8c087a4185541b851bd8b16f8d91b840e51b1cb0ba6fe647997e57429265e85ef62d565db50a69ae1647d54d7bd855e4db3d8a91510e5bcbd0edfbbecaa20a7bd9ae74593daa7b11b4")]
diff --git a/sdk/communication/Azure.Communication.Sms/tests.yml b/sdk/communication/Azure.Communication.Sms/tests.yml
index ecafa56d8b9a3..43c2e15970578 100644
--- a/sdk/communication/Azure.Communication.Sms/tests.yml
+++ b/sdk/communication/Azure.Communication.Sms/tests.yml
@@ -11,6 +11,11 @@ extends:
- $(sub-config-azure-cloud-test-resources)
- $(sub-config-communication-services-cloud-test-resources-common)
- $(sub-config-communication-services-cloud-test-resources-net)
- Clouds: Public
+ - $(sub-config-communication-services-sms-cloud-test-resources)
+ Int:
+ SubscriptionConfigurations:
+ - $(sub-config-communication-int-test-resources-common)
+ - $(sub-config-communication-int-test-resources-net)
+ Clouds: Public,Int
TestResourceDirectories:
- communication/test-resources/
diff --git a/sdk/communication/Azure.Communication.Sms/tests/Azure.Communication.Sms.Tests.csproj b/sdk/communication/Azure.Communication.Sms/tests/Azure.Communication.Sms.Tests.csproj
index f27ab63e2d1cb..d6b080ed84a73 100644
--- a/sdk/communication/Azure.Communication.Sms/tests/Azure.Communication.Sms.Tests.csproj
+++ b/sdk/communication/Azure.Communication.Sms/tests/Azure.Communication.Sms.Tests.csproj
@@ -11,15 +11,10 @@
-
-
-
-
-
diff --git a/sdk/communication/Azure.Communication.Sms/tests/SmsClientLiveTestBase.cs b/sdk/communication/Azure.Communication.Sms/tests/SmsClientLiveTestBase.cs
index cfd6ee898fa97..85c56ae027a80 100644
--- a/sdk/communication/Azure.Communication.Sms/tests/SmsClientLiveTestBase.cs
+++ b/sdk/communication/Azure.Communication.Sms/tests/SmsClientLiveTestBase.cs
@@ -42,6 +42,22 @@ public SmsClient CreateSmsClient()
return InstrumentClient(client);
}
+ public SmsClient CreateSmsClientWithNullOptions()
+ {
+ var connectionString = TestEnvironment.LiveTestStaticConnectionString;
+ SmsClient client = new SmsClient(connectionString, null);
+
+ return InstrumentClient(client);
+ }
+
+ public SmsClient CreateSmsClientWithoutOptions()
+ {
+ var connectionString = TestEnvironment.LiveTestStaticConnectionString;
+ SmsClient client = new SmsClient(connectionString);
+
+ return InstrumentClient(client);
+ }
+
public SmsClient CreateSmsClientWithToken()
{
Uri endpoint = TestEnvironment.LiveTestStaticEndpoint;
diff --git a/sdk/communication/Azure.Communication.Sms/tests/SmsClientLiveTests.cs b/sdk/communication/Azure.Communication.Sms/tests/SmsClientLiveTests.cs
index 67ba2c35ac695..9bc146e4e6124 100644
--- a/sdk/communication/Azure.Communication.Sms/tests/SmsClientLiveTests.cs
+++ b/sdk/communication/Azure.Communication.Sms/tests/SmsClientLiveTests.cs
@@ -76,7 +76,7 @@ public async Task SendingSmsMessageUsingTokenCredential()
[TestCase("+15550000000", Description = "Fake number")]
public async Task SendingSmsMessageFromUnauthorizedNumber(string from)
{
- SmsClient client = CreateSmsClient();
+ SmsClient client = CreateSmsClientWithNullOptions();
try
{
SmsSendResult result = await client.SendAsync(
@@ -167,7 +167,7 @@ public async Task SendingTwoSmsMessages()
[Test]
public async Task SendingSmsFromNullNumberShouldThrow()
{
- SmsClient client = CreateSmsClient();
+ SmsClient client = CreateSmsClientWithoutOptions();
try
{
SmsSendResult result = await client.SendAsync(
diff --git a/sdk/communication/Azure.Communication.Sms/tests/SmsClientTest.cs b/sdk/communication/Azure.Communication.Sms/tests/SmsClientTest.cs
index fac87926c0d69..5d52342452add 100644
--- a/sdk/communication/Azure.Communication.Sms/tests/SmsClientTest.cs
+++ b/sdk/communication/Azure.Communication.Sms/tests/SmsClientTest.cs
@@ -7,7 +7,8 @@
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;
-using Azure.Communication.Sms.Models;
+using Azure.Core;
+using Azure.Core.TestFramework;
using Moq;
using NUnit.Framework;
@@ -15,6 +16,56 @@ namespace Azure.Communication.Sms.Tests
{
public class SmsClientTest
{
+ [Test]
+ public void SmsClient_ThrowsWithNullKeyCredential()
+ {
+ AzureKeyCredential? nullCredential = null;
+ Uri uri = new Uri("http://localhost");
+
+ Assert.Throws(() => new SmsClient(uri, nullCredential));
+ }
+
+ [Test]
+ public void SmsClient_ThrowsWithNullUri()
+ {
+ AzureKeyCredential mockCredential = new AzureKeyCredential("mockKey");
+
+ Assert.Throws(() => new SmsClient(null, mockCredential));
+ }
+
+ [Test]
+ public void SmsClient_KeyCredential_ValidParameters()
+ {
+ AzureKeyCredential mockCredential = new AzureKeyCredential("mockKey");
+ Uri uri = new Uri("http://localhost");
+
+ Assert.DoesNotThrow(() => new SmsClient(uri, mockCredential));
+ }
+
+ [Test]
+ public void SmsClient_TokenCredential_NullOptions()
+ {
+ TokenCredential mockCredential = new MockCredential();
+ Uri endpoint = new Uri("http://localhost");
+
+ Assert.DoesNotThrow(() => new SmsClient(endpoint, mockCredential, null));
+ }
+
+ [Test]
+ public void SmsClient_ThrowsWithNullOrEmptyConnectionString()
+ {
+ Assert.Throws(() => new SmsClient(string.Empty));
+ Assert.Throws(() => new SmsClient(null));
+ }
+
+ [Test]
+ public void SmsClientOptions_ThrowsWithInvalidVersion()
+ {
+ var invalidServiceVersion = (SmsClientOptions.ServiceVersion)2;
+
+ Assert.Throws(() => new SmsClientOptions(invalidServiceVersion));
+ }
+
[TestCaseSource(nameof(TestDataForSingleSms))]
public async Task SendSmsAsyncOverload_PassesToGeneratedOne(string expectedFrom, string expectedTo, string expectedMessage, SmsSendOptions expectedOptions)
{
diff --git a/sdk/communication/Azure.Communication.Sms/tests/SmsRestClientTest.cs b/sdk/communication/Azure.Communication.Sms/tests/SmsRestClientTest.cs
new file mode 100644
index 0000000000000..3f6ff2d60aa79
--- /dev/null
+++ b/sdk/communication/Azure.Communication.Sms/tests/SmsRestClientTest.cs
@@ -0,0 +1,178 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+using System;
+using System.Linq;
+using System.Threading.Tasks;
+using Azure.Communication.Sms.Models;
+using Azure.Core.Pipeline;
+using Azure.Core.TestFramework;
+using NUnit.Framework;
+
+namespace Azure.Communication.Sms.Tests
+{
+ public class SmsRestClientTest
+ {
+ [Test]
+ public void SmsRestClient_NullClientDiagnostics_ShouldThrow()
+ {
+ var httpPipeline = HttpPipelineBuilder.Build(new SmsClientOptions());
+ var uri = "http://localhost";
+
+ Assert.Throws(() => new SmsRestClient(null, httpPipeline, uri));
+ }
+
+ [Test]
+ public void SmsRestClient_NullHttpPipeline_ShouldThrow()
+ {
+ var clientDiagnostics = new ClientDiagnostics(new SmsClientOptions());
+ var endpoint = "http://localhost";
+
+ Assert.Throws(() => new SmsRestClient(clientDiagnostics, null, endpoint));
+ }
+
+ [Test]
+ public void SmsRestClient_NullEndpoint_ShouldThrow()
+ {
+ var clientDiagnostics = new ClientDiagnostics(new SmsClientOptions());
+ var httpPipeline = HttpPipelineBuilder.Build(new SmsClientOptions());
+
+ Assert.Throws(() => new SmsRestClient(clientDiagnostics, httpPipeline, null));
+ }
+
+ [Test]
+ public void SmsRestClient_NullVersion_ShouldThrow()
+ {
+ var clientOptions = new SmsClientOptions();
+ var clientDiagnostics = new ClientDiagnostics(clientOptions);
+ var httpPipeline = HttpPipelineBuilder.Build(clientOptions);
+ var uri = "http://localhost";
+
+ Assert.Throws(() => new SmsRestClient(clientDiagnostics, httpPipeline, uri, null));
+ }
+
+ [Test]
+ public void SmsRestClient_SendWithNullSender_ShouldThrow()
+ {
+ var client = CreateSmsRestClient();
+
+ var recipients = Enumerable.Empty();
+ var message = "Message";
+
+ try
+ {
+ client.Send(null, recipients, message);
+ }
+ catch (ArgumentNullException ex)
+ {
+ Assert.AreEqual("from", ex.ParamName);
+ return;
+ }
+ }
+
+ [Test]
+ public void SmsRestClient_SendWithNullRecipients_ShouldThrow()
+ {
+ var client = CreateSmsRestClient();
+
+ var from = "+123456789";
+ var message = "Message";
+
+ try
+ {
+ client.Send(from, null, message);
+ }
+ catch (ArgumentNullException ex)
+ {
+ Assert.AreEqual("smsRecipients", ex.ParamName);
+ return;
+ }
+ }
+
+ [Test]
+ public void SmsRestClient_SendWithNullMessage_ShouldThrow()
+ {
+ var client = CreateSmsRestClient();
+
+ var from = "+123456789";
+ var recipients = Enumerable.Empty();
+
+ try
+ {
+ client.Send(from, recipients, null);
+ }
+ catch (ArgumentNullException ex)
+ {
+ Assert.AreEqual("message", ex.ParamName);
+ return;
+ }
+ }
+
+ [Test]
+ public async Task SmsRestClient_SendAsyncWithNullSender_ShouldThrow()
+ {
+ var client = CreateSmsRestClient();
+
+ var recipients = Enumerable.Empty();
+ var message = "Message";
+
+ try
+ {
+ await client.SendAsync(null, recipients, message);
+ }
+ catch (ArgumentNullException ex)
+ {
+ Assert.AreEqual("from", ex.ParamName);
+ return;
+ }
+ }
+
+ [Test]
+ public async Task SmsRestClient_SendAsyncWithNullRecipients_ShouldThrow()
+ {
+ var client = CreateSmsRestClient();
+
+ var from = "+123456789";
+ var message = "Message";
+
+ try
+ {
+ await client.SendAsync(from, null, message);
+ }
+ catch (ArgumentNullException ex)
+ {
+ Assert.AreEqual("smsRecipients", ex.ParamName);
+ return;
+ }
+ }
+
+ [Test]
+ public async Task SmsRestClient_SendAsyncWithNullMessage_ShouldThrow()
+ {
+ var client = CreateSmsRestClient();
+
+ var from = "+123456789";
+ var recipients = Enumerable.Empty();
+
+ try
+ {
+ await client.SendAsync(from, recipients, null);
+ }
+ catch (ArgumentNullException ex)
+ {
+ Assert.AreEqual("message", ex.ParamName);
+ return;
+ }
+ }
+
+ private SmsRestClient CreateSmsRestClient()
+ {
+ var clientOptions = new SmsClientOptions();
+ var clientDiagnostics = new ClientDiagnostics(clientOptions);
+ var httpPipeline = HttpPipelineBuilder.Build(clientOptions);
+ var endpoint = "http://localhost";
+
+ return new SmsRestClient(clientDiagnostics, httpPipeline, endpoint);
+ }
+ }
+}