Example #1
0
        public async Task Reserve_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.ReserveAsync(It.IsAny <Duration>(), It.IsAny <Metadata>(), It.IsAny <DateTime?>(), It.IsAny <CancellationToken>())).Returns(fakeCall);
            mockSdk.client = mockClient.Object;

            var result = await mockSdk.ReserveAsync(30);

            Assert.AreEqual(expected, result.StatusCode);
        }
Example #2
0
        public async Task Reserve_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(), () => { });
            var expectedDuration = new Duration();

            expectedDuration.Seconds = 30;
            Duration actualDuration = null;

            mockClient.Setup(m => m.ReserveAsync(It.IsAny <Duration>(), It.IsAny <Metadata>(), It.IsAny <DateTime?>(), It.IsAny <CancellationToken>())).Returns(fakeCall)
            .Callback(
                (Duration dur, Metadata md, DateTime? dt, CancellationToken ct) => {
                actualDuration = dur;
            });
            mockSdk.client = mockClient.Object;

            var result = await mockSdk.ReserveAsync(30);

            Assert.AreEqual(expectedDuration, actualDuration);
        }