public async Task WhenLinkTagHelperCalled_ThenCorrectClassCalled()
        {
            var tagHelper = Substitute.For <IMockViewComponentHelper>();

            var componentTag = new LinkTagHelper(tagHelper)
            {
                AdditionalClass = "AdditionalClass",
                Class           = "Class",
                Id           = "Id",
                LinkHref     = "LinkHref",
                LinkTabIndex = 1,
                LinkText     = "LinkText",
                LinkTitle    = "LinkTitle"
            };
            string additionalClass = componentTag.AdditionalClass;
            string id           = componentTag.Id;
            string linkHref     = componentTag.LinkHref;
            int    linkTabIndex = componentTag.LinkTabIndex;
            string linkText     = componentTag.LinkText;
            string linkTitle    = componentTag.LinkTitle;
            string classProp    = componentTag.Class;


            await ViewComponentTestHelper.CallTagHelper("Link", tagHelper, componentTag);
        }
        public async Task WhenBackLinkTagHelperCalled_ThenCorrectClassCalled()
        {
            var tagHelper = Substitute.For <IMockViewComponentHelper>();

            var componentTag = new BackLinkTagHelper(tagHelper);
            await ViewComponentTestHelper.CallTagHelper("BackLink", tagHelper, componentTag);
        }
Esempio n. 3
0
        public async Task WhenAutoCompleteLabelTagHelperCalled_ThenCorrectClassCalled()
        {
            var tagHelper = Substitute.For <IMockViewComponentHelper>();

            var componentTag = new AutoCompleteLabelTagHelper(tagHelper)
            {
                Text = "LabelText", For = "ForText", AdditionalClass = "AdditionalClass"
            };
            await ViewComponentTestHelper.CallTagHelper("AutoCompleteLabel", tagHelper, componentTag);
        }
        public async Task WhenListItemHelperCalled_ThenCorrectClassCalled()
        {
            var tagHelper = Substitute.For <IMockViewComponentHelper>();

            var componentTag = new ListItemTagHelper(tagHelper)
            {
                Text = "Test"
            };
            string text = componentTag.Text;

            await ViewComponentTestHelper.CallTagHelper("ListItem", tagHelper, componentTag);
        }
        public async Task WhenRadioHintTagHelperCalled_ThenCorrectClassCalled()
        {
            var tagHelper = Substitute.For <IMockViewComponentHelper>();

            var componentTag = new RadioHintTagHelper(tagHelper);

            componentTag.HintText        = "HintText";
            componentTag.AdditionalClass = "AdditionalClass";
            componentTag.Id = "Id";

            await ViewComponentTestHelper.CallTagHelper("RadioHint", tagHelper, componentTag);
        }
        public void WhenSecondaryButtonInvoked_ThenViewModelIsUpdated(string key, string expected)
        {
            var component = new SecondaryButton();

            component.ViewComponentContext = ViewComponentTestHelper.GetViewComponentContext();

            ViewViewComponentResult result      = component.Invoke(new Dictionary <string, string>()) as ViewViewComponentResult;
            ButtonModel             resultModel = (ButtonModel)result.ViewData.Model;

            //Assert
            resultModel.AdditionalClass.Should().BeEquivalentTo(expected);
        }
        public void WhenWarningButtonInvoked_ThenViewModelIsUpdated(string key, string expected)
        {
            var component = new WarningButton();

            component.ViewComponentContext = ViewComponentTestHelper.GetViewComponentContext();

            ViewViewComponentResult result      = component.Invoke(new Dictionary <string, string>()) as ViewViewComponentResult;
            ButtonModel             resultModel = (ButtonModel)result.ViewData.Model;

            //Assert
            expected.Should().Be(ViewComponentTestHelper.GetPropertyValue(resultModel, key));
        }
        public async Task WhenErrorSummaryHelperCalled_ThenCorrectClassCalled()
        {
            var tagHelper = Substitute.For <IMockViewComponentHelper>();

            var componentTag = new ErrorSummaryTagHelper(tagHelper)
            {
                Id     = "Id",
                Hidden = true
            };

            await ViewComponentTestHelper.CallTagHelper("ErrorSummary", tagHelper, componentTag);
        }
        public async Task WhenErrorSummaryItemHelperCalled_ThenCorrectClassCalled()
        {
            var tagHelper = Substitute.For <IMockViewComponentHelper>();

            var componentTag = new ErrorSummaryItemTagHelper(tagHelper)
            {
                Href = "href",
                Text = "text"
            };

            await ViewComponentTestHelper.CallTagHelper("ErrorSummaryItem", tagHelper, componentTag);
        }
