예제 #1
0
        public async Task PutAsync_ExpectedCall()
        {
            IConnection connection = NSubstitute.Substitute.For <IConnection>();

            connection.PutAsync <object>("testresource").Returns(Task.Run(() => new ClientResponse <object>()
            {
                StatusCode = 200
            }));

            TestUKFastClient client = new TestUKFastClient(connection);

            await client.PutAsync("testresource");

            await connection.Received().PutAsync <object>("testresource");
        }
예제 #2
0
        public async Task PutAsyncGeneric_ExpectedCall()
        {
            ModelBase model = new ModelBase();

            var mockResponse = GetSingleResponse(model, 0);

            mockResponse.StatusCode = 200;

            IConnection connection = NSubstitute.Substitute.For <IConnection>();

            connection.PutAsync <ModelBase>("testresource").Returns(Task.Run(() => mockResponse));

            TestUKFastClient client = new TestUKFastClient(connection);

            var result = await client.PutAsync <ModelBase>("testresource");

            Assert.AreEqual(model, result);
            await connection.Received().PutAsync <ModelBase>("testresource");
        }