Fixes mandatory validation issue when creating a new document and a mandatory language has validation problems

This commit is contained in:
Shannon
2019-03-14 14:18:42 +11:00
parent 4eedc3ce5c
commit 9d8b5be650
4 changed files with 125 additions and 33 deletions

View File

@@ -12,6 +12,31 @@ namespace Umbraco.Tests.Web
public class ModelStateExtensionsTests
{
[Test]
public void Get_Cultures_With_Errors()
{
var ms = new ModelStateDictionary();
var localizationService = new Mock<ILocalizationService>();
localizationService.Setup(x => x.GetDefaultLanguageIsoCode()).Returns("en-US");
ms.AddPropertyError(new ValidationResult("no header image"), "headerImage", null); //invariant property
ms.AddPropertyError(new ValidationResult("title missing"), "title", "en-US"); //variant property
var result = ms.GetCulturesWithErrors(localizationService.Object);
//even though there are 2 errors, they are both for en-US since that is the default language and one of the errors is for an invariant property
Assert.AreEqual(1, result.Count);
Assert.AreEqual("en-US", result[0]);
ms = new ModelStateDictionary();
ms.AddCultureValidationError("en-US", "generic culture error");
result = ms.GetCulturesWithErrors(localizationService.Object);
Assert.AreEqual(1, result.Count);
Assert.AreEqual("en-US", result[0]);
}
[Test]
public void Get_Cultures_With_Property_Errors()
{