public void ShouldGetWebPartFieldsByMatchString()
        {
            // Setup the web part fields
            var webPartFieldMock1 = new Mock <IWebPartField>();

            webPartFieldMock1
            .Setup(x => x.Name)
            .Returns("Field1");
            var webPartFieldMock2 = new Mock <IWebPartField>();

            webPartFieldMock2
            .Setup(x => x.Name)
            .Returns("Other");

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

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

            webPartServiceMock
            .Setup(x => x.GetWebPartFields(webPartMock.Object))
            .Returns(new IWebPartField[]
            {
                webPartFieldMock1.Object,
                webPartFieldMock2.Object,
            });

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

            // Get the results
            // Should return results
            var results = businessLayer.GetWebPartFields("*field*", false, webPartMock.Object);

            results
            .Should()
            .NotBeNullOrEmpty();
            results
            .Should()
            .Contain(webPartFieldMock1.Object);
            results
            .Should()
            .NotContain(webPartFieldMock2.Object);
            results
            .Should()
            .NotContainNulls();

            // Get the results
            // Should not return results
            results = businessLayer.GetWebPartFields("notfields", false, webPartMock.Object);
            results
            .Should()
            .BeEmpty();
        }
        public void ShouldGetWebPartFields()
        {
            // Setup mocks
            var webPartMock        = new Mock <IWebPart>();
            var webPartServiceMock = new Mock <IWebPartService>();

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

            businessLayer.GetWebPartFields(webPartMock.Object);

            // Verify the execution
            webPartServiceMock.Verify(x => x.GetWebPartFields(webPartMock.Object));
        }