public async Task SetAnnotation_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.SetAnnotationAsync(It.IsAny <KeyValue>(), It.IsAny <Metadata>(), It.IsAny <DateTime?>(), It.IsAny <CancellationToken>())).Returns(fakeCall); mockSdk.client = mockClient.Object; var result = await mockSdk.SetAnnotationAsync("", ""); Assert.AreEqual(expected, result.StatusCode); }
public async Task SetAnnotation_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.SetAnnotationAsync(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.SetAnnotationAsync(expectedKeyValue.Key, expectedKeyValue.Value); Assert.AreEqual(expectedKeyValue, actualKeyValue); }