예제 #1
0
        public async Task Post_Category_response_bad_request_with_message_when_Category_image_is_empty()
        {
            var cancellationToken = new CancellationToken();
            // Act
            var categoryController = new CategoryController(_catalogContextFixture.Context,
                                                            _fileUtilityFixture.FileUtility, _settings);
            var response = await categoryController.AddNewCategoryAsync(GetTestCategoryEmptyImage(), cancellationToken);

            var badRequestResponse = Assert.IsType <BadRequestObjectResult>(response);

            Assert.Contains("Message", badRequestResponse.Value.ToString());
        }
예제 #2
0
        public async Task Post_Category_response_bad_request_with_message_when_Category_exists()
        {
            var cancellationToken = new CancellationToken();
            //Arrange
            var expectedCategory = await _catalogContextFixture.Context.Categories.ToListAsync(cancellationToken);

            if (expectedCategory.IsNullOrEmpty())
            {
                expectedCategory = await SeedCategory(cancellationToken);
            }

            // Act
            var categoryController = new CategoryController(_catalogContextFixture.Context,
                                                            _fileUtilityFixture.FileUtility, _settings);
            var response = await categoryController.AddNewCategoryAsync(expectedCategory[0], cancellationToken);

            var badRequestResponse = Assert.IsType <BadRequestObjectResult>(response);

            Assert.Contains("Message", badRequestResponse.Value.ToString());
        }