Beispiel #1
0
        public void SetCmsMediaLibraryTest_SpecifiedProperties()
        {
            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);

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

                MediaLibraryService = libraryServiceMock.Object,
            };

            businessLayer.Set(1, "MyLibrary1", "My Modified Library1", "New Description", "images1");

            libraryServiceMock.Verify(x => x.UpdateMediaLibrary(
                                          It.Is <IMediaLibrary>(i => i.LibraryDisplayName != "My Library1" &&
                                                                i.LibraryDescription == "New Description"), false));

            libraryServiceMock.Verify(x => x.UpdateMediaLibrary(
                                          It.Is <IMediaLibrary>(i => i.LibraryDisplayName == "My Modified Library1" &&
                                                                i.LibraryDescription == "New Description"), false));
        }
Beispiel #2
0
        public void SetCmsMediaLibraryTest_SpecifiedObject()
        {
            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);

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

                MediaLibraryService = libraryServiceMock.Object,
            };

            businessLayer.Set(libraryMock1.Object);

            libraryServiceMock.Verify(x => x.UpdateMediaLibrary(libraryMock1.Object, true));

            businessLayer.Set(libraryMock2.Object);

            libraryServiceMock.Verify(x => x.UpdateMediaLibrary(libraryMock2.Object, true));
        }