public void TestCostumerRemove() { var costumerManagerMock = new Mock <ICostumerManager>(); var bookManagerMock = new Mock <IBookManager>(); costumerManagerMock.Setup(m => m.GetCostumerByCostumerName(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <bool>(), It.IsAny <int>(), It.IsAny <string>())) .Returns(new Costumer { CostumerID = 1, IsInDebt = false, HasBorrowedBook = false }); costumerManagerMock.Setup(m => m.RemoveCostumer(It.IsAny <int>())); var costumerAPI = new CostumerAPI(costumerManagerMock.Object, bookManagerMock.Object); var successfull = costumerAPI.RemoveCostumer("Jan", "1990-01-01", false, false, 0, "Fågelvägen 1"); Assert.AreEqual(RemoveCostumerCodes.Ok, successfull); costumerManagerMock.Verify( m => m.RemoveCostumer(It.IsAny <int>()), Times.Once()); }
public void TestRemoveNoneExistingCostumer() { var costumerManagerMock = new Mock <ICostumerManager>(); var bookManagerMock = new Mock <IBookManager>(); costumerManagerMock.Setup(m => m.GetCostumerByCostumerName(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <bool>(), It.IsAny <int>(), It.IsAny <string>())) .Returns((Costumer)null); costumerManagerMock.Setup(m => m.RemoveCostumer(It.IsAny <int>())); var costumerAPI = new CostumerAPI(costumerManagerMock.Object, bookManagerMock.Object); var successfull = costumerAPI.RemoveCostumer("Jan", "1990-01-01", false, false, 0, "Fågelvägen 1"); Assert.AreEqual(RemoveCostumerCodes.NoSuchCostumer, successfull); costumerManagerMock.Verify( m => m.RemoveCostumer(It.IsAny <int>()), Times.Never()); }