Skip to content

Commit 1ccd27a

Browse files
author
Leo
committed
Fix broken test
1 parent b22734a commit 1ccd27a

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

FirebaseAdmin/FirebaseAdmin.Tests/Messaging/TopicManagementResponseTest.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public void SuccessfulReponse()
1515
var response = new TopicManagementResponse(topicManagementResults);
1616

1717
Assert.Empty(response.Errors);
18-
Assert.Equal(2, response.SuccessCount);
18+
Assert.Equal(1, response.SuccessCount);
1919
}
2020

2121
[Fact]
@@ -34,7 +34,7 @@ public void UnsuccessfulResponse()
3434
[Fact]
3535
public void NullResponse()
3636
{
37-
Assert.Throws<ArgumentException>(() =>
37+
Assert.Throws<ArgumentNullException>(() =>
3838
{
3939
new TopicManagementResponse(null);
4040
});
@@ -55,9 +55,7 @@ public void UnknownError()
5555
var topicManagementResults = new List<string> { "NOT_A_REAL_ERROR_CODE" };
5656
var response = new TopicManagementResponse(topicManagementResults);
5757

58-
Assert.Empty(response.Errors);
59-
Assert.Equal(0, response.SuccessCount);
60-
Assert.NotEmpty(response.Errors);
58+
Assert.Single(response.Errors);
6159
Assert.Equal("unknown-error", response.Errors[0].Reason);
6260
Assert.Equal(0, response.Errors[0].Index);
6361
}
@@ -68,8 +66,9 @@ public void UnexpectedResponse()
6866
var topicManagementResults = new List<string> { "NOT_A_REAL_CODE" };
6967
var response = new TopicManagementResponse(topicManagementResults);
7068

71-
Assert.Empty(response.Errors);
72-
Assert.Equal(1, response.SuccessCount);
69+
Assert.Single(response.Errors);
70+
Assert.Equal("unknown-error", response.Errors[0].Reason);
71+
Assert.Equal(0, response.SuccessCount);
7372
}
7473

7574
[Fact]

FirebaseAdmin/FirebaseAdmin/Messaging/TopicManagementResponse.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
using System;
1516
using System.Collections.Generic;
1617
using System.Linq;
1718

@@ -22,15 +23,21 @@ namespace FirebaseAdmin.Messaging
2223
/// </summary>
2324
public sealed class TopicManagementResponse
2425
{
25-
private IEnumerable<string> topicManagementResults;
26-
2726
/// <summary>
2827
/// Initializes a new instance of the <see cref="TopicManagementResponse"/> class.
2928
/// </summary>
3029
/// <param name="topicManagementResults">The results from the response produced by FCM topic management operations.</param>
3130
public TopicManagementResponse(List<string> topicManagementResults)
3231
{
33-
this.topicManagementResults = topicManagementResults;
32+
if (topicManagementResults == null)
33+
{
34+
throw new ArgumentNullException("Topic management response list is null");
35+
}
36+
37+
if (topicManagementResults.Count() == 0)
38+
{
39+
throw new ArgumentException("Topic management response list is empty");
40+
}
3441

3542
var resultErrors = new List<ErrorInfo>();
3643
for (var i = 0; i < topicManagementResults.Count(); i++)

0 commit comments

Comments
 (0)