public void AddTable_ExceptionFromDataAccess() { var mock = new Mock <IManagerDataAccess>(); mock.Setup(m => m.AddTable(It.IsAny <int>(), It.IsAny <string>())).Throws(new Exception()); //Arrange Bar Data Model var BarDataModel = new BarDataModel(mock.Object); //Act var result = BarDataModel.AddTable(1, "Po lewej"); //Assert Assert.IsNull(result); }
public void AddTable_FailedAddinToDataBase() { //Arrange Table Table table = null; var mock = new Mock <IManagerDataAccess>(); mock.Setup(m => m.AddTable(It.IsAny <int>(), It.IsAny <string>())).Returns(table); //Arrange Bar Data Model var BarDataModel = new BarDataModel(mock.Object); //Act var result = BarDataModel.AddTable(1, "Po lewej"); //Assert Assert.IsNull(result); }
public void AddTable_ValidExample() { //Arrange Table var table = new MoqTable(1, 1, "Po lewej"); var mock = new Mock <IManagerDataAccess>(); mock.Setup(m => m.AddTable(It.IsAny <int>(), It.IsAny <string>())).Returns(table); //Arrange Bar Data Model var BarDataModel = new BarDataModel(mock.Object); //Act var result = BarDataModel.AddTable(table.Number, table.Description); //Assert Assert.AreEqual(result, table); }
public void AddTable_ValidExample() { //Arrange Table var table = new MoqTable(1, 1, "Po lewej"); var mock = new Mock<IManagerDataAccess>(); mock.Setup(m => m.AddTable(It.IsAny<int>(), It.IsAny<string>())).Returns(table); //Arrange Bar Data Model var BarDataModel = new BarDataModel(mock.Object); //Act var result = BarDataModel.AddTable(table.Number, table.Description); //Assert Assert.AreEqual(result, table); }
public void AddTable_FailedAddinToDataBase() { //Arrange Table Table table = null; var mock = new Mock<IManagerDataAccess>(); mock.Setup(m => m.AddTable(It.IsAny<int>(), It.IsAny<string>())).Returns(table); //Arrange Bar Data Model var BarDataModel = new BarDataModel(mock.Object); //Act var result = BarDataModel.AddTable(1, "Po lewej"); //Assert Assert.IsNull(result); }
public void AddTable_ExceptionFromDataAccess() { var mock = new Mock<IManagerDataAccess>(); mock.Setup(m => m.AddTable(It.IsAny<int>(), It.IsAny<string>())).Throws(new Exception()); //Arrange Bar Data Model var BarDataModel = new BarDataModel(mock.Object); //Act var result = BarDataModel.AddTable(1, "Po lewej"); //Assert Assert.IsNull(result); }