Exemplo n.º 1
0
        public void GetCmsMediaLibraryTest__MatchString_ExactFalse()
        {
            var libraryServiceMock = new Mock <IMediaLibraryService>();

            var libraries    = new List <IMediaLibrary>();
            var libraryMock1 = new Mock <IMediaLibrary>();

            libraryMock1.SetupGet(x => x.LibraryName).Returns("MyLibrary1");
            libraryMock1.SetupGet(x => x.LibraryDisplayName).Returns("My Library1");
            libraryMock1.SetupGet(x => x.LibraryFolder).Returns("images1");
            libraryMock1.SetupGet(x => x.LibrarySiteID).Returns(1);
            libraries.Add(libraryMock1.Object);

            var libraryMock2 = new Mock <IMediaLibrary>();

            libraryMock2.SetupGet(x => x.LibraryName).Returns("MyLibrary2");
            libraryMock2.SetupGet(x => x.LibraryDisplayName).Returns("My Library2");
            libraryMock2.SetupGet(x => x.LibraryFolder).Returns("images2");
            libraryMock2.SetupGet(x => x.LibrarySiteID).Returns(1);
            libraries.Add(libraryMock2.Object);

            libraryServiceMock.SetupGet(x => x.MediaLibraries).Returns(libraries);

            var businessLayer = new GetCmsMediaLibraryBusiness
            {
                WriteDebug   = Assert.NotNull,
                WriteVerbose = Assert.NotNull,

                MediaLibraryService = libraryServiceMock.Object,
            };

            businessLayer.GetMediaLibraries(1, "MyLibrary", false).Should().NotBeNullOrEmpty().And.HaveCount(2);
            businessLayer.GetMediaLibraries(1, "1", false).Should().NotBeNullOrEmpty().And.HaveCount(1);
            libraryServiceMock.Verify(x => x.MediaLibraries);
        }
Exemplo n.º 2
0
        public void RemoveCmsMediaLibraryTest_Object()
        {
            var libraryServiceMock = new Mock <IMediaLibraryService>();

            var libraries    = new List <IMediaLibrary>();
            var libraryMock1 = new Mock <IMediaLibrary>();

            libraryMock1.SetupGet(x => x.LibraryName).Returns("MyLibrary1");
            libraryMock1.SetupGet(x => x.LibraryDisplayName).Returns("My Library1");
            libraryMock1.SetupGet(x => x.LibraryFolder).Returns("images1");
            libraryMock1.SetupGet(x => x.LibrarySiteID).Returns(1);
            libraries.Add(libraryMock1.Object);

            var libraryMock2 = new Mock <IMediaLibrary>();

            libraryMock2.SetupGet(x => x.LibraryName).Returns("MyLibrary2");
            libraryMock2.SetupGet(x => x.LibraryDisplayName).Returns("My Library2");
            libraryMock2.SetupGet(x => x.LibraryFolder).Returns("images2");
            libraryMock2.SetupGet(x => x.LibrarySiteID).Returns(1);
            libraries.Add(libraryMock2.Object);

            libraryServiceMock.SetupGet(x => x.MediaLibraries).Returns(libraries);

            var getBusinessLayer = new GetCmsMediaLibraryBusiness
            {
                WriteDebug   = Assert.NotNull,
                WriteVerbose = Assert.NotNull,

                MediaLibraryService = libraryServiceMock.Object,
            };

            var businessLayer = new RemoveCmsMediaLibraryBusiness
            {
                WriteDebug    = Assert.NotNull,
                WriteVerbose  = Assert.NotNull,
                ShouldProcess = (x, y) => true,

                MediaLibraryService        = libraryServiceMock.Object,
                GetCmsMediaLibraryBusiness = getBusinessLayer,
            };

            businessLayer.Remove(libraryMock1.Object);

            libraryServiceMock.Verify(x => x.DeleteMediaLibrary(libraryMock1.Object));

            businessLayer.Remove(libraryMock2.Object);

            libraryServiceMock.Verify(x => x.DeleteMediaLibrary(libraryMock2.Object));
        }
Exemplo n.º 3
0
        public void GetCmsMediaLibraryTest_NoParameters_None()
        {
            var libraryServiceMock = new Mock <IMediaLibraryService>();

            var businessLayer = new GetCmsMediaLibraryBusiness
            {
                WriteDebug   = Assert.NotNull,
                WriteVerbose = Assert.NotNull,

                MediaLibraryService = libraryServiceMock.Object,
            };

            businessLayer.GetMediaLibraries().Should().BeEmpty();

            libraryServiceMock.Verify(x => x.MediaLibraries);
        }
Exemplo n.º 4
0
        public void GetCmsMediaLibrary_IDs()
        {
            var libraryServiceMock = new Mock <IMediaLibraryService>();

            var libraries    = new List <IMediaLibrary>();
            var libraryMock1 = new Mock <IMediaLibrary>();

            libraryMock1.SetupGet(x => x.LibraryName).Returns("MyLibrary1");
            libraryMock1.SetupGet(x => x.LibraryDisplayName).Returns("My Library1");
            libraryMock1.SetupGet(x => x.LibraryFolder).Returns("images1");
            libraryMock1.SetupGet(x => x.LibrarySiteID).Returns(1);
            libraries.Add(libraryMock1.Object);

            var libraryMock2 = new Mock <IMediaLibrary>();

            libraryMock2.SetupGet(x => x.LibraryName).Returns("MyLibrary2");
            libraryMock2.SetupGet(x => x.LibraryDisplayName).Returns("My Library2");
            libraryMock2.SetupGet(x => x.LibraryFolder).Returns("images2");
            libraryMock2.SetupGet(x => x.LibrarySiteID).Returns(1);
            libraries.Add(libraryMock2.Object);

            libraryServiceMock.Setup(x => x.GetMediaLibrary(1)).Returns(libraryMock1.Object);
            libraryServiceMock.Setup(x => x.GetMediaLibrary(2)).Returns(libraryMock2.Object);

            var businessLayer = new GetCmsMediaLibraryBusiness
            {
                WriteDebug   = Assert.NotNull,
                WriteVerbose = Assert.NotNull,

                MediaLibraryService = libraryServiceMock.Object,
            };

            businessLayer.GetMediaLibraries(1).Should().NotBeNullOrEmpty().And.HaveCount(1);
            businessLayer.GetMediaLibraries(2).Should().NotBeNullOrEmpty().And.HaveCount(1);
            businessLayer.GetMediaLibraries(3).Should().BeEmpty();

            businessLayer.GetMediaLibraries(1, 2, 3).Should().NotBeNullOrEmpty().And.HaveCount(2);

            libraryServiceMock.Verify(x => x.GetMediaLibrary(1));
            libraryServiceMock.Verify(x => x.GetMediaLibrary(2));
            libraryServiceMock.Verify(x => x.GetMediaLibrary(3));
        }