@@ -333,4 +333,95 @@ public async Task Cannot_Update_Variant_With_Incorrect_Culture_Casing()
333333 Assert . IsFalse ( result . Success ) ;
334334 Assert . AreEqual ( ContentEditingOperationStatus . InvalidCulture , result . Status ) ;
335335 }
336+
337+ [ Test ]
338+ public async Task Cannot_Update_Invariant_Readonly_Property_Value ( )
339+ {
340+ var content = await CreateInvariantContent ( ) ;
341+ content . SetValue ( "label" , "The initial label value" ) ;
342+ ContentService . Save ( content ) ;
343+
344+ var updateModel = new ContentUpdateModel
345+ {
346+ InvariantName = "Updated Name" ,
347+ InvariantProperties = new [ ]
348+ {
349+ new PropertyValueModel { Alias = "label" , Value = "The updated label value" }
350+ }
351+ } ;
352+
353+ var result = await ContentEditingService . UpdateAsync ( content . Key , updateModel , Constants . Security . SuperUserKey ) ;
354+ Assert . Multiple ( ( ) =>
355+ {
356+ Assert . IsTrue ( result . Success ) ;
357+ Assert . AreEqual ( ContentEditingOperationStatus . Success , result . Status ) ;
358+ Assert . IsNotNull ( result . Result . Content ) ;
359+ } ) ;
360+
361+ // re-get and validate
362+ content = await ContentEditingService . GetAsync ( content . Key ) ;
363+ Assert . IsNotNull ( content ) ;
364+ Assert . Multiple ( ( ) =>
365+ {
366+ Assert . AreEqual ( "Updated Name" , content . Name ) ;
367+ Assert . AreEqual ( "The initial label value" , content . GetValue < string > ( "label" ) ) ;
368+ } ) ;
369+ }
370+
371+ [ Test ]
372+ public async Task Cannot_Update_Variant_Readonly_Property_Value ( )
373+ {
374+ var content = await CreateVariantContent ( ) ;
375+ content . SetValue ( "variantLabel" , "The initial English label value" , "en-US" ) ;
376+ content . SetValue ( "variantLabel" , "The initial Danish label value" , "da-DK" ) ;
377+ ContentService . Save ( content ) ;
378+
379+ var updateModel = new ContentUpdateModel
380+ {
381+ InvariantProperties = new [ ]
382+ {
383+ new PropertyValueModel { Alias = "invariantTitle" , Value = "The updated invariant title" }
384+ } ,
385+ Variants = new [ ]
386+ {
387+ new VariantModel
388+ {
389+ Culture = "en-US" ,
390+ Name = "Updated English Name" ,
391+ Properties = new [ ]
392+ {
393+ new PropertyValueModel { Alias = "variantLabel" , Value = "The updated English label value" }
394+ }
395+ } ,
396+ new VariantModel
397+ {
398+ Culture = "da-DK" ,
399+ Name = "Updated Danish Name" ,
400+ Properties = new [ ]
401+ {
402+ new PropertyValueModel { Alias = "variantLabel" , Value = "The updated Danish label value" }
403+ }
404+ }
405+ }
406+ } ;
407+
408+ var result = await ContentEditingService . UpdateAsync ( content . Key , updateModel , Constants . Security . SuperUserKey ) ;
409+ Assert . Multiple ( ( ) =>
410+ {
411+ Assert . IsTrue ( result . Success ) ;
412+ Assert . AreEqual ( ContentEditingOperationStatus . Success , result . Status ) ;
413+ Assert . IsNotNull ( result . Result . Content ) ;
414+ } ) ;
415+
416+ // re-get and validate
417+ content = await ContentEditingService . GetAsync ( content . Key ) ;
418+ Assert . IsNotNull ( content ) ;
419+ Assert . Multiple ( ( ) =>
420+ {
421+ Assert . AreEqual ( "Updated English Name" , content . GetCultureName ( "en-US" ) ) ;
422+ Assert . AreEqual ( "Updated Danish Name" , content . GetCultureName ( "da-DK" ) ) ;
423+ Assert . AreEqual ( "The initial English label value" , content . GetValue < string > ( "variantLabel" , "en-US" ) ) ;
424+ Assert . AreEqual ( "The initial Danish label value" , content . GetValue < string > ( "variantLabel" , "da-DK" ) ) ;
425+ } ) ;
426+ }
336427}
0 commit comments