public async Task SetLabel_Returns_OK() { var mockClient = new Mock <SDK.SDKClient>(); var mockSdk = new AgonesSDK(); var expected = StatusCode.OK; var fakeCall = TestCalls.AsyncUnaryCall(Task.FromResult(new Empty()), Task.FromResult(new Metadata()), () => Status.DefaultSuccess, () => new Metadata(), () => { }); mockClient.Setup(m => m.SetLabelAsync(It.IsAny <KeyValue>(), It.IsAny <Metadata>(), It.IsAny <DateTime?>(), It.IsAny <CancellationToken>())).Returns(fakeCall); mockSdk.client = mockClient.Object; var result = await mockSdk.SetLabelAsync("", ""); Assert.AreEqual(expected, result.StatusCode); }
public async Task SetLabel_Sends_OK() { var mockClient = new Mock <SDK.SDKClient>(); var mockSdk = new AgonesSDK(); var fakeCall = TestCalls.AsyncUnaryCall(Task.FromResult(new Empty()), Task.FromResult(new Metadata()), () => Status.DefaultSuccess, () => new Metadata(), () => { }); KeyValue expectedKeyValue = new KeyValue(); expectedKeyValue.Key = "Test"; expectedKeyValue.Value = "Test"; KeyValue actualKeyValue = null; mockClient.Setup(m => m.SetLabelAsync(It.IsAny <KeyValue>(), It.IsAny <Metadata>(), It.IsAny <DateTime?>(), It.IsAny <CancellationToken>())).Returns(fakeCall) .Callback( (KeyValue kv, Metadata md, DateTime? dt, CancellationToken ct) => { actualKeyValue = kv; }); mockSdk.client = mockClient.Object; var result = await mockSdk.SetLabelAsync(expectedKeyValue.Key, expectedKeyValue.Value); Assert.AreEqual(expectedKeyValue, actualKeyValue); }