public void AddMenuItem_ExceptionFromDataAccess() { //Arrange Adding Menu item Category var category = new MoqMenuItemCategory(1, "Żarcie", "Różne"); //Arrange Exception var mock = new Mock <IManagerDataAccess>(); mock.Setup(m => m.AddMenuItem(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <Money>())).Throws(new Exception()); //Arrange Bar Data Model var BarDataModel = new BarDataModel(mock.Object); //Act var result = BarDataModel.AddMenuItem("Schabowy", category, 20, "Bardzo dobry schabowy"); //Assert Assert.IsNull(result); }
public void AddMenuItem_FailedAddinToDataBase() { //Arrange Adding Menu item Category var category = new MoqMenuItemCategory(1, "Żarcie", "Różne"); //Arrange ManagerDataAccess MenuItem menuItem = null; var mock = new Mock <IManagerDataAccess>(); mock.Setup(m => m.AddMenuItem(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <Money>())).Returns(menuItem); //Arrange Bar Data Model var BarDataModel = new BarDataModel(mock.Object); //Act var result = BarDataModel.AddMenuItem("Schabowy", category, 20, "Bardzo dobry schabowy"); //Assert Assert.IsNull(result); }
public void AddMenuItem_ValidExample() { //Arrange Adding Menu item Category var category = new MoqMenuItemCategory(1, "Żarcie", "Różne"); //Arrange Menu Item var menuItem = new MoqMenuItem(1, "Schabowy", "Bardzo dobry schabowy", category, new Money() { Amount = 20, Currency = "PLN" }); var mock = new Mock <IManagerDataAccess>(); mock.Setup(m => m.AddMenuItem(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <Money>())).Returns(menuItem); //Arrange Bar Data Model var BarDataModel = new BarDataModel(mock.Object); //Act var result = BarDataModel.AddMenuItem("Schabowy", category, 20, "Bardzo dobry schabowy"); //Assert Assert.AreEqual(result, menuItem); }
public void AddMenuItem_FailedAddinToDataBase() { //Arrange Adding Menu item Category var category = new MoqMenuItemCategory(1, "Żarcie", "Różne"); //Arrange ManagerDataAccess MenuItem menuItem = null; var mock = new Mock<IManagerDataAccess>(); mock.Setup(m => m.AddMenuItem(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>(), It.IsAny<Money>())).Returns(menuItem); //Arrange Bar Data Model var BarDataModel = new BarDataModel(mock.Object); //Act var result = BarDataModel.AddMenuItem("Schabowy", category, 20, "Bardzo dobry schabowy"); //Assert Assert.IsNull(result); }
public void AddMenuItem_ExceptionFromDataAccess() { //Arrange Adding Menu item Category var category = new MoqMenuItemCategory(1, "Żarcie", "Różne"); //Arrange Exception var mock = new Mock<IManagerDataAccess>(); mock.Setup(m => m.AddMenuItem(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>(), It.IsAny<Money>())).Throws(new Exception()); //Arrange Bar Data Model var BarDataModel = new BarDataModel(mock.Object); //Act var result = BarDataModel.AddMenuItem("Schabowy", category, 20, "Bardzo dobry schabowy"); //Assert Assert.IsNull(result); }
public void AddMenuItem_ValidExample() { //Arrange Adding Menu item Category var category = new MoqMenuItemCategory(1, "Żarcie", "Różne"); //Arrange Menu Item var menuItem = new MoqMenuItem(1, "Schabowy", "Bardzo dobry schabowy", category, new Money() { Amount = 20, Currency = "PLN" }); var mock = new Mock<IManagerDataAccess>(); mock.Setup(m => m.AddMenuItem(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>(), It.IsAny<Money>())).Returns(menuItem); //Arrange Bar Data Model var BarDataModel = new BarDataModel(mock.Object); //Act var result = BarDataModel.AddMenuItem("Schabowy", category, 20, "Bardzo dobry schabowy"); //Assert Assert.AreEqual(result, menuItem); }