示例#1
0
        public void ShouldGetWebPartByField()
        {
            // Setup web part
            var webPartMock = new Mock <IWebPart>();
            var webPartObj  = webPartMock.Object;

            // Setup web part field
            var webPartFieldMock = new Mock <IWebPartField>();

            webPartFieldMock
            .Setup(x => x.WebPart)
            .Returns(webPartObj);

            // Setup business layer
            var businessLayer = new GetCMSWebPartBusiness
            {
                WriteDebug   = Assert.NotNull,
                WriteVerbose = Assert.NotNull,
            };
            var result = businessLayer.GetWebPart(webPartFieldMock.Object);

            result
            .Should()
            .NotBeNull();

            result
            .Should().BeEquivalentTo(webPartObj);
        }
示例#2
0
        public void ShouldGetWebPartFromNoPath()
        {
            // Setup web part category
            var webPartCategoryMock = new Mock <IWebPartCategory>();

            webPartCategoryMock
            .Setup(x => x.CategoryID)
            .Returns(15);
            webPartCategoryMock
            .Setup(x => x.CategoryPath)
            .Returns("/");
            var webPartCategoryObj = webPartCategoryMock.Object;

            // Setup web part
            var webPartMock = new Mock <IWebPart>();

            webPartMock
            .Setup(x => x.WebPartCategoryID)
            .Returns(15);
            webPartMock
            .Setup(x => x.WebPartName)
            .Returns("WebPart");
            var webPartObj = webPartMock.Object;

            // Setup web part service mock
            var webPartServiceMock = new Mock <IWebPartService>();

            webPartServiceMock
            .Setup(x => x.WebPartCategories)
            .Returns(new IWebPartCategory[]
            {
                webPartCategoryObj,
            });
            webPartServiceMock
            .Setup(x => x.GetWebParts(webPartCategoryObj))
            .Returns(new IWebPart[] { webPartObj });

            // Setup business layer
            var businessLayer = new GetCMSWebPartBusiness
            {
                WebPartService = webPartServiceMock.Object,
                WriteDebug     = Assert.NotNull,
                WriteVerbose   = Assert.NotNull,
            };

            var result = businessLayer.GetWebPart("/WebPart");

            result
            .Should()
            .NotBeNull();

            result
            .Should().BeEquivalentTo(webPartObj);
        }