public void WhenCertainNumberOfCategoriesExist_ShouldReturnOKWithCountEqualToSameNumberOfCategories()
        {
            var categoriesCountParametersModel = new CategoriesCountParametersModel();
            int categoriesCount = 20;

            // arrange
            var autoMocker = new RhinoAutoMocker <CategoriesController>();

            autoMocker.Get <ICategoryApiService>().Stub(x => x.GetCategoriesCount()).IgnoreArguments().Return(categoriesCount);

            // act
            IActionResult result = autoMocker.ClassUnderTest.GetCategoriesCount(categoriesCountParametersModel);

            // assert
            Assert.IsInstanceOf <OkObjectResult>(result);

            var okObjectResult = result as OkObjectResult;

            Assert.NotNull(okObjectResult);

            Assert.IsInstanceOf <CategoriesCountRootObject>(okObjectResult.Value);

            var rootObject = okObjectResult.Value as CategoriesCountRootObject;

            Assert.NotNull(rootObject);

            Assert.AreEqual(categoriesCount, rootObject.Count);
        }
        public void WhenSingleCategoryExists_ShouldReturnOKWithCountEqualToOne()
        {
            var parameters = new CategoriesCountParametersModel();

            // arrange
            var autoMocker = new RhinoAutoMocker <CategoriesController>();

            autoMocker.Get <ICategoryApiService>().Stub(x => x.GetCategoriesCount()).IgnoreArguments().Return(1);

            // act
            IActionResult result = autoMocker.ClassUnderTest.GetCategoriesCount(parameters);

            // assert
            Assert.IsInstanceOf <OkObjectResult>(result);

            var okObjectResult = result as OkObjectResult;

            Assert.NotNull(okObjectResult);

            Assert.IsInstanceOf <CategoriesCountRootObject>(okObjectResult.Value);

            var rootObject = okObjectResult.Value as CategoriesCountRootObject;

            Assert.NotNull(rootObject);

            Assert.AreEqual(1, rootObject.Count);
        }
        public IActionResult GetCategoriesCount(CategoriesCountParametersModel parameters)
        {
            var allCategoriesCount = _categoryApiService.GetCategoriesCount(parameters.CreatedAtMin, parameters.CreatedAtMax,
                                                                            parameters.UpdatedAtMin, parameters.UpdatedAtMax,
                                                                            parameters.PublishedStatus, parameters.ProductId);

            var categoriesCountRootObject = new CategoriesCountRootObject()
            {
                Count = allCategoriesCount
            };

            return(Ok(categoriesCountRootObject));
        }
Esempio n. 4
0
        public void WhenSingleCategoryExists_ShouldReturnOKWithCountEqualToOne()
        {
            var parameters = new CategoriesCountParametersModel();

            // arrange
            var autoMocker = new RhinoAutoMocker <CategoriesController>();

            autoMocker.Get <ICategoryApiService>().Stub(x => x.GetCategoriesCount()).IgnoreArguments().Return(1);

            // act
            IHttpActionResult result = autoMocker.ClassUnderTest.GetCategoriesCount(parameters);

            // assert
            Assert.IsInstanceOf <OkNegotiatedContentResult <CategoriesCountRootObject> >(result);
            Assert.AreEqual(1, ((OkNegotiatedContentResult <CategoriesCountRootObject>)result).Content.Count);
        }
Esempio n. 5
0
        public void WhenCertainNumberOfCategoriesExist_ShouldReturnOKWithCountEqualToSameNumberOfCategories()
        {
            var categoriesCountParametersModel = new CategoriesCountParametersModel();
            int categoriesCount = 20;

            // arrange
            var autoMocker = new RhinoAutoMocker <CategoriesController>();

            autoMocker.Get <ICategoryApiService>().Stub(x => x.GetCategoriesCount()).IgnoreArguments().Return(categoriesCount);

            // act
            IHttpActionResult result = autoMocker.ClassUnderTest.GetCategoriesCount(categoriesCountParametersModel);

            // assert
            Assert.IsInstanceOf <OkNegotiatedContentResult <CategoriesCountRootObject> >(result);
            Assert.AreEqual(categoriesCount, ((OkNegotiatedContentResult <CategoriesCountRootObject>)result).Content.Count);
        }