コード例 #1
0
ファイル: CategoriesDeleteTests.cs プロジェクト: Kubion70/AP
        public async Task CategoryDeleteOperationsTest()
        {
            var unauthorizedResponse = await DefaultClient.DeleteAsync($"api/Categories/{Guid.NewGuid()}");

            Assert.Equal(HttpStatusCode.Unauthorized, unauthorizedResponse.StatusCode);

            var notExistingResponse = await AuthorizedClient.DeleteAsync($"api/Categories/{Guid.NewGuid()}");

            Assert.Equal(HttpStatusCode.NoContent, notExistingResponse.StatusCode);

            var badResponse = await AuthorizedClient.DeleteAsync($"api/Categories/{Guid.Empty}");

            Assert.Equal(HttpStatusCode.BadRequest, badResponse.StatusCode);

            var category = new Models.Category()
            {
                Name = "IsDeletePossible"
            };

            category = await categoryRepository.Create(category);

            var response = await AuthorizedClient.DeleteAsync($"api/Categories/{category.Id}");

            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
        }
コード例 #2
0
ファイル: UsersDeleteTests.cs プロジェクト: Kubion70/AP
        public async Task IsDeleteOperationWorksCorrectly()
        {
            var unauthResponse = await DefaultClient.DeleteAsync($"api/Users/{sampleUser.Id}");

            Assert.Equal(HttpStatusCode.Unauthorized, unauthResponse.StatusCode);

            var badResponse = await AuthorizedClient.DeleteAsync($"api/Users/{Guid.Empty}");

            Assert.Equal(HttpStatusCode.BadRequest, badResponse.StatusCode);

            var noContentResponse = await AuthorizedClient.DeleteAsync($"api/Users/{Guid.NewGuid()}");

            Assert.Equal(HttpStatusCode.NoContent, noContentResponse.StatusCode);

            var response = await AuthorizedClient.DeleteAsync($"api/Users/{sampleUser.Id}");

            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
        }