Пример #1
0
        public void AddCategoryItem_ExceptionFromDataAccess()
        {
            //Arrange Exception
            var mock = new Mock<IManagerDataAccess>();
            mock.Setup(m => m.AddMenuItemCategory(It.IsAny<string>(), It.IsAny<string>())).Throws(new Exception());

            //Arrange Bar Data Model
            var BarDataModel = new BarDataModel(mock.Object);

            //Act
            var result = BarDataModel.AddCategoryItem("Żarcie", "Różne");

            //Assert
            Assert.IsNull(result);
        }
Пример #2
0
        public void AddCategoryItem_ExceptionFromDataAccess()
        {
            //Arrange Exception
            var mock = new Mock <IManagerDataAccess>();

            mock.Setup(m => m.AddMenuItemCategory(It.IsAny <string>(), It.IsAny <string>())).Throws(new Exception());

            //Arrange Bar Data Model
            var BarDataModel = new BarDataModel(mock.Object);

            //Act
            var result = BarDataModel.AddCategoryItem("Żarcie", "Różne");

            //Assert
            Assert.IsNull(result);
        }
Пример #3
0
        public void AddCategoryItem_ValidExample()
        {
            //Arrange Adding Menu item Category
            var category = new MoqMenuItemCategory(1, "Żarcie", "Różne");

            var mock = new Mock<IManagerDataAccess>();
            mock.Setup(m => m.AddMenuItemCategory(It.IsAny<string>(), It.IsAny<string>())).Returns(category);

            //Arrange Bar Data Model
            var BarDataModel = new BarDataModel(mock.Object);

            //Act
            var result = BarDataModel.AddCategoryItem("Żarcie", "Różne");

            //Assert
            Assert.AreEqual(result, category);
        }
Пример #4
0
        public void AddCategoryItem_FailedAddinToDataBase()
        {
            //Arrange ManagerDataAccess
            MenuItemCategory category = null;

            var mock = new Mock<IManagerDataAccess>();
            mock.Setup(m => m.AddMenuItemCategory(It.IsAny<string>(), It.IsAny<string>())).Returns(category);

            //Arrange Bar Data Model
            var BarDataModel = new BarDataModel(mock.Object);

            //Act
            var result = BarDataModel.AddCategoryItem("Żarcie", "Różne");

            //Assert
            Assert.IsNull(result);
        }
Пример #5
0
        public void AddCategoryItem_FailedAddinToDataBase()
        {
            //Arrange ManagerDataAccess
            MenuItemCategory category = null;

            var mock = new Mock <IManagerDataAccess>();

            mock.Setup(m => m.AddMenuItemCategory(It.IsAny <string>(), It.IsAny <string>())).Returns(category);

            //Arrange Bar Data Model
            var BarDataModel = new BarDataModel(mock.Object);

            //Act
            var result = BarDataModel.AddCategoryItem("Żarcie", "Różne");

            //Assert
            Assert.IsNull(result);
        }
Пример #6
0
        public void AddCategoryItem_ValidExample()
        {
            //Arrange Adding Menu item Category
            var category = new MoqMenuItemCategory(1, "Żarcie", "Różne");

            var mock = new Mock <IManagerDataAccess>();

            mock.Setup(m => m.AddMenuItemCategory(It.IsAny <string>(), It.IsAny <string>())).Returns(category);

            //Arrange Bar Data Model
            var BarDataModel = new BarDataModel(mock.Object);

            //Act
            var result = BarDataModel.AddCategoryItem("Żarcie", "Różne");

            //Assert
            Assert.AreEqual(result, category);
        }