public void CanDeleteUpdateTagType() { Mock <ITagTypeRepository> mock = new Mock <ITagTypeRepository>(); TagTypeController controller = new TagTypeController(mock.Object); controller.Delete(1); }
public void CanUpdateTagType() { Mock <ITagTypeRepository> mock = new Mock <ITagTypeRepository>(); TagTypeController controller = new TagTypeController(mock.Object); controller.Put(new TagType { Id = 1, Description = "abc" }); }
public void CanGetTagType() { TagType expected = new TagType { Id = 1, Description = "abc" }; Mock <ITagTypeRepository> mock = new Mock <ITagTypeRepository>(); mock.Setup(f => f.GetById(It.IsAny <int>())) .Returns(expected); TagTypeController controller = new TagTypeController(mock.Object); Assert.AreEqual(expected, controller.Get(1)); }
public void CanFailGetTagType() { TagType expected = new TagType { Id = 1, Description = "abc" }; Mock <ITagTypeRepository> mock = new Mock <ITagTypeRepository>(); mock.Setup(f => f.GetById(1)) .Returns(expected); TagTypeController controller = new TagTypeController(mock.Object); TagType tagType = controller.Get(2); Assert.AreNotEqual(expected, tagType); }
public void CanGetAllTagTypes() { TagType[] expected = { new TagType { Id = 1, Description = "abc" }, new TagType { Id = 2, Description = "def" } }; Mock <ITagTypeRepository> mock = new Mock <ITagTypeRepository>(); mock.Setup(f => f.GetAll()) .Returns(expected); TagTypeController controller = new TagTypeController(mock.Object); TagType[] tagTypes = controller.Get().ToArray(); Assert.AreEqual(expected, tagTypes); }