Beispiel #1
0
        public void ShouldGetWebPartsByMatchStringWithoutRegex()
        {
            // Setup web part
            var webPartMock = new Mock <IWebPart>();

            webPartMock
            .Setup(x => x.WebPartDisplayName)
            .Returns("aDisplaya");
            webPartMock
            .Setup(x => x.WebPartName)
            .Returns("dTests");
            var webPartObj = webPartMock.Object;

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

            webPartServiceMock
            .Setup(x => x.WebParts)
            .Returns(new IWebPart[] { webPartObj });

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

            // Test Display Name
            var results = businessLayer.GetWebParts("*Display*", false);

            results
            .Should()
            .NotBeNullOrEmpty();
            results
            .Single()
            .Should().BeEquivalentTo(webPartObj);

            results = businessLayer.GetWebParts("Display*", false);
            results
            .Should()
            .BeEmpty();

            // Test Name
            results = businessLayer.GetWebParts("*test*", false);
            results
            .Should()
            .NotBeNullOrEmpty();
            results
            .Single()
            .Should().BeEquivalentTo(webPartObj);

            results = businessLayer.GetWebParts("test*", false);
            results
            .Should()
            .BeEmpty();
        }
Beispiel #2
0
        public void ShouldGetAllWebParts()
        {
            // Setup web part
            var webPartMock = new Mock <IWebPart>();
            var webPartObj  = webPartMock.Object;

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

            webPartServiceMock
            .Setup(x => x.WebParts)
            .Returns(new IWebPart[] { webPartObj });

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

            result
            .Should()
            .NotBeNullOrEmpty();

            result
            .Single()
            .Should()
            .NotBeNull();

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