Exemple #1
0
        public async Task GetAll_ShouldSuccess()
        {
            //ARRANGE
            const string catDesc     = "cat desc";
            const string catDesc2    = "cat desc2";
            const string catName     = "cat name";
            const string catName2    = "cat name2";
            var          categoryId  = new Guid("7BC0C011-7FA3-4AA4-B260-257465831D65");
            var          categoryId2 = new Guid("FB7871B2-B08F-487F-9739-0172C77A4BDD");


            var categories = new List <Category>
            {
                new Category
                {
                    Description = catDesc,
                    Name        = catName,
                    Id          = categoryId
                },
                new Category
                {
                    Description = catDesc,
                    Name        = catName,
                    Id          = categoryId
                }
            };


            _categoryRepositoryMock.Setup(cr => cr.GetAllCategories())
            .ReturnsAsync(categories);

            //ACT
            GetAllCategoriesResponse actual = await _categoryService.GetAll();

            //ASSERT
            var expected = new GetAllCategoriesResponse
            {
                Categories = new List <CategoryDto>
                {
                    new CategoryDto
                    {
                        Description = catDesc,
                        Name        = catName,
                        Id          = categoryId
                    },
                    new CategoryDto
                    {
                        Description = catDesc2,
                        Name        = catName2,
                        Id          = categoryId2
                    }
                }
            };

            ContentAssert.AreCollectionsEquivalent(expected.Categories, actual.Categories);
        }