コード例 #1
0
        public async Task GetAsync_10_ReturnsValidSubcategory()
        {
            // Arrange
            const int expectedId = SubcategoriesCount;

            // Act
            var subcategory = await _subcategoryRepository.GetAsync(expectedId);

            // Assert
            Assert.NotNull(subcategory);
            Assert.NotNull(subcategory.Name);
            Assert.InRange(subcategory.CategoryId, 1, int.MaxValue);
            Assert.Equal(expectedId, subcategory.Id);
        }
コード例 #2
0
        public async Task <Subcategory> FindAsync(int id)
        {
            Guard.Against.LessOne(id, Resources.Subcategory_InvalidId_ErrorMessage);

            var subcategory = await _subcategoryRepository.GetAsync(id);

            Guard.Against.NullNotFound(subcategory, string.Format(Resources.Subcategory_NotFoundById_ErrorMessage, id));

            return(subcategory);
        }