public void ShouldShowWageRangeInputsWhenWageRangeIsSelected() { var details = new FurtherVacancyDetails(); var viewModel = new Fixture().Build <FurtherVacancyDetailsViewModel>() .With(v => v.Status, VacancyStatus.Draft) .With(v => v.Wage, new WageViewModel() { Classification = WageClassification.Custom, CustomType = CustomWageType.Ranged, AmountLowerBound = 200, AmountUpperBound = 500, Unit = WageUnit.Weekly }) .With(v => v.WageUnits, ApprenticeshipVacancyConverter.GetWageUnits()) .Create(); var view = details.RenderAsHtml(viewModel); view.GetElementbyId("custom-wage").Attributes["checked"].Value.Should().Be("checked"); view.GetElementbyId("custom-wage-fixed").Attributes["checked"]?.Value.Should().NotBe("checked"); view.GetElementbyId("custom-wage-range").Attributes["checked"].Value.Should().Be("checked"); view.GetElementbyId("Wage_AmountLowerBound").Should().NotBeNull(); view.GetElementbyId("Wage_AmountLowerBound").Attributes["value"].Value.Should().Be("200"); view.GetElementbyId("Wage_AmountUpperBound").Attributes["value"].Value.Should().Be("500"); view.GetElementbyId("Wage_RangeUnit").Should().NotBeNull(); view.GetElementbyId("Wage_RangeUnit") .ChildNodes.Any(cn => cn.Attributes["value"].Value == WageUnit.Weekly.ToString()).Should().BeTrue(); }
public void ShouldShowTextDropdownAndReasonBoxWhenChooseTextIsSelected(PresetText wageType) { var details = new FurtherVacancyDetails(); var viewModel = new Fixture().Build <FurtherVacancyDetailsViewModel>() .With(v => v.Status, VacancyStatus.Draft) .With(v => v.Wage, new WageViewModel() { Classification = WageClassification.LegacyText, PresetText = wageType }) .With(v => v.WageTextPresets, ApprenticeshipVacancyConverter.GetWageTextPresets()) .Create(); var view = details.RenderAsHtml(viewModel); //TODO: Our HTML is invalid. This causes the browser to fail to set the "checked" property. //A quick W3C check on this page resulted in 136 errors and 8 warnings. //This is not good at all. The input appears to be selected but does not have the property. //So, we can't verify as we should. //view.GetElementbyId("preset-text").Attributes["checked"].Value.Should().Be("checked"); view.GetElementbyId("Wage_PresetText").Should().NotBeNull(); view.GetElementbyId("Wage_PresetText").ChildNodes.Any(x => x.Attributes.Contains("selected") && x.Attributes["selected"].Value == "selected").Should().BeTrue(); view.GetElementbyId("Wage_PresetText").ChildNodes.Single(x => x.Attributes.Contains("selected") && x.Attributes["selected"].Value == "selected").Attributes["value"].Value.Should().Be(((int)wageType).ToString()); view.GetElementbyId("Wage_WageTypeReason").Should().NotBeNull(); }
public void ShouldShowFixedWageAndWageRangeRadiosWhenCustomWageIsSelected(CustomWageType wageType) { var details = new FurtherVacancyDetails(); var viewModel = new Fixture().Build <FurtherVacancyDetailsViewModel>() .With(v => v.Status, VacancyStatus.Draft) .With(v => v.Wage, new WageViewModel() { Classification = WageClassification.Custom, CustomType = wageType }) .Create(); var view = details.RenderAsHtml(viewModel); view.GetElementbyId("custom-wage").Attributes["checked"].Value.Should().Be("checked"); view.GetElementbyId("custom-wage-fixed").Should().NotBeNull(); view.GetElementbyId("custom-wage-range").Should().NotBeNull(); if (wageType == CustomWageType.Fixed) { view.GetElementbyId("custom-wage-fixed").Attributes["checked"].Value.Should().Be("checked"); } else { view.GetElementbyId("custom-wage-range").Attributes["checked"].Value.Should().Be("checked"); } }
public void ShouldNotHaveWageWhenTraineeship() { //Arrange var viewModel = new Fixture().Build <FurtherVacancyDetailsViewModel>() .With(vm => vm.VacancyType, VacancyType.Traineeship) .With(vm => vm.Wage, dummyWageViewModel) .Create(); var details = new FurtherVacancyDetails(); //Act var view = details.RenderAsHtml(viewModel); //Assert view.GetElementbyId("custom-wage").Should().BeNull(); view.GetElementbyId("national-minimum-wage").Should().BeNull(); view.GetElementbyId("apprenticeship-minimum-wage").Should().BeNull(); var wageType = view.GetElementbyId("Wage_Type"); wageType.Should().NotBeNull(); wageType.Attributes["type"].Value.Should().Be("hidden"); var wage = view.GetElementbyId("Wage_Amount"); wage.Should().NotBeNull(); wage.Attributes["type"].Value.Should().Be("hidden"); var wageUnit = view.GetElementbyId("Wage_Unit"); wageUnit.Should().NotBeNull(); wageUnit.Attributes["type"].Value.Should().Be("hidden"); }
public void ShouldAlwaysShowChooseTextDescriptionRadio() { var details = new FurtherVacancyDetails(); var viewModel = new Fixture().Build <FurtherVacancyDetailsViewModel>() .With(v => v.Status, VacancyStatus.Referred) .Create(); var view = details.RenderAsHtml(viewModel); view.GetElementbyId("preset-text").Should().NotBeNull(); }
public void ApprenticeshipHeading() { //Arrange var viewModel = new Fixture().Build <FurtherVacancyDetailsViewModel>() .With(vm => vm.VacancyType, VacancyType.Apprenticeship) .Create(); var details = new FurtherVacancyDetails(); //Act var view = details.RenderAsHtml(viewModel); view.GetElementbyId("heading").Should().NotBeNull(); view.GetElementbyId("heading").InnerText.Should().Contain("Enter further details"); }
public void ShouldNoDisplayLegacyExpectedDurationWhenVacancySourceIsRaa() { //Arrange var viewModel = new Fixture().Build <FurtherVacancyDetailsViewModel>() .With(v => v.VacancySource, VacancySource.Raa) .Create(); var details = new FurtherVacancyDetails(); //Act var view = details.RenderAsHtml(viewModel); //Assert var expectedDuration = view.GetElementbyId("ExpectedDuration"); expectedDuration.Should().BeNull(); }
public void ShouldNotHaveHoursPerWeekWhenTraineeship() { //Arrange var viewModel = new Fixture().Build <FurtherVacancyDetailsViewModel>() .With(vm => vm.VacancyType, VacancyType.Traineeship) .With(vm => vm.Wage, dummyWageViewModel) .Create(); var details = new FurtherVacancyDetails(); //Act var view = details.RenderAsHtml(viewModel); //Assert var hoursPerWeek = view.GetElementbyId("Wage_HoursPerWeek"); hoursPerWeek.Should().NotBeNull(); hoursPerWeek.Attributes["type"].Value.Should().Be("hidden"); }
public void TraineeshipWorkingWeekLabel() { //Arrange var viewModel = new Fixture().Build <FurtherVacancyDetailsViewModel>() .With(vm => vm.VacancyType, VacancyType.Traineeship) .Create(); var details = new FurtherVacancyDetails(); //Act var view = details.RenderAsHtml(viewModel); //Assert var workingWeek = view.GetElementbyId("WorkingWeek"); workingWeek.Should().NotBeNull(); var label = workingWeek.PreviousSibling; label.Should().NotBeNull(); label.InnerText.Should().Be("Weekly hours"); }
public void ShouldDisplayWageAmount() { //Arrange var viewModel = new Fixture().Build <FurtherVacancyDetailsViewModel>() .With(vm => vm.VacancyType, VacancyType.Apprenticeship) .With(vm => vm.Wage, new WageViewModel() { CustomType = CustomWageType.Fixed, Amount = 123.45m }) .Create(); var details = new FurtherVacancyDetails(); //Act var view = details.RenderAsHtml(viewModel); //Assert var wage = view.GetElementbyId("Wage_Amount"); wage.Should().NotBeNull(); wage.GetAttributeValue("value", "").Should().Be("123.45"); }
public void ShouldDisplayHoursPerWeek() { //Arrange var viewModel = new Fixture().Build <FurtherVacancyDetailsViewModel>() .With(vm => vm.VacancyType, VacancyType.Apprenticeship) .With(vm => vm.Wage, new WageViewModel() { CustomType = CustomWageType.Fixed, HoursPerWeek = 37.5m }) .Create(); var details = new FurtherVacancyDetails(); //Act var view = details.RenderAsHtml(viewModel); //Assert var hoursPerWeek = view.GetElementbyId("Wage_HoursPerWeek"); hoursPerWeek.Should().NotBeNull(); hoursPerWeek.GetAttributeValue("value", "").Should().Be("37.5"); }