public void GetIsNotOk() { Guid guid = Guid.NewGuid(); TypeEntity dummyType = new TypeEntity(); dummyType.Id = guid; var mock = new Mock <IRepository <TypeEntity, Topic> >(MockBehavior.Strict); mock.Setup(m => m.Exist(dummyType)).Returns(true); mock.Setup(m => m.Get(guid)).Throws(new ExceptionController()); var controller = new TypeLogic(mock.Object); Assert.ThrowsException <ExceptionController>(() => controller.Get(guid)); mock.VerifyAll(); }
public void GetIsOk() { Guid guid = Guid.NewGuid(); TypeEntity type = new TypeEntity() { Id = guid, Name = "Just Testing", TopicId = Guid.NewGuid() }; TypeEntity dummyType = new TypeEntity(); dummyType.Id = guid; var mock = new Mock <IRepository <TypeEntity, Topic> >(MockBehavior.Strict); mock.Setup(m => m.Exist(dummyType)).Returns(true); mock.Setup(m => m.Get(guid)).Returns(type); var controller = new TypeLogic(mock.Object); TypeEntity result = controller.Get(guid); Assert.AreEqual(type, result); }