Esempio n. 10
0
        public async Task WhenErrorTagHelperCalled_ThenCorrectClassCalled()
        {
            var tagHelper = Substitute.For <IMockViewComponentHelper>();

            var componentTag = new ErrorTagHelper(tagHelper);

            componentTag.AdditionalClass = "AdditionalClass";
            componentTag.Id   = "Id";
            componentTag.Text = "ThisIsText";
            string additionalClass = componentTag.AdditionalClass;
            string id   = componentTag.Id;
            string text = componentTag.Text;

            await ViewComponentTestHelper.CallTagHelper("Error", tagHelper, componentTag);
        }
        public void WhenRadioHintInvoked_TheViewModelIsUpdated(string key, string value)
        {
            var values = new Dictionary <string, string>()
            {
            };

            var component = new RadioHint();

            component.ViewComponentContext = ViewComponentTestHelper.GetViewComponentContext();

            ViewViewComponentResult result = component.Invoke(values) as ViewViewComponentResult;
            HintModel resultModel          = (HintModel)result.ViewData.Model;

            //Assert
            value.Should().Be(ViewComponentTestHelper.GetPropertyValue(resultModel, key));
        }
        public async Task WhenHeadingHelperCalled_ThenCorrectClassCalled()
        {
            var tagHelper = Substitute.For <IMockViewComponentHelper>();

            var componentTag = new HeadingTagHelper(tagHelper)
            {
                AdditionalClass = "AdditionalClass",
                Caption         = "Caption",
                Text            = "Text"
            };
            string additionalClass = componentTag.AdditionalClass;
            string caption         = componentTag.Caption;
            string text            = componentTag.Text;

            await ViewComponentTestHelper.CallTagHelper("Heading", tagHelper, componentTag);
        }
        public async Task WhenBulletedListHelperCalled_ThenCorrectClassCalled()
        {
            var tagHelper = Substitute.For <IMockViewComponentHelper>();

            var componentTag = new BulletedListTagHelper(tagHelper)
            {
                Id = "Id",
                AdditionalClass = "AdditionalClass",
                Text            = "Test"
            };
            string id = componentTag.Id;
            string additionalClass = componentTag.AdditionalClass;
            string text            = componentTag.Text;

            await ViewComponentTestHelper.CallTagHelper("BulletedList", tagHelper, componentTag);
        }
        public void WhenBackLinkInvoked_ThenViewModelLinkTextShouldBeSetToBackAsDefault()
        {
            var values = new Dictionary <string, string>()
            {
            };

            var component = new BackLink();

            component.ViewComponentContext = ViewComponentTestHelper.GetViewComponentContext();

            ViewViewComponentResult result = component.Invoke(values) as ViewViewComponentResult;
            LinkModel resultModel          = (LinkModel)result.ViewData.Model;

            //Assert
            "Back".Should().Be(ViewComponentTestHelper.GetPropertyValue(resultModel, "LinkText"));
        }
