Ejemplo n.º 1
0
        public async Task Should_Make_Request_Using_DELETE_Verb_Ignoring_Given_Verb()
        {
            // Arrange
            _restClientMock.Setup(client => client.ExecuteTaskAsync(It.IsAny <IRestRequest>(), It.IsAny <CancellationToken>())).ReturnsAsync(new RestResponse
            {
                StatusCode     = HttpStatusCode.OK,
                ResponseStatus = ResponseStatus.Completed
            });

            var request = new ApiRequest("resource")
            {
                HttpMethod = HttpMethods.Post
            };

            // Act
            await _sut.Delete(request, CancellationToken.None);

            // Assert
            _restClientMock.Verify(client => client.ExecuteTaskAsync(It.Is <IRestRequest>(req => req.Method == Method.DELETE), It.IsAny <CancellationToken>()), Times.Once);
        }
Ejemplo n.º 2
0
        public async Task TestPushAndDelete()
        {
            var packageName = new PackageName("test", "1.0");

            using (var stream = new MemoryStream())
            {
                client.Generate(stream, packageName);
                stream.Position = 0;

                Assert.Empty(await client.Query());
                Assert.Empty(await clientForNew.Query());
                client.Push(stream, apiKey);
                Assert.Empty(await client.Query());
                var packageNames = await clientForNew.Query();

                Assert.Equal(1, packageNames.Count);

                clientForNew.Delete(apiKey, packageNames[0]);
                Assert.Empty(await clientForNew.Query());
            }
        }
Ejemplo n.º 3
0
        public async Task TestPushAndDeleteWithInvalidKey()
        {
            var invalidApiKey = Guid.NewGuid().ToString();
            var packageName   = new PackageName("test", "1.0");

            using (var stream = new MemoryStream())
            {
                client.Generate(stream, packageName);
                stream.Position = 0;

                Assert.Empty(await client.Query());
                Assert.Empty(await clientForNew.Query());
                client.Push(stream, apiKey);

                var packageNames = await clientForNew.Query();

                Assert.Equal(1, packageNames.Count);
                var exception = Assert.Throws <InvalidOperationException>(() => client.Delete(invalidApiKey, packageNames[0]));
                Assert.Contains("403", exception.Message);
                Assert.NotEmpty(await clientForNew.Query());
            }
        }
Ejemplo n.º 4
0
 public static void UnregisterProfile(this TestClient client)
 {
     client.Delete("/api/profiles/deleteMine");
 }