public void GetAllNoElements() { var mock = new Mock <IRequestRepository <Request, TypeEntity> >(MockBehavior.Strict); mock.Setup(m => m.GetAll()).Throws(new ArgumentException()); var controller = new RequestLogic(mock.Object); Assert.ThrowsException <ArgumentException>(() => controller.GetAll()); mock.VerifyAll(); }
public void GetAllIsOk() { Request firstRequestExpected = new Request() { Id = Guid.NewGuid(), RequestorsName = "Just Testing", RequestorsEmail = "*****@*****.**", RequestorsPhone = "489498948894", TypeId = Guid.NewGuid(), State = "State", Description = "description" }; Request secondRequestExpected = new Request() { Id = Guid.NewGuid(), RequestorsName = "Second Testing", RequestorsEmail = "*****@*****.**", RequestorsPhone = "5445864565", TypeId = Guid.NewGuid(), State = "State", Description = "description" }; IEnumerable <Request> requests = new List <Request>() { firstRequestExpected, secondRequestExpected }; var mock = new Mock <IRequestRepository <Request, TypeEntity> >(MockBehavior.Strict); mock.Setup(m => m.GetAll()).Returns(requests); var controller = new RequestLogic(mock.Object); IEnumerable <Request> resultList = controller.GetAll(); Assert.AreEqual(requests, resultList); }