Esempio n. 15
0
        public void WhenRadioLabelInvoked_TheViewModelIsUpdated(string key, string value)
        {
            var values = new Dictionary <string, string>()
            {
                { key, value }
            };

            var component = new RadioLabel();

            component.ViewComponentContext = ViewComponentTestHelper.GetViewComponentContext();

            ViewViewComponentResult result = component.Invoke(values) as ViewViewComponentResult;
            LabelModel resultModel         = (LabelModel)result.ViewData.Model;

            //Assert
            resultModel.AdditionalClass.Should().Contain(value);
        }
        public async Task WhenStartButtonHelperCalled_ThenCorrectClassCalled()
        {
            var tagHelper = Substitute.For <IMockViewComponentHelper>();

            var componentTag = new StartButtonTagHelper(tagHelper)
            {
                Id = "id",
                AdditionalClass = "AdditionalClass",
                Disabled        = false,
                Text            = "ButtonText"
            };
            string id = componentTag.Id;
            string additionalClass = componentTag.AdditionalClass;
            bool   disabled        = componentTag.Disabled;
            string text            = componentTag.Text;
            await ViewComponentTestHelper.CallTagHelper("StartButton", tagHelper, componentTag);
        }
        public async Task WhenPrimaryHeroBannerTagHelperCalled_ThenCorrectClassCalled()
        {
            var tagHelper = Substitute.For <IMockViewComponentHelper>();

            var componentTag = new PrimaryHeroBannerTagHelper(tagHelper)
            {
                Id            = "Id",
                HeaderText    = "HeaderText",
                SubheaderText = "SubHeaderText"
            };

            //For code coverage
            var id         = componentTag.Id;
            var headerText = componentTag.HeaderText;
            var subHeading = componentTag.SubheaderText;
            await ViewComponentTestHelper.CallTagHelper("PrimaryHeroBanner", tagHelper, componentTag);
        }
        public void WhenPrimaryHeroBannerInvoked_ThenViewModelIsUpdated(string key, string value)
        {
            var values = new Dictionary <string, string>()
            {
                { key, value }
            };

            var component = new PrimaryHeroBanner();

            component.ViewComponentContext = ViewComponentTestHelper.GetViewComponentContext();

            ViewViewComponentResult result      = component.Invoke(values) as ViewViewComponentResult;
            BannerModel             resultModel = (BannerModel)result.ViewData.Model;

            //Assert
            value.Should().Be(ViewComponentTestHelper.GetPropertyValue(resultModel, key));
        }
        public void WhenCheckBoxInvoked_ThenViewModelIsUpdated(string key, string value)
        {
            var values = new Dictionary <string, string>()
            {
                { key, value }
            };

            var component = new Checkbox();

            component.ViewComponentContext = ViewComponentTestHelper.GetViewComponentContext();

            ViewViewComponentResult result      = component.Invoke(values) as ViewViewComponentResult;
            CheckBoxModel           resultModel = (CheckBoxModel)result.ViewData.Model;

            //Assert
            Assert.AreEqual(value, ViewComponentTestHelper.GetPropertyValue(resultModel, key));
        }
        public void WhenStartButtonLinkInvoked_ThenViewModelIsUpdated(string key, string value)
        {
            var values = new Dictionary <string, string>()
            {
                { key, value }
            };

            var component = new StartButtonLink
            {
                ViewComponentContext = ViewComponentTestHelper.GetViewComponentContext(),
            };

            ViewViewComponentResult result = component.Invoke(values) as ViewViewComponentResult;
            LinkModel resultModel          = (LinkModel)result.ViewData.Model;

            //Assert
            value.Should().Be(ViewComponentTestHelper.GetPropertyValue(resultModel, key));
        }
Esempio n. 21
0
        public async Task WhenRadioButtonHelperCalled_ThenCorrectClassCalled()
        {
            var tagHelper = Substitute.For <IMockViewComponentHelper>();

            var componentTag = new RadioButtonTagHelper(tagHelper)
            {
                Id              = "Id",
                Value           = "Value",
                AdditionalClass = "AdditionalClass",
                Name            = "Name",
                Checked         = true
            };
            string id              = componentTag.Id;
            string value           = componentTag.Value;
            string additionalClass = componentTag.AdditionalClass;
            bool   selected        = componentTag.Checked;

            await ViewComponentTestHelper.CallTagHelper("RadioButton", tagHelper, componentTag);
        }
Esempio n. 22
0
        public void When_PhaseBannerInvoked_Then_ViewModelIsUpdated(string key, string value)
        {
            // Arrange.
            var values = new Dictionary <string, string>()
            {
                { key, value }
            };
            var component = new PhaseBanner
            {
                ViewComponentContext = ViewComponentTestHelper.GetViewComponentContext()
            };

            // Act.
            var result      = component.Invoke(values) as ViewViewComponentResult;
            var resultModel = result.ViewData.Model as PhaseBannerModel;

            //Assert
            value.Should().Be(ViewComponentTestHelper.GetPropertyValue(resultModel, key));
        }
