예제 #1
0
        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_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")));
        }
예제 #3
0
        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")));
        }
예제 #4
0
        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")));
        }
예제 #5
0
        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();
        }
예제 #6
0
        public void When_Tag_Mvc_Is_Assigned_Then_TagsList_Contains_Mvc()
        {
            Mock<ITagTarget> targetMock = CreateStandardTargetMock();

            var storageMock = new Mock<ITagStorageAdapter>();

            storageMock
                .Setup(x => x.LoadTagMappingsFor(It.IsAny<TagTargetReference>()))
                .Returns(new List<TagMapping>());

            storageMock.Setup(x => x.SaveTagMapping(It.IsAny<TagMapping>())).Verifiable();

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

            tagger.AddTag(new Tag("Mvc"));

            Assert.That(tagger.Tags, Contains.Item(new Tag("Mvc")));
        }
예제 #7
0
        public void When_Taggable_Is_Created_Then_All_Tags_Are_Loaded_From_Storage()
        {
            Mock<ITagTarget> targetMock = CreateStandardTargetMock();

            var storageMock = new Mock<ITagStorageAdapter>();
            storageMock.Setup(x => x.LoadTagMappingsFor(It.IsAny<TagTargetReference>())).Verifiable();

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