Exemple #1
0
        public void GetAllCategories_ReturnsAListOfProductCategoriesOfLengthZero_WhenCalledAndTheDatabaseIsEmpty()
        {
            // Arrange
            int expected = 0;
            SqlServerCategoryRepository categoryRepo = new SqlServerCategoryRepository(context);

            // Act
            int actual = categoryRepo.GetAllCategories().Count();

            // Assert
            Assert.AreEqual(expected, actual);
        }
Exemple #2
0
        public void GetCategoryById_ReturnsADefaultProductCategoriyOfIdValueOfZero_WhenCalledWithValidIdOfValueOneButDatabaseIsEmpty()
        {
            // Arrange
            int expected = 0;
            int id       = 1;
            SqlServerCategoryRepository categoryRepo = new SqlServerCategoryRepository(context);

            // Act
            int actual = categoryRepo.GetCategoryById(id).Id;

            // Assert
            Assert.AreEqual(expected, actual);
        }
Exemple #3
0
        public void CheckCategoryName_ReturnsABoolOfValueFalse_WhenCalledAndProductCategoryNameIsNotInDatabase()
        {
            // Arrange
            bool   expected = false;
            string name     = "name";
            SqlServerCategoryRepository categoryRepo = new SqlServerCategoryRepository(context);

            // Act
            bool actual = categoryRepo.CheckCategoryName(name);

            // Assert
            Assert.AreEqual(expected, actual);
        }
Exemple #4
0
        public void GetCategoryById_ReturnsAProductCategoriyOfIdValueOfOne_WhenCalledWithValidIdOfValueOnePresentInDatabase()
        {
            // Arrange
            int expected = 1;
            int id       = 1;

            InsertData();
            SqlServerCategoryRepository categoryRepo = new SqlServerCategoryRepository(context);

            // Act
            int actual = categoryRepo.GetCategoryById(id).Id;

            // Assert
            Assert.AreEqual(expected, actual);
        }
Exemple #5
0
        public void AddNewCategory_ReturnsAProductCategoriyOfIdValueOfOne_WhenCalledWithValidIdOfValueOnePresentInDatabase()
        {
            // Arrange
            int             expected = 1;
            ProductCategory category = new ProductCategory();

            category.Id = 1;
            category.ProductCategoryName = "name";
            SqlServerCategoryRepository categoryRepo = new SqlServerCategoryRepository(context);

            // Act
            categoryRepo.AddNewCategory(category);
            int actual = context.ProductCategories.ToList().Count();

            // Assert
            Assert.AreEqual(expected, actual);
        }
Exemple #6
0
        public void CheckCategoryName_ReturnsABoolOfValueTrue_WhenCalledAndProductCategoryNamePresentInDatabase()
        {
            // Arrange
            bool            expected = true;
            string          name     = "name";
            ProductCategory category = new ProductCategory();

            category.Id = 1;
            category.ProductCategoryName = "name";
            context.ProductCategories.Add(category);
            context.SaveChanges();
            SqlServerCategoryRepository categoryRepo = new SqlServerCategoryRepository(context);

            // Act
            bool actual = categoryRepo.CheckCategoryName(name);

            // Assert
            Assert.AreEqual(expected, actual);
        }