public void CanGetTagTypeNoReferences()
        {
            TagTypeRepository repo = new TagTypeRepository();
            TagType tagType = new TagType
            {
                Description = "tag type"
            };
            repo.Add(tagType);

            Assert.AreEqual(tagType, repo.GetById(tagType.Id));
        }
        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()
        {
            TagTypeRepository repo = new TagTypeRepository();
            TagType tagType1 = new TagType { Description = "tt1" };
            TagType tagType2 = new TagType { Description = "tt2" };
            repo.Add(tagType1);
            repo.Add(tagType2);

            TagType[] tagTypes = repo.GetAll().ToArray();

            Assert.True(tagTypes.Contains(tagType1));
            Assert.True(tagTypes.Contains(tagType2));
        }
        public void CanDeleteTagType()
        {
            TagTypeRepository repo = new TagTypeRepository();
            TagType tagType = new TagType
            {
                Description = "tag type"
            };
            repo.Add(tagType);

            repo.Delete(tagType.Id);

            Assert.Null(repo.GetById(tagType.Id));
        }
        public void CanUpdateTag()
        {
            TagTypeRepository repoTagtypes = new TagTypeRepository();
            TagType tagTypeOriginal = new TagType
            {
                Description = "tag type original"
            };
            TagType tagTypeUpdated = new TagType
            {
                Description = "tag type updated"
            };
            repoTagtypes.Add(tagTypeOriginal);
            repoTagtypes.Add(tagTypeUpdated);

            TagRepository repoTags = new TagRepository();
            Tag tag = new Tag
            {
                Description = "tag",
                TagType = tagTypeOriginal
            };
            repoTags.Add(tag);

            tag.Description = "tag updated";
            tag.TagType = tagTypeUpdated;
            repoTags.Update(tag);

            Assert.AreEqual(tag, repoTags.GetById(tag.Id));
        }
 public void Put(TagType tagType)
 {
     _tagTypeRepository.Update(tagType);
 }
 public void Post(TagType tagType)
 {
     _tagTypeRepository.Add(tagType);
 }
 public void Update(TagType tagType)
 {
     SqliteHelper.Update(UpdateQuery, UpdateCommandBinder, tagType);
 }
Esempio n. 10
0
 public void Add(TagType tagType)
 {
     SqliteHelper.Insert(AddQuery, AddCommandBinder, tagType);
 }
        public void CanUpdateTagType()
        {
            TagTypeRepository repo = new TagTypeRepository();
            TagType tagType = new TagType
            {
                Description = "tag type"
            };
            repo.Add(tagType);

            const string newDescription = "newDescription";
            tagType.Description = newDescription;
            repo.Update(tagType);

            Assert.AreEqual(newDescription, repo.GetById(tagType.Id).Description);
        }