Esempio n. 23
0
        public async Task WhenCheckBoxHelperCalled_ThenCorrectClassCalled()
        {
            var tagHelper = Substitute.For <IMockViewComponentHelper>();

            var componentTag = new AutoCompleteTagHelper(tagHelper)
            {
                Id                 = "id",
                AutoSelect         = true,
                ConfirmOnBlur      = true,
                CssNameSpace       = "",
                DefaultValue       = "",
                DisplayMenu        = "",
                Element            = "",
                FunctionName       = "",
                MinLength          = 1,
                ShowNoOptionsFound = true,
                Name               = "",
                Required           = true,
                ShowAllValues      = true,
                OnConfirm          = "",
                Source             = "",
                AdditionalClass    = ""
            };
            string id                 = componentTag.Id;
            bool   autoSelect         = componentTag.AutoSelect;
            bool   confirmOnBlur      = componentTag.ConfirmOnBlur;
            string cssNamespace       = componentTag.CssNameSpace;
            string defaultValue       = componentTag.DefaultValue;
            string displayMenu        = componentTag.DisplayMenu;
            string element            = componentTag.Element;
            string functionName       = componentTag.FunctionName;
            int    minLength          = componentTag.MinLength;
            bool   showNoOptionsFound = componentTag.ShowNoOptionsFound;
            string name               = componentTag.Name;
            bool   required           = componentTag.Required;
            bool   showAllValues      = componentTag.ShowAllValues;
            string onConfirm          = componentTag.OnConfirm;
            string source             = componentTag.Source;
            string additionalClass    = componentTag.AdditionalClass;

            await ViewComponentTestHelper.CallTagHelper("AutoComplete", tagHelper, componentTag);
        }
        public async Task WhenTextInputHelperCalled_ThenCorrectClassCalled()
        {
            var tagHelper = Substitute.For <IMockViewComponentHelper>();

            var componentTag = new TextInputTagHelper(tagHelper)
            {
                AdditionalClass = "AdditionalClass",
                ErrorMessage    = "ErrorMessage",
                HintText        = "HintText",
                HasError        = false,
                Id = "Id"
            };
            string id              = componentTag.Id;
            string hintText        = componentTag.HintText;
            string errorMessage    = componentTag.ErrorMessage;
            bool   hasError        = componentTag.HasError;
            string additionalClass = componentTag.AdditionalClass;

            await ViewComponentTestHelper.CallTagHelper("TextInput", tagHelper, componentTag);
        }
Esempio n. 25
0
        public void When_PhaseBannerInvokedWithNoAttributes_Then_DefaultValuesShouldBeUsed()
        {
            // Arrange.
            var values = new Dictionary <string, string>()
            {
            };
            var component = new PhaseBanner()
            {
                ViewComponentContext = ViewComponentTestHelper.GetViewComponentContext()
            };

            // Act.
            var result      = component.Invoke(values) as ViewViewComponentResult;
            var resultModel = result.ViewData.Model as PhaseBannerModel;

            //Assert
            resultModel.Id.Should().BeNull();
            resultModel.Phase.Should().Be(IPhaseBanner.ProjectPhase.Alpha);
            resultModel.FeedbackHref.Should().Be("#");
        }
        public async Task WhenCheckBoxHelperCalled_ThenCorrectClassCalled()
        {
            var tagHelper = Substitute.For <IMockViewComponentHelper>();

            var componentTag = new CheckboxTagHelper(tagHelper)
            {
                AdditionalClass = "AdditionalClass",
                Checked         = true,
                Id    = "Id",
                Label = "Label",
                Name  = "Name",
                Value = "Value"
            };
            string additionalClass = componentTag.AdditionalClass;
            bool   isChecked       = componentTag.Checked;
            string id    = componentTag.Id;
            string label = componentTag.Label;
            string name  = componentTag.Name;
            string value = componentTag.Value;

            await ViewComponentTestHelper.CallTagHelper("Checkbox", tagHelper, componentTag);
        }