示例#1
0
        public async Task DeleteAsync_ExpectedCall()
        {
            IConnection connection = NSubstitute.Substitute.For <IConnection>();

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

            TestUKFastClient client = new TestUKFastClient(connection);

            await client.DeleteAsync("testresource");

            await connection.Received().DeleteAsync <object>("testresource");
        }
示例#2
0
        public async Task DeleteAsyncGeneric_ExpectedCall()
        {
            ModelBase model = new ModelBase();

            var mockResponse = GetSingleResponse(model, 0);

            mockResponse.StatusCode = 200;

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

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

            TestUKFastClient client = new TestUKFastClient(connection);

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

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