Skip to content

Commit 28c9b9b

Browse files
author
nikolajlauridsen
committed
Add constants for ISO codes in ContentControllerTests
1 parent 563babd commit 28c9b9b

File tree

1 file changed

+28
-31
lines changed

1 file changed

+28
-31
lines changed

src/Umbraco.Tests.Integration/Umbraco.Web.BackOffice/Controllers/ContentControllerTests.cs

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Web.BackOffice.Controllers
2525
[TestFixture]
2626
public class ContentControllerTests : UmbracoTestServerTestBase
2727
{
28+
private const string UsIso = "en-US";
29+
private const string DkIso = "da-DK";
30+
2831
/// <summary>
2932
/// Returns 404 if the content wasn't found based on the ID specified
3033
/// </summary>
@@ -35,7 +38,7 @@ public async Task PostSave_Validate_Existing_Content()
3538

3639
// Add another language
3740
localizationService.Save(new LanguageBuilder()
38-
.WithCultureInfo("da-DK")
41+
.WithCultureInfo(DkIso)
3942
.WithIsDefault(false)
4043
.Build());
4144

@@ -93,7 +96,7 @@ public async Task PostSave_Validate_At_Least_One_Variant_Flagged_For_Saving()
9396

9497
// Add another language
9598
localizationService.Save(new LanguageBuilder()
96-
.WithCultureInfo("da-DK")
99+
.WithCultureInfo(DkIso)
97100
.WithIsDefault(false)
98101
.Build());
99102

@@ -162,7 +165,7 @@ public async Task PostSave_Validate_Properties_Exist()
162165

163166
// Add another language
164167
localizationService.Save(new LanguageBuilder()
165-
.WithCultureInfo("da-DK")
168+
.WithCultureInfo(DkIso)
166169
.WithIsDefault(false)
167170
.Build());
168171

@@ -227,7 +230,7 @@ public async Task PostSave_Simple_Invariant()
227230

228231
// Add another language
229232
localizationService.Save(new LanguageBuilder()
230-
.WithCultureInfo("da-DK")
233+
.WithCultureInfo(DkIso)
231234
.WithIsDefault(false)
232235
.Build());
233236

@@ -288,7 +291,7 @@ public async Task PostSave_Validate_Empty_Name()
288291

289292
// Add another language
290293
localizationService.Save(new LanguageBuilder()
291-
.WithCultureInfo("da-DK")
294+
.WithCultureInfo(DkIso)
292295
.WithIsDefault(false)
293296
.Build());
294297

@@ -352,7 +355,7 @@ public async Task PostSave_Validate_Variants_Empty_Name()
352355

353356
// Add another language
354357
localizationService.Save(new LanguageBuilder()
355-
.WithCultureInfo("da-DK")
358+
.WithCultureInfo(DkIso)
356359
.WithIsDefault(false)
357360
.Build());
358361

@@ -376,8 +379,8 @@ public async Task PostSave_Validate_Variants_Empty_Name()
376379

377380
Content content = new ContentBuilder()
378381
.WithId(0)
379-
.WithCultureName("en-US", "English")
380-
.WithCultureName("da-DK", "Danish")
382+
.WithCultureName(UsIso, "English")
383+
.WithCultureName(DkIso, "Danish")
381384
.WithContentType(contentType)
382385
.AddPropertyData()
383386
.WithKeyValue("title", "Cool invariant title")
@@ -414,7 +417,7 @@ public async Task PostSave_Validates_Domains_Exist()
414417
{
415418
ILocalizationService localizationService = GetRequiredService<ILocalizationService>();
416419
localizationService.Save(new LanguageBuilder()
417-
.WithCultureInfo("da-DK")
420+
.WithCultureInfo(DkIso)
418421
.WithIsDefault(false)
419422
.Build());
420423

@@ -425,8 +428,8 @@ public async Task PostSave_Validates_Domains_Exist()
425428
Content content = new ContentBuilder()
426429
.WithId(1)
427430
.WithContentType(contentType)
428-
.WithCultureName("en-US", "Root")
429-
.WithCultureName("da-DK", "Rod")
431+
.WithCultureName(UsIso, "Root")
432+
.WithCultureName(DkIso, "Rod")
430433
.Build();
431434

432435
ContentItemSave model = new ContentItemSaveBuilder()
@@ -459,12 +462,9 @@ public async Task PostSave_Validates_Domains_Exist()
459462
[Test]
460463
public async Task PostSave_Validates_All_Cultures_Has_Domains()
461464
{
462-
var enString = "en-US";
463-
var dkString = "da-DK";
464-
465465
ILocalizationService localizationService = GetRequiredService<ILocalizationService>();
466466
localizationService.Save(new LanguageBuilder()
467-
.WithCultureInfo(dkString)
467+
.WithCultureInfo(DkIso)
468468
.WithIsDefault(false)
469469
.Build());
470470

@@ -475,8 +475,8 @@ public async Task PostSave_Validates_All_Cultures_Has_Domains()
475475
Content content = new ContentBuilder()
476476
.WithoutIdentity()
477477
.WithContentType(contentType)
478-
.WithCultureName(enString, "Root")
479-
.WithCultureName(dkString, "Rod")
478+
.WithCultureName(UsIso, "Root")
479+
.WithCultureName(DkIso, "Rod")
480480
.Build();
481481

482482
IContentService contentService = GetRequiredService<IContentService>();
@@ -487,7 +487,7 @@ public async Task PostSave_Validates_All_Cultures_Has_Domains()
487487
.WithAction(ContentSaveAction.Publish)
488488
.Build();
489489

490-
ILanguage dkLanguage = localizationService.GetLanguageByIsoCode(dkString);
490+
ILanguage dkLanguage = localizationService.GetLanguageByIsoCode(DkIso);
491491
IDomainService domainService = GetRequiredService<IDomainService>();
492492
var dkDomain = new UmbracoDomain("/")
493493
{
@@ -509,7 +509,7 @@ public async Task PostSave_Validates_All_Cultures_Has_Domains()
509509

510510

511511
ILocalizedTextService localizedTextService = GetRequiredService<ILocalizedTextService>();
512-
var expectedMessage = localizedTextService.Localize("speechBubbles", "publishWithMissingDomain", new []{"en-US"});
512+
var expectedMessage = localizedTextService.Localize("speechBubbles", "publishWithMissingDomain", new []{UsIso});
513513

514514
Assert.Multiple(() =>
515515
{
@@ -522,12 +522,9 @@ public async Task PostSave_Validates_All_Cultures_Has_Domains()
522522
[Test]
523523
public async Task PostSave_Checks_Ancestors_For_Domains()
524524
{
525-
var enString = "en-US";
526-
var dkString = "da-DK";
527-
528525
ILocalizationService localizationService = GetRequiredService<ILocalizationService>();
529526
localizationService.Save(new LanguageBuilder()
530-
.WithCultureInfo(dkString)
527+
.WithCultureInfo(DkIso)
531528
.WithIsDefault(false)
532529
.Build());
533530

@@ -538,8 +535,8 @@ public async Task PostSave_Checks_Ancestors_For_Domains()
538535
Content rootNode = new ContentBuilder()
539536
.WithoutIdentity()
540537
.WithContentType(contentType)
541-
.WithCultureName(enString, "Root")
542-
.WithCultureName(dkString, "Rod")
538+
.WithCultureName(UsIso, "Root")
539+
.WithCultureName(DkIso, "Rod")
543540
.Build();
544541

545542
IContentService contentService = GetRequiredService<IContentService>();
@@ -549,8 +546,8 @@ public async Task PostSave_Checks_Ancestors_For_Domains()
549546
.WithoutIdentity()
550547
.WithParent(rootNode)
551548
.WithContentType(contentType)
552-
.WithCultureName(dkString, "Barn")
553-
.WithCultureName(enString, "Child")
549+
.WithCultureName(DkIso, "Barn")
550+
.WithCultureName(UsIso, "Child")
554551
.Build();
555552

556553
contentService.SaveAndPublish(childNode);
@@ -559,14 +556,14 @@ public async Task PostSave_Checks_Ancestors_For_Domains()
559556
.WithoutIdentity()
560557
.WithParent(childNode)
561558
.WithContentType(contentType)
562-
.WithCultureName(dkString, "BarneBarn")
563-
.WithCultureName(enString, "GrandChild")
559+
.WithCultureName(DkIso, "BarneBarn")
560+
.WithCultureName(UsIso, "GrandChild")
564561
.Build();
565562

566563
contentService.Save(grandChild);
567564

568-
ILanguage dkLanguage = localizationService.GetLanguageByIsoCode(dkString);
569-
ILanguage usLanguage = localizationService.GetLanguageByIsoCode(enString);
565+
ILanguage dkLanguage = localizationService.GetLanguageByIsoCode(DkIso);
566+
ILanguage usLanguage = localizationService.GetLanguageByIsoCode(UsIso);
570567
IDomainService domainService = GetRequiredService<IDomainService>();
571568
var dkDomain = new UmbracoDomain("/")
572569
{

0 commit comments

Comments
 (0)