コード例 #1
0
ファイル: TaggerTests.cs プロジェクト: ilkerde/dc-tagger
        public void When_Querying_For_Mvc_And_Tag_Mvc_Is_Not_Assigned_Then_Returns_False()
        {
            var storageMock = new Mock<ITagStorageAdapter>();
            storageMock.Setup(x => x.LoadTagMappingsFor(It.IsAny<TagTargetReference>()));

            storageMock.WithTagInStorage("Any");

            var targetMock = CreateStandardTargetMock();

            Tagger tagger = new Tagger(targetMock.Object, storageMock.Object);
            Assert.False(tagger.ContainsTag(new Tag("Mvc")));
        }
コード例 #2
0
        public void When_One_Target_Exists_For_Mvc_Then_Returns_TargetReference()
        {
            var storageMock = new Mock<ITagStorageAdapter>();
            var tagRef = storageMock.WithTagInStorage("Mvc");

            var tagFinder = new TagTargetReferenceFinder(storageMock.Object);
            List<TagTargetReference> refs = tagFinder.FindByTag(new Tag("Mvc"));

            Assert.That(refs, Contains.Item(new TagTargetReference()
                                            {
                                                FullTypeName = tagRef.FullTypeName,
                                                Id = tagRef.Id
                                            }));
        }
コード例 #3
0
ファイル: TaggerTests.cs プロジェクト: ilkerde/dc-tagger
        public void When_Taggable_Is_Created_Then_All_Loaded_Tags_Are_In_TagsList()
        {
            Mock<ITagTarget> targetMock = CreateStandardTargetMock();

            var storageMock = new Mock<ITagStorageAdapter>();
            storageMock.WithTagInStorage("JS");

            var taggable = new Tagger(targetMock.Object, storageMock.Object);

            Assert.That(taggable.Tags, Contains.Item(new Tag("JS")));
        }
コード例 #4
0
ファイル: TaggerTests.cs プロジェクト: ilkerde/dc-tagger
        public void When_Tag_Mvc_Is_To_Be_Removed_And_Has_Not_Been_Already_Assigned_Then_Storage_Is_Not_Called()
        {
            Mock<ITagTarget> targetMock = CreateStandardTargetMock();

            var storageMock = new Mock<ITagStorageAdapter>();

            storageMock.WithTagInStorage("Nope");
            storageMock.Setup(x => x.DeleteTagMapping(It.IsAny<TagMapping>())).Throws<Exception>();

            Tagger tagger = new Tagger(targetMock.Object, storageMock.Object);

            Assert.DoesNotThrow(() => tagger.RemoveTag(new Tag("Mvc")));
        }
コード例 #5
0
ファイル: TaggerTests.cs プロジェクト: ilkerde/dc-tagger
        public void When_Tag_Mvc_Is_Removed_Then_TagsList_No_Longer_Contains_Mvc()
        {
            var storageMock = new Mock<ITagStorageAdapter>();
            storageMock.Setup(x => x.DeleteTagMapping(It.IsAny<TagMapping>())).Verifiable();
            storageMock.Setup(x => x.LoadTagMappingsFor(It.IsAny<TagTargetReference>()));

            var tagRef = storageMock.WithTagInStorage("Mvc");

            var targetMock = CreateStandardTargetMock(tagRef.Id);

            Tagger tagger = new Tagger(targetMock.Object, storageMock.Object);
            tagger.RemoveTag(new Tag("Mvc"));

            Assert.False(tagger.Tags.Contains(new Tag("Mvc")));
        }
コード例 #6
0
ファイル: TaggerTests.cs プロジェクト: ilkerde/dc-tagger
        public void When_Tag_Mvc_Is_Removed_Then_Storage_Is_Called()
        {
            var storageMock = new Mock<ITagStorageAdapter>();
            storageMock.Setup(x => x.DeleteTagMapping(It.IsAny<TagMapping>())).Verifiable();

            var tagRef = storageMock.WithTagInStorage("Mvc");
            var targetMock = CreateStandardTargetMock(tagRef.Id);

            Tagger tagger = new Tagger(targetMock.Object, storageMock.Object);
            tagger.RemoveTag(new Tag("Mvc"));
            storageMock.Verify();
        }