public void EditWaiter_ExceptionFromDataAccess() { //Arrange Changes var newFirstName = "Tony"; var newLastName = "Lombster"; var newLogin = "******"; var newPassword = "******"; //Arrange waiter var oldFirstName = "Keny"; var oldLastName = "Wall"; var oldLogin = "******"; var oldPassword = "******"; var waiter = new MoqWaiter(1, oldFirstName, oldLastName, oldLogin, oldPassword); var mock = new Mock <IManagerDataAccess>(); mock.Setup(m => m.EditWaiter(It.IsAny <WaiterContext>())).Throws(new Exception()); //Arrange Bar Data Model var BarDataModel = new BarDataModel(mock.Object); //Act var result = BarDataModel.EditWaiter(waiter, newLogin, newFirstName, newLastName, newPassword); //Assert Assert.IsFalse(result); Assert.AreEqual(waiter.FirstName, oldFirstName); Assert.AreEqual(waiter.LastName, oldLastName); Assert.AreEqual(waiter.Login, oldLogin); Assert.AreEqual(waiter.Password, oldPassword); }
public void EditWaiter_ValidExample() { //Arrange Changes var newFirstName = "Tony"; var newLastName = "Lombster"; var newLogin = "******"; var newPassword = "******"; //Arrange waiter var waiter = new MoqWaiter(1, "Keny", "Wall", "wally", "qwerty"); var mock = new Mock <IManagerDataAccess>(); mock.Setup(m => m.EditWaiter(It.IsAny <WaiterContext>())).Returns(true); //Arrange Bar Data Model var BarDataModel = new BarDataModel(mock.Object); //Act var result = BarDataModel.EditWaiter(waiter, newLogin, newFirstName, newLastName, newPassword); //Assert Assert.IsTrue(result); Assert.AreEqual(waiter.FirstName, newFirstName); Assert.AreEqual(waiter.LastName, newLastName); Assert.AreEqual(waiter.Login, newLogin); Assert.AreEqual(waiter.Password, newPassword); }
public void GetAllWaiters_ValidExample() { //Arrange List of Waiters var Waiters = new List <MoqWaiter>(); var f1 = new MoqWaiter(1, "Tom", "Dickens", "tDick", "lala"); var f2 = new MoqWaiter(2, "Wiliam", "Whatever", "Rockman", "lolo"); var f3 = new MoqWaiter(3, "Ken", "Hilary", "hili", "lipo"); Waiters.Add(f1); Waiters.Add(f2); Waiters.Add(f3); var mock = new Mock <IManagerDataAccess>(); mock.Setup(m => m.GetWaiters()).Returns(Waiters); //Arrange Bar Data Model var BarDataModel = new BarDataModel(mock.Object); //Act var ReturnedWaiters = BarDataModel.GetAllWaiters(); var ReturnedWaitersCast = ReturnedWaiters.Cast <MoqWaiter>().ToList(); //Asserts Assert.IsNotNull(ReturnedWaiters); Assert.AreEqual(ReturnedWaitersCast[0].Id, f1.Id); Assert.AreEqual(ReturnedWaitersCast[0].FirstName, f1.FirstName); Assert.AreEqual(ReturnedWaitersCast[0].LastName, f1.LastName); Assert.AreEqual(ReturnedWaitersCast[0].Login, f1.Login); Assert.AreEqual(ReturnedWaitersCast[0].Password, f1.Password); Assert.AreEqual(ReturnedWaitersCast[1].Id, f2.Id); Assert.AreEqual(ReturnedWaitersCast[1].FirstName, f2.FirstName); Assert.AreEqual(ReturnedWaitersCast[1].LastName, f2.LastName); Assert.AreEqual(ReturnedWaitersCast[1].Login, f2.Login); Assert.AreEqual(ReturnedWaitersCast[1].Password, f2.Password); Assert.AreEqual(ReturnedWaitersCast[2].Id, f3.Id); Assert.AreEqual(ReturnedWaitersCast[2].FirstName, f3.FirstName); Assert.AreEqual(ReturnedWaitersCast[2].LastName, f3.LastName); Assert.AreEqual(ReturnedWaitersCast[2].Login, f3.Login); Assert.AreEqual(ReturnedWaitersCast[2].Password, f3.Password); }
public void AddWaiter_ValidExample() { //Arrange Waiter var waiter = new MoqWaiter(1, "Tom", "Dickens", "tDick", "lala"); var mock = new Mock <IManagerDataAccess>(); mock.Setup(m => m.AddWaiter(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).Returns(waiter); //Arrange Bar Data Model var BarDataModel = new BarDataModel(mock.Object); //Act var result = BarDataModel.AddWaiter(waiter.FirstName, waiter.LastName, waiter.Login, waiter.Password); //Assert Assert.AreEqual(result, waiter); }
public void GetAllWaiters_ValidExample() { //Arrange List of Waiters var Waiters = new List<MoqWaiter>(); var f1 = new MoqWaiter(1, "Tom", "Dickens", "tDick", "lala"); var f2 = new MoqWaiter(2, "Wiliam", "Whatever", "Rockman", "lolo"); var f3 = new MoqWaiter(3, "Ken", "Hilary", "hili", "lipo"); Waiters.Add(f1); Waiters.Add(f2); Waiters.Add(f3); var mock = new Mock<IManagerDataAccess>(); mock.Setup(m => m.GetWaiters()).Returns(Waiters); //Arrange Bar Data Model var BarDataModel = new BarDataModel(mock.Object); //Act var ReturnedWaiters = BarDataModel.GetAllWaiters(); var ReturnedWaitersCast = ReturnedWaiters.Cast<MoqWaiter>().ToList(); //Asserts Assert.IsNotNull(ReturnedWaiters); Assert.AreEqual(ReturnedWaitersCast[0].Id, f1.Id); Assert.AreEqual(ReturnedWaitersCast[0].FirstName, f1.FirstName); Assert.AreEqual(ReturnedWaitersCast[0].LastName, f1.LastName); Assert.AreEqual(ReturnedWaitersCast[0].Login, f1.Login); Assert.AreEqual(ReturnedWaitersCast[0].Password, f1.Password); Assert.AreEqual(ReturnedWaitersCast[1].Id, f2.Id); Assert.AreEqual(ReturnedWaitersCast[1].FirstName, f2.FirstName); Assert.AreEqual(ReturnedWaitersCast[1].LastName, f2.LastName); Assert.AreEqual(ReturnedWaitersCast[1].Login, f2.Login); Assert.AreEqual(ReturnedWaitersCast[1].Password, f2.Password); Assert.AreEqual(ReturnedWaitersCast[2].Id, f3.Id); Assert.AreEqual(ReturnedWaitersCast[2].FirstName, f3.FirstName); Assert.AreEqual(ReturnedWaitersCast[2].LastName, f3.LastName); Assert.AreEqual(ReturnedWaitersCast[2].Login, f3.Login); Assert.AreEqual(ReturnedWaitersCast[2].Password, f3.Password); }
public void EditWaiter_ValidExample() { //Arrange Changes var newFirstName = "Tony"; var newLastName = "Lombster"; var newLogin = "******"; var newPassword = "******"; //Arrange waiter var waiter = new MoqWaiter(1, "Keny", "Wall" , "wally" , "qwerty"); var mock = new Mock<IManagerDataAccess>(); mock.Setup(m => m.EditWaiter(It.IsAny<WaiterContext>())).Returns(true); //Arrange Bar Data Model var BarDataModel = new BarDataModel(mock.Object); //Act var result = BarDataModel.EditWaiter(waiter,newLogin, newFirstName, newLastName, newPassword); //Assert Assert.IsTrue(result); Assert.AreEqual(waiter.FirstName, newFirstName); Assert.AreEqual(waiter.LastName, newLastName); Assert.AreEqual(waiter.Login, newLogin); Assert.AreEqual(waiter.Password, newPassword); }
public void EditWaiter_ExceptionFromDataAccess() { //Arrange Changes var newFirstName = "Tony"; var newLastName = "Lombster"; var newLogin = "******"; var newPassword = "******"; //Arrange waiter var oldFirstName = "Keny"; var oldLastName = "Wall"; var oldLogin = "******"; var oldPassword = "******"; var waiter = new MoqWaiter(1, oldFirstName, oldLastName, oldLogin, oldPassword); var mock = new Mock<IManagerDataAccess>(); mock.Setup(m => m.EditWaiter(It.IsAny<WaiterContext>())).Throws(new Exception()); //Arrange Bar Data Model var BarDataModel = new BarDataModel(mock.Object); //Act var result = BarDataModel.EditWaiter(waiter, newLogin, newFirstName, newLastName, newPassword); //Assert Assert.IsFalse(result); Assert.AreEqual(waiter.FirstName, oldFirstName); Assert.AreEqual(waiter.LastName, oldLastName); Assert.AreEqual(waiter.Login, oldLogin); Assert.AreEqual(waiter.Password, oldPassword); }
public void AddWaiter_ValidExample() { //Arrange Waiter var waiter = new MoqWaiter(1, "Tom", "Dickens", "tDick", "lala"); var mock = new Mock<IManagerDataAccess>(); mock.Setup(m => m.AddWaiter(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>())).Returns(waiter); //Arrange Bar Data Model var BarDataModel = new BarDataModel(mock.Object); //Act var result = BarDataModel.AddWaiter(waiter.FirstName, waiter.LastName, waiter.Login, waiter.Password); //Assert Assert.AreEqual(result, waiter); }