Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Communication] - PhoneNumberAdministrationClient - adding live tests #16962

Merged
merged 6 commits into from
Nov 25, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public PhoneNumberAdministrationClientTestEnvironment() : base("communication")
{
}

internal const string ConnectionStringEnvironmentVariableName = "COMMUNICATION_CONNECTION_STRING";
private const string ConnectionStringEnvironmentVariableName = "COMMUNICATION_CONNECTION_STRING";

public string ConnectionString => GetRecordedVariable(ConnectionStringEnvironmentVariableName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public PhoneNumberAdministrationClientLiveTests(bool isAsync) : base(isAsync)
[Test]
[TestCase(null, TestName = "GetAllSupportedCountries")]
[TestCase("en-US", TestName = "GetAllSupportedCountriesEnUsLocale")]
public async Task GetAllSupportedCountries(string locale)
public async Task GetAllSupportedCountries(string? locale)
{
var client = CreateClient();

Expand All @@ -48,7 +48,6 @@ public async Task GetAllSupportedCountries(string locale)
}

[Test]
[AsyncOnly]
public async Task GetAllPhoneNumbers()
{
var client = CreateClient();
Expand All @@ -57,7 +56,7 @@ public async Task GetAllPhoneNumbers()
var numbers = await numbersPagable.ToEnumerableAsync();

Assert.IsNotNull(numbers);
Assert.IsTrue(numbers.Count > 0);
Assert.IsNotEmpty(numbers);
}

[Test]
Expand Down Expand Up @@ -107,7 +106,7 @@ public async Task GetPhonePlans(string? locale)
var phonePlans = await pageablePhonePlans.ToEnumerableAsync();

Assert.IsNotNull(phonePlans);
Assert.IsTrue(phonePlans.Count > 0);
Assert.IsNotEmpty(phonePlans);
}

[Test]
Expand All @@ -133,19 +132,19 @@ public async Task GetAreaCodesForPlan(string? locale)
new LocationOptionsQuery
{
LabelId = "state",
OptionsValue = "WA"
OptionsValue = "NY"
},
new LocationOptionsQuery
{
LabelId = "city",
OptionsValue = "NOAM-US-WA-SE"
OptionsValue = "NOAM-US-NY-NY"
}
};

var areaCodes = await client.GetAllAreaCodesAsync("selection", countryCode, phonePlanId, locationOptions);

Assert.IsNotNull(areaCodes.Value.PrimaryAreaCodes);
Assert.IsTrue(areaCodes.Value.PrimaryAreaCodes.Count > 0);
Assert.IsNotEmpty(areaCodes.Value.PrimaryAreaCodes);
}

[Test]
Expand Down Expand Up @@ -179,19 +178,7 @@ public async Task CreateReservationErrorState(string? locale)
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand you correctly, this test case only fails as expected because the recorded response has an error in it.
The code however isn't guranteed to produce an error case by itself, and it made me as the reader wonder what's supposedly wrong with it.

The problem with this approach is that recordings can no longer be regenerated and do the same thing because they rely on a server condition that we can't control.

Can we change the code instead to reliably produce an error state?

}

Assert.Fail("WaitForCompletionAsync shoul have throun exception.");

Assert.IsNotNull(reservationOperation);
Assert.IsTrue(reservationOperation.HasCompleted);
Assert.IsTrue(reservationOperation.HasValue);

var reservation = reservationOperation.Value;
Assert.IsNotNull(reservation);

Assert.AreEqual(ReservationStatus.Reserved, reservation.Status);
Assert.AreEqual(areaCode, reservation.AreaCode);
Assert.IsNull(reservation.ErrorCode);
Assert.AreEqual(1, reservation.PhoneNumbers?.Count);
Assert.Fail("WaitForCompletionAsync should have thrown an exception.");
}

[Test]
Expand Down
Loading