public void GetIsOk() { Guid guid = Guid.NewGuid(); Request request = new Request() { Id = guid, RequestorsName = "Just Testing", RequestorsEmail = "*****@*****.**", RequestorsPhone = "489498948894", TypeId = Guid.NewGuid(), State = "State", Description = "description" }; Request dummyRequest = new Request(); dummyRequest.Id = guid; var mock = new Mock <IRequestRepository <Request, TypeEntity> >(MockBehavior.Strict); mock.Setup(m => m.Exist(dummyRequest)).Returns(true); mock.Setup(m => m.Get(guid)).Returns(request); var controller = new RequestLogic(mock.Object); Request result = controller.Get(guid); Assert.AreEqual(request, result); }
public void GetIsNotOk() { Guid guid = Guid.NewGuid(); Request dummyRequest = new Request(); dummyRequest.Id = guid; var mock = new Mock <IRequestRepository <Request, TypeEntity> >(MockBehavior.Strict); mock.Setup(m => m.Exist(dummyRequest)).Returns(true); mock.Setup(m => m.Get(guid)).Throws(new ArgumentException()); var controller = new RequestLogic(mock.Object); Assert.ThrowsException <ArgumentException>(() => controller.Get(guid)); mock.VerifyAll(); }