2020-12-20 08:36:11 +01:00
// Copyright (c) Umbraco.
// See LICENSE for more details.
2019-10-28 18:02:52 +11:00
using System.Text ;
using NUnit.Framework ;
2021-02-09 10:22:42 +01:00
using Umbraco.Cms.Core.Configuration.Models ;
2022-06-21 08:09:38 +02:00
using Umbraco.Cms.Core.Exceptions ;
2021-02-09 10:22:42 +01:00
using Umbraco.Cms.Core.Models.PublishedContent ;
2021-02-22 09:00:33 +01:00
using Umbraco.Cms.Infrastructure.ModelsBuilder ;
using Umbraco.Cms.Infrastructure.ModelsBuilder.Building ;
2019-10-28 18:02:52 +11:00
2022-06-21 08:09:38 +02:00
namespace Umbraco.Cms.Tests.UnitTests.Umbraco.ModelsBuilder.Embedded ;
[TestFixture]
public class BuilderTests
2019-10-28 18:02:52 +11:00
{
2022-06-21 08:09:38 +02:00
[Test]
public void GenerateSimpleType ( )
2019-10-28 18:02:52 +11:00
{
2022-06-21 08:09:38 +02:00
// Umbraco returns nice, pascal-cased names.
var type1 = new TypeModel
{
Id = 1 ,
Alias = "type1" ,
ClrName = "Type1" ,
Name = "type1Name" ,
ParentId = 0 ,
BaseType = null ,
ItemType = TypeModel . ItemTypes . Content ,
} ;
type1 . Properties . Add ( new PropertyModel
2019-10-28 18:02:52 +11:00
{
2022-06-21 08:09:38 +02:00
Alias = "prop1" ,
ClrName = "Prop1" ,
Name = "prop1Name" ,
ModelClrType = typeof ( string ) ,
} ) ;
TypeModel [ ] types = { type1 } ;
var modelsBuilderConfig = new ModelsBuilderSettings ( ) ;
var builder = new TextBuilder ( modelsBuilderConfig , types ) ;
var sb = new StringBuilder ( ) ;
builder . Generate ( sb , builder . GetModelsToGenerate ( ) . First ( ) ) ;
var gen = sb . ToString ( ) ;
var version = ApiVersion . Current . Version ;
var expected = @ "//------------------------------------------------------------------------------
2019-10-28 18:02:52 +11:00
// <auto-generated>
// This code was generated by a tool.
//
2020-03-07 21:33:35 +00:00
// Umbraco.ModelsBuilder.Embedded v" + version + @"
2019-10-28 18:02:52 +11:00
//
// Changes to this file will be lost if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System ;
using System.Linq.Expressions ;
2021-02-11 13:27:19 +01:00
using Umbraco.Cms.Core.Models.PublishedContent ;
using Umbraco.Cms.Core.PublishedCache ;
2021-02-22 10:32:09 +01:00
using Umbraco.Cms.Infrastructure.ModelsBuilder ;
2021-02-09 15:39:00 +01:00
using Umbraco.Cms.Core ;
2021-02-11 13:27:19 +01:00
using Umbraco.Extensions ;
2019-10-28 18:02:52 +11:00
2021-02-11 13:27:19 +01:00
namespace Umbraco.Cms.Web.Common.PublishedModels
2019-10-28 18:02:52 +11:00
{
2021-11-03 13:05:43 +01:00
/// <summary>type1Name</summary>
2019-10-28 18:02:52 +11:00
[PublishedModel(""type1"")]
public partial class Type1 : PublishedContentModel
{
// helpers
#pragma warning disable 0109 // new is redundant
2022-06-21 08:09:38 +02:00
[ global :: System . CodeDom . Compiler . GeneratedCodeAttribute ( "" Umbraco . ModelsBuilder . Embedded "" , "" " + version +
@"" ")]
2019-10-28 18:02:52 +11:00
public new const string ModelTypeAlias = "" type1 "" ;
2022-06-21 08:09:38 +02:00
[ global :: System . CodeDom . Compiler . GeneratedCodeAttribute ( "" Umbraco . ModelsBuilder . Embedded "" , "" " + version +
@"" ")]
2019-10-28 18:02:52 +11:00
public new const PublishedItemType ModelItemType = PublishedItemType . Content ;
2022-06-21 08:09:38 +02:00
[ global :: System . CodeDom . Compiler . GeneratedCodeAttribute ( "" Umbraco . ModelsBuilder . Embedded "" , "" " + version +
@"" ")]
2021-07-13 10:15:03 +02:00
[return: global::System.Diagnostics.CodeAnalysis.MaybeNull]
2024-10-01 15:03:02 +02:00
public new static IPublishedContentType GetModelContentType ( IPublishedContentTypeCache contentTypeCache )
= > PublishedModelUtility . GetModelContentType ( contentTypeCache , ModelItemType , ModelTypeAlias ) ;
2022-06-21 08:09:38 +02:00
[ global :: System . CodeDom . Compiler . GeneratedCodeAttribute ( "" Umbraco . ModelsBuilder . Embedded "" , "" " + version +
@"" ")]
2021-07-13 10:15:03 +02:00
[return: global::System.Diagnostics.CodeAnalysis.MaybeNull]
2024-10-01 15:03:02 +02:00
public static IPublishedPropertyType GetModelPropertyType < TValue > ( IPublishedContentTypeCache contentTypeCache , Expression < Func < Type1 , TValue > > selector )
= > PublishedModelUtility . GetModelPropertyType ( GetModelContentType ( contentTypeCache ) , selector ) ;
2019-10-28 18:02:52 +11:00
#pragma warning restore 0109
2020-09-08 15:17:57 +02:00
private IPublishedValueFallback _publishedValueFallback ;
2019-10-28 18:02:52 +11:00
// ctor
2020-09-08 15:17:57 +02:00
public Type1 ( IPublishedContent content , IPublishedValueFallback publishedValueFallback )
2021-05-06 10:58:45 +02:00
: base ( content , publishedValueFallback )
2020-09-08 15:17:57 +02:00
{
2021-02-09 10:22:42 +01:00
_publishedValueFallback = publishedValueFallback ;
2020-09-08 15:17:57 +02:00
}
2019-10-28 18:02:52 +11:00
// properties
2021-11-03 13:05:43 +01:00
///<summary>
/// prop1Name
///</summary>
2022-06-21 08:09:38 +02:00
[ global :: System . CodeDom . Compiler . GeneratedCodeAttribute ( "" Umbraco . ModelsBuilder . Embedded "" , "" " + version +
@"" ")]
2021-07-13 10:15:03 +02:00
[global::System.Diagnostics.CodeAnalysis.MaybeNull]
2019-10-28 18:02:52 +11:00
[ImplementPropertyType(""prop1"")]
2021-04-20 19:34:18 +02:00
public virtual string Prop1 = > this . Value < string > ( _publishedValueFallback , "" prop1 "" ) ;
2019-10-28 18:02:52 +11:00
}
}
2025-03-04 11:52:20 +01:00
";
Console . WriteLine ( gen ) ;
Assert . AreEqual ( expected . ClearLf ( ) , gen ) ;
}
[Test]
public void GenerateSimpleType_WithoutVersion ( )
{
// Umbraco returns nice, pascal-cased names.
var type1 = new TypeModel
{
Id = 1 ,
Alias = "type1" ,
ClrName = "Type1" ,
Name = "type1Name" ,
ParentId = 0 ,
BaseType = null ,
ItemType = TypeModel . ItemTypes . Content ,
} ;
type1 . Properties . Add ( new PropertyModel
{
Alias = "prop1" ,
ClrName = "Prop1" ,
Name = "prop1Name" ,
ModelClrType = typeof ( string ) ,
} ) ;
TypeModel [ ] types = { type1 } ;
var modelsBuilderConfig = new ModelsBuilderSettings { IncludeVersionNumberInGeneratedModels = false } ;
var builder = new TextBuilder ( modelsBuilderConfig , types ) ;
var sb = new StringBuilder ( ) ;
builder . Generate ( sb , builder . GetModelsToGenerate ( ) . First ( ) ) ;
var gen = sb . ToString ( ) ;
var expected = @ "//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Umbraco.ModelsBuilder.Embedded
//
// Changes to this file will be lost if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System ;
using System.Linq.Expressions ;
using Umbraco.Cms.Core.Models.PublishedContent ;
using Umbraco.Cms.Core.PublishedCache ;
using Umbraco.Cms.Infrastructure.ModelsBuilder ;
using Umbraco.Cms.Core ;
using Umbraco.Extensions ;
namespace Umbraco.Cms.Web.Common.PublishedModels
{
/// <summary>type1Name</summary>
[PublishedModel(""type1"")]
public partial class Type1 : PublishedContentModel
{
// helpers
#pragma warning disable 0109 // new is redundant
[global::System.CodeDom.Compiler.GeneratedCodeAttribute(""Umbraco.ModelsBuilder.Embedded"", """")]
public new const string ModelTypeAlias = "" type1 "" ;
[global::System.CodeDom.Compiler.GeneratedCodeAttribute(""Umbraco.ModelsBuilder.Embedded"", """")]
public new const PublishedItemType ModelItemType = PublishedItemType . Content ;
[global::System.CodeDom.Compiler.GeneratedCodeAttribute(""Umbraco.ModelsBuilder.Embedded"", """")]
[return: global::System.Diagnostics.CodeAnalysis.MaybeNull]
2025-03-05 11:47:27 +01:00
public new static IPublishedContentType GetModelContentType ( IPublishedContentTypeCache contentTypeCache )
= > PublishedModelUtility . GetModelContentType ( contentTypeCache , ModelItemType , ModelTypeAlias ) ;
2025-03-04 11:52:20 +01:00
[global::System.CodeDom.Compiler.GeneratedCodeAttribute(""Umbraco.ModelsBuilder.Embedded"", """")]
[return: global::System.Diagnostics.CodeAnalysis.MaybeNull]
2025-03-05 11:47:27 +01:00
public static IPublishedPropertyType GetModelPropertyType < TValue > ( IPublishedContentTypeCache contentTypeCache , Expression < Func < Type1 , TValue > > selector )
= > PublishedModelUtility . GetModelPropertyType ( GetModelContentType ( contentTypeCache ) , selector ) ;
2025-03-04 11:52:20 +01:00
#pragma warning restore 0109
private IPublishedValueFallback _publishedValueFallback ;
// ctor
public Type1 ( IPublishedContent content , IPublishedValueFallback publishedValueFallback )
: base ( content , publishedValueFallback )
{
_publishedValueFallback = publishedValueFallback ;
}
// properties
///<summary>
/// prop1Name
///</summary>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute(""Umbraco.ModelsBuilder.Embedded"", """")]
[global::System.Diagnostics.CodeAnalysis.MaybeNull]
[ImplementPropertyType(""prop1"")]
2021-04-20 19:34:18 +02:00
public virtual string Prop1 = > this . Value < string > ( _publishedValueFallback , "" prop1 "" ) ;
2019-10-28 18:02:52 +11:00
}
}
";
2022-06-21 08:09:38 +02:00
Console . WriteLine ( gen ) ;
Assert . AreEqual ( expected . ClearLf ( ) , gen ) ;
}
[Test]
public void GenerateSimpleType_Ambiguous_Issue ( )
{
// Umbraco returns nice, pascal-cased names.
var type1 = new TypeModel
{
Id = 1 ,
Alias = "type1" ,
ClrName = "Type1" ,
ParentId = 0 ,
BaseType = null ,
ItemType = TypeModel . ItemTypes . Content ,
} ;
type1 . Properties . Add ( new PropertyModel
{
Alias = "foo" ,
ClrName = "Foo" ,
ModelClrType = typeof ( IEnumerable < > ) . MakeGenericType ( ModelType . For ( "foo" ) ) ,
} ) ;
2019-10-28 18:02:52 +11:00
2022-06-21 08:09:38 +02:00
var type2 = new TypeModel
{
Id = 2 ,
Alias = "foo" ,
ClrName = "Foo" ,
ParentId = 0 ,
BaseType = null ,
ItemType = TypeModel . ItemTypes . Element ,
} ;
TypeModel [ ] types = { type1 , type2 } ;
var modelsBuilderConfig = new ModelsBuilderSettings ( ) ;
var builder = new TextBuilder ( modelsBuilderConfig , types )
2019-10-28 18:02:52 +11:00
{
2022-06-21 08:09:38 +02:00
ModelsNamespace = "Umbraco.Cms.Web.Common.PublishedModels" ,
} ;
var sb1 = new StringBuilder ( ) ;
builder . Generate ( sb1 , builder . GetModelsToGenerate ( ) . Skip ( 1 ) . First ( ) ) ;
var gen1 = sb1 . ToString ( ) ;
Console . WriteLine ( gen1 ) ;
var sb = new StringBuilder ( ) ;
builder . Generate ( sb , builder . GetModelsToGenerate ( ) . First ( ) ) ;
var gen = sb . ToString ( ) ;
var version = ApiVersion . Current . Version ;
var expected = @ "//------------------------------------------------------------------------------
2019-10-28 18:02:52 +11:00
// <auto-generated>
// This code was generated by a tool.
//
2020-03-07 21:33:35 +00:00
// Umbraco.ModelsBuilder.Embedded v" + version + @"
2019-10-28 18:02:52 +11:00
//
// Changes to this file will be lost if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System ;
using System.Linq.Expressions ;
2021-02-11 13:27:19 +01:00
using Umbraco.Cms.Core.Models.PublishedContent ;
using Umbraco.Cms.Core.PublishedCache ;
2021-02-22 10:32:09 +01:00
using Umbraco.Cms.Infrastructure.ModelsBuilder ;
2021-02-09 15:39:00 +01:00
using Umbraco.Cms.Core ;
2021-02-11 13:27:19 +01:00
using Umbraco.Extensions ;
2019-10-28 18:02:52 +11:00
2021-02-11 13:27:19 +01:00
namespace Umbraco.Cms.Web.Common.PublishedModels
2019-10-28 18:02:52 +11:00
{
[PublishedModel(""type1"")]
public partial class Type1 : PublishedContentModel
{
// helpers
#pragma warning disable 0109 // new is redundant
2022-06-21 08:09:38 +02:00
[ global :: System . CodeDom . Compiler . GeneratedCodeAttribute ( "" Umbraco . ModelsBuilder . Embedded "" , "" " + version +
@"" ")]
2019-10-28 18:02:52 +11:00
public new const string ModelTypeAlias = "" type1 "" ;
2022-06-21 08:09:38 +02:00
[ global :: System . CodeDom . Compiler . GeneratedCodeAttribute ( "" Umbraco . ModelsBuilder . Embedded "" , "" " + version +
@"" ")]
2019-10-28 18:02:52 +11:00
public new const PublishedItemType ModelItemType = PublishedItemType . Content ;
2022-06-21 08:09:38 +02:00
[ global :: System . CodeDom . Compiler . GeneratedCodeAttribute ( "" Umbraco . ModelsBuilder . Embedded "" , "" " + version +
@"" ")]
2021-07-13 10:15:03 +02:00
[return: global::System.Diagnostics.CodeAnalysis.MaybeNull]
2024-10-01 15:03:02 +02:00
public new static IPublishedContentType GetModelContentType ( IPublishedContentTypeCache contentTypeCache )
= > PublishedModelUtility . GetModelContentType ( contentTypeCache , ModelItemType , ModelTypeAlias ) ;
2022-06-21 08:09:38 +02:00
[ global :: System . CodeDom . Compiler . GeneratedCodeAttribute ( "" Umbraco . ModelsBuilder . Embedded "" , "" " + version +
@"" ")]
2021-07-13 10:15:03 +02:00
[return: global::System.Diagnostics.CodeAnalysis.MaybeNull]
2024-10-01 15:03:02 +02:00
public static IPublishedPropertyType GetModelPropertyType < TValue > ( IPublishedContentTypeCache contentTypeCache , Expression < Func < Type1 , TValue > > selector )
= > PublishedModelUtility . GetModelPropertyType ( GetModelContentType ( contentTypeCache ) , selector ) ;
2019-10-28 18:02:52 +11:00
#pragma warning restore 0109
2020-09-08 15:17:57 +02:00
private IPublishedValueFallback _publishedValueFallback ;
2019-10-28 18:02:52 +11:00
// ctor
2020-09-08 15:17:57 +02:00
public Type1 ( IPublishedContent content , IPublishedValueFallback publishedValueFallback )
2021-05-06 10:58:45 +02:00
: base ( content , publishedValueFallback )
2020-09-08 15:17:57 +02:00
{
2021-02-09 10:22:42 +01:00
_publishedValueFallback = publishedValueFallback ;
2020-09-08 15:17:57 +02:00
}
2019-10-28 18:02:52 +11:00
// properties
2022-06-21 08:09:38 +02:00
[ global :: System . CodeDom . Compiler . GeneratedCodeAttribute ( "" Umbraco . ModelsBuilder . Embedded "" , "" " + version +
@"" ")]
2021-07-13 10:15:03 +02:00
[global::System.Diagnostics.CodeAnalysis.MaybeNull]
2019-10-28 18:02:52 +11:00
[ImplementPropertyType(""foo"")]
2022-06-21 08:09:38 +02:00
public virtual global :: System . Collections . Generic . IEnumerable < global :: " + modelsBuilderConfig.ModelsNamespace +
@".Foo> Foo => this.Value<global::System.Collections.Generic.IEnumerable<global::" +
modelsBuilderConfig . ModelsNamespace + @".Foo>>(_publishedValueFallback, ""foo" ");
2019-10-28 18:02:52 +11:00
}
}
";
2022-06-21 08:09:38 +02:00
Console . WriteLine ( gen ) ;
Assert . AreEqual ( expected . ClearLf ( ) , gen ) ;
}
[Test]
public void GenerateAmbiguous ( )
{
var type1 = new TypeModel
{
Id = 1 ,
Alias = "type1" ,
ClrName = "Type1" ,
ParentId = 0 ,
BaseType = null ,
ItemType = TypeModel . ItemTypes . Content ,
IsMixin = true ,
} ;
type1 . Properties . Add ( new PropertyModel
{
Alias = "prop1" ,
ClrName = "Prop1" ,
ModelClrType = typeof ( IPublishedContent ) ,
} ) ;
type1 . Properties . Add ( new PropertyModel
{
Alias = "prop2" ,
ClrName = "Prop2" ,
ModelClrType = typeof ( StringBuilder ) ,
} ) ;
type1 . Properties . Add ( new PropertyModel
{
Alias = "prop3" ,
ClrName = "Prop3" ,
ModelClrType = typeof ( BootFailedException ) ,
} ) ;
TypeModel [ ] types = { type1 } ;
var modelsBuilderConfig = new ModelsBuilderSettings ( ) ;
var builder = new TextBuilder ( modelsBuilderConfig , types )
{
ModelsNamespace = "Umbraco.ModelsBuilder.Models" , // forces conflict with Umbraco.ModelsBuilder.Umbraco
} ;
2019-10-28 18:02:52 +11:00
2022-06-21 08:09:38 +02:00
var sb = new StringBuilder ( ) ;
foreach ( var model in builder . GetModelsToGenerate ( ) )
2019-10-28 18:02:52 +11:00
{
2022-06-21 08:09:38 +02:00
builder . Generate ( sb , model ) ;
2019-10-28 18:02:52 +11:00
}
2022-06-21 08:09:38 +02:00
var gen = sb . ToString ( ) ;
Console . WriteLine ( gen ) ;
Assert . IsTrue ( gen . Contains ( " global::Umbraco.Cms.Core.Models.PublishedContent.IPublishedContent Prop1" ) ) ;
Assert . IsTrue ( gen . Contains ( " global::System.Text.StringBuilder Prop2" ) ) ;
Assert . IsTrue ( gen . Contains ( " global::Umbraco.Cms.Core.Exceptions.BootFailedException Prop3" ) ) ;
}
[Test]
public void GenerateInheritedType ( )
{
var parentType = new TypeModel
{
Id = 1 ,
Alias = "parentType" ,
ClrName = "ParentType" ,
Name = "parentTypeName" ,
ParentId = 0 ,
IsParent = true ,
BaseType = null ,
ItemType = TypeModel . ItemTypes . Content ,
} ;
parentType . Properties . Add ( new PropertyModel
2021-11-03 13:05:43 +01:00
{
2022-06-21 08:09:38 +02:00
Alias = "prop1" ,
ClrName = "Prop1" ,
Name = "prop1Name" ,
ModelClrType = typeof ( string ) ,
} ) ;
var childType = new TypeModel
{
Id = 2 ,
Alias = "childType" ,
ClrName = "ChildType" ,
Name = "childTypeName" ,
ParentId = 1 ,
BaseType = parentType ,
ItemType = TypeModel . ItemTypes . Content ,
} ;
TypeModel [ ] docTypes = { parentType , childType } ;
var modelsBuilderConfig = new ModelsBuilderSettings ( ) ;
var builder = new TextBuilder ( modelsBuilderConfig , docTypes ) ;
var sb = new StringBuilder ( ) ;
builder . Generate ( sb , builder . GetModelsToGenerate ( ) . First ( ) ) ;
var genParent = sb . ToString ( ) ;
var version = ApiVersion . Current . Version ;
var expectedParent = @ "//------------------------------------------------------------------------------
2021-11-03 13:05:43 +01:00
// <auto-generated>
// This code was generated by a tool.
//
// Umbraco.ModelsBuilder.Embedded v" + version + @"
//
// Changes to this file will be lost if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System ;
using System.Linq.Expressions ;
using Umbraco.Cms.Core.Models.PublishedContent ;
using Umbraco.Cms.Core.PublishedCache ;
using Umbraco.Cms.Infrastructure.ModelsBuilder ;
using Umbraco.Cms.Core ;
using Umbraco.Extensions ;
namespace Umbraco.Cms.Web.Common.PublishedModels
{
/// <summary>parentTypeName</summary>
[PublishedModel(""parentType"")]
public partial class ParentType : PublishedContentModel
{
// helpers
#pragma warning disable 0109 // new is redundant
2022-06-21 08:09:38 +02:00
[ global :: System . CodeDom . Compiler . GeneratedCodeAttribute ( "" Umbraco . ModelsBuilder . Embedded "" , "" " + version +
@"" ")]
2021-11-03 13:05:43 +01:00
public new const string ModelTypeAlias = "" parentType "" ;
2022-06-21 08:09:38 +02:00
[ global :: System . CodeDom . Compiler . GeneratedCodeAttribute ( "" Umbraco . ModelsBuilder . Embedded "" , "" " + version +
@"" ")]
2021-11-03 13:05:43 +01:00
public new const PublishedItemType ModelItemType = PublishedItemType . Content ;
2022-06-21 08:09:38 +02:00
[ global :: System . CodeDom . Compiler . GeneratedCodeAttribute ( "" Umbraco . ModelsBuilder . Embedded "" , "" " + version +
@"" ")]
2021-11-03 13:05:43 +01:00
[return: global::System.Diagnostics.CodeAnalysis.MaybeNull]
2024-10-01 15:03:02 +02:00
public new static IPublishedContentType GetModelContentType ( IPublishedContentTypeCache contentTypeCache )
= > PublishedModelUtility . GetModelContentType ( contentTypeCache , ModelItemType , ModelTypeAlias ) ;
2022-06-21 08:09:38 +02:00
[ global :: System . CodeDom . Compiler . GeneratedCodeAttribute ( "" Umbraco . ModelsBuilder . Embedded "" , "" " + version +
@"" ")]
2021-11-03 13:05:43 +01:00
[return: global::System.Diagnostics.CodeAnalysis.MaybeNull]
2024-10-01 15:03:02 +02:00
public static IPublishedPropertyType GetModelPropertyType < TValue > ( IPublishedContentTypeCache contentTypeCache , Expression < Func < ParentType , TValue > > selector )
= > PublishedModelUtility . GetModelPropertyType ( GetModelContentType ( contentTypeCache ) , selector ) ;
2021-11-03 13:05:43 +01:00
#pragma warning restore 0109
private IPublishedValueFallback _publishedValueFallback ;
// ctor
public ParentType ( IPublishedContent content , IPublishedValueFallback publishedValueFallback )
: base ( content , publishedValueFallback )
{
_publishedValueFallback = publishedValueFallback ;
}
// properties
///<summary>
/// prop1Name
///</summary>
2022-06-21 08:09:38 +02:00
[ global :: System . CodeDom . Compiler . GeneratedCodeAttribute ( "" Umbraco . ModelsBuilder . Embedded "" , "" " + version +
@"" ")]
2021-11-03 13:05:43 +01:00
[global::System.Diagnostics.CodeAnalysis.MaybeNull]
[ImplementPropertyType(""prop1"")]
public virtual string Prop1 = > this . Value < string > ( _publishedValueFallback , "" prop1 "" ) ;
}
}
";
2022-06-21 08:09:38 +02:00
Console . WriteLine ( genParent ) ;
Assert . AreEqual ( expectedParent . ClearLf ( ) , genParent ) ;
2021-11-03 13:05:43 +01:00
2022-06-21 08:09:38 +02:00
var sb2 = new StringBuilder ( ) ;
builder . Generate ( sb2 , builder . GetModelsToGenerate ( ) . Skip ( 1 ) . First ( ) ) ;
var genChild = sb2 . ToString ( ) ;
2021-11-03 13:05:43 +01:00
2022-06-21 08:09:38 +02:00
var expectedChild = @ "//------------------------------------------------------------------------------
2021-11-03 13:05:43 +01:00
// <auto-generated>
// This code was generated by a tool.
//
// Umbraco.ModelsBuilder.Embedded v" + version + @"
//
// Changes to this file will be lost if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System ;
using System.Linq.Expressions ;
using Umbraco.Cms.Core.Models.PublishedContent ;
using Umbraco.Cms.Core.PublishedCache ;
using Umbraco.Cms.Infrastructure.ModelsBuilder ;
using Umbraco.Cms.Core ;
using Umbraco.Extensions ;
namespace Umbraco.Cms.Web.Common.PublishedModels
{
/// <summary>childTypeName</summary>
[PublishedModel(""childType"")]
public partial class ChildType : ParentType
{
// helpers
#pragma warning disable 0109 // new is redundant
2022-06-21 08:09:38 +02:00
[ global :: System . CodeDom . Compiler . GeneratedCodeAttribute ( "" Umbraco . ModelsBuilder . Embedded "" , "" " + version +
@"" ")]
2021-11-03 13:05:43 +01:00
public new const string ModelTypeAlias = "" childType "" ;
2022-06-21 08:09:38 +02:00
[ global :: System . CodeDom . Compiler . GeneratedCodeAttribute ( "" Umbraco . ModelsBuilder . Embedded "" , "" " + version +
@"" ")]
2021-11-03 13:05:43 +01:00
public new const PublishedItemType ModelItemType = PublishedItemType . Content ;
2022-06-21 08:09:38 +02:00
[ global :: System . CodeDom . Compiler . GeneratedCodeAttribute ( "" Umbraco . ModelsBuilder . Embedded "" , "" " + version +
@"" ")]
2021-11-03 13:05:43 +01:00
[return: global::System.Diagnostics.CodeAnalysis.MaybeNull]
2024-10-01 15:03:02 +02:00
public new static IPublishedContentType GetModelContentType ( IPublishedContentTypeCache contentTypeCache )
= > PublishedModelUtility . GetModelContentType ( contentTypeCache , ModelItemType , ModelTypeAlias ) ;
2022-06-21 08:09:38 +02:00
[ global :: System . CodeDom . Compiler . GeneratedCodeAttribute ( "" Umbraco . ModelsBuilder . Embedded "" , "" " + version +
@"" ")]
2021-11-03 13:05:43 +01:00
[return: global::System.Diagnostics.CodeAnalysis.MaybeNull]
2024-10-01 15:03:02 +02:00
public static IPublishedPropertyType GetModelPropertyType < TValue > ( IPublishedContentTypeCache contentTypeCache , Expression < Func < ChildType , TValue > > selector )
= > PublishedModelUtility . GetModelPropertyType ( GetModelContentType ( contentTypeCache ) , selector ) ;
2021-11-03 13:05:43 +01:00
#pragma warning restore 0109
private IPublishedValueFallback _publishedValueFallback ;
// ctor
public ChildType ( IPublishedContent content , IPublishedValueFallback publishedValueFallback )
: base ( content , publishedValueFallback )
{
_publishedValueFallback = publishedValueFallback ;
}
// properties
}
}
";
2022-06-21 08:09:38 +02:00
Console . WriteLine ( genChild ) ;
Assert . AreEqual ( expectedChild . ClearLf ( ) , genChild ) ;
}
2021-11-03 13:05:43 +01:00
2022-06-21 08:09:38 +02:00
[Test]
public void GenerateComposedType ( )
{
// Umbraco returns nice, pascal-cased names.
var composition1 = new TypeModel
{
Id = 2 ,
Alias = "composition1" ,
ClrName = "Composition1" ,
Name = "composition1Name" ,
ParentId = 0 ,
BaseType = null ,
ItemType = TypeModel . ItemTypes . Content ,
IsMixin = true ,
} ;
composition1 . Properties . Add ( new PropertyModel
2021-11-03 13:05:43 +01:00
{
2022-06-21 08:09:38 +02:00
Alias = "compositionProp" ,
ClrName = "CompositionProp" ,
Name = "compositionPropName" ,
ModelClrType = typeof ( string ) ,
ClrTypeName = typeof ( string ) . FullName ,
} ) ;
var type1 = new TypeModel
{
Id = 1 ,
Alias = "type1" ,
ClrName = "Type1" ,
Name = "type1Name" ,
ParentId = 0 ,
BaseType = null ,
ItemType = TypeModel . ItemTypes . Content ,
} ;
type1 . Properties . Add ( new PropertyModel
{
Alias = "prop1" ,
ClrName = "Prop1" ,
Name = "prop1Name" ,
ModelClrType = typeof ( string ) ,
} ) ;
type1 . MixinTypes . Add ( composition1 ) ;
TypeModel [ ] types = { type1 , composition1 } ;
var modelsBuilderConfig = new ModelsBuilderSettings ( ) ;
var builder = new TextBuilder ( modelsBuilderConfig , types ) ;
var version = ApiVersion . Current . Version ;
var sb = new StringBuilder ( ) ;
builder . Generate ( sb , builder . GetModelsToGenerate ( ) . First ( ) ) ;
var genComposed = sb . ToString ( ) ;
var expectedComposed = @ "//------------------------------------------------------------------------------
2021-11-03 13:05:43 +01:00
// <auto-generated>
// This code was generated by a tool.
//
// Umbraco.ModelsBuilder.Embedded v" + version + @"
//
// Changes to this file will be lost if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System ;
using System.Linq.Expressions ;
using Umbraco.Cms.Core.Models.PublishedContent ;
using Umbraco.Cms.Core.PublishedCache ;
using Umbraco.Cms.Infrastructure.ModelsBuilder ;
using Umbraco.Cms.Core ;
using Umbraco.Extensions ;
namespace Umbraco.Cms.Web.Common.PublishedModels
{
/// <summary>type1Name</summary>
[PublishedModel(""type1"")]
public partial class Type1 : PublishedContentModel , IComposition1
{
// helpers
#pragma warning disable 0109 // new is redundant
2022-06-21 08:09:38 +02:00
[ global :: System . CodeDom . Compiler . GeneratedCodeAttribute ( "" Umbraco . ModelsBuilder . Embedded "" , "" " + version +
@"" ")]
2021-11-03 13:05:43 +01:00
public new const string ModelTypeAlias = "" type1 "" ;
2022-06-21 08:09:38 +02:00
[ global :: System . CodeDom . Compiler . GeneratedCodeAttribute ( "" Umbraco . ModelsBuilder . Embedded "" , "" " + version +
@"" ")]
2021-11-03 13:05:43 +01:00
public new const PublishedItemType ModelItemType = PublishedItemType . Content ;
2022-06-21 08:09:38 +02:00
[ global :: System . CodeDom . Compiler . GeneratedCodeAttribute ( "" Umbraco . ModelsBuilder . Embedded "" , "" " + version +
@"" ")]
2021-11-03 13:05:43 +01:00
[return: global::System.Diagnostics.CodeAnalysis.MaybeNull]
2024-10-01 15:03:02 +02:00
public new static IPublishedContentType GetModelContentType ( IPublishedContentTypeCache contentTypeCache )
= > PublishedModelUtility . GetModelContentType ( contentTypeCache , ModelItemType , ModelTypeAlias ) ;
2022-06-21 08:09:38 +02:00
[ global :: System . CodeDom . Compiler . GeneratedCodeAttribute ( "" Umbraco . ModelsBuilder . Embedded "" , "" " + version +
@"" ")]
2021-11-03 13:05:43 +01:00
[return: global::System.Diagnostics.CodeAnalysis.MaybeNull]
2024-10-01 15:03:02 +02:00
public static IPublishedPropertyType GetModelPropertyType < TValue > ( IPublishedContentTypeCache contentTypeCache , Expression < Func < Type1 , TValue > > selector )
= > PublishedModelUtility . GetModelPropertyType ( GetModelContentType ( contentTypeCache ) , selector ) ;
2021-11-03 13:05:43 +01:00
#pragma warning restore 0109
private IPublishedValueFallback _publishedValueFallback ;
// ctor
public Type1 ( IPublishedContent content , IPublishedValueFallback publishedValueFallback )
: base ( content , publishedValueFallback )
{
_publishedValueFallback = publishedValueFallback ;
}
// properties
///<summary>
/// prop1Name
///</summary>
2022-06-21 08:09:38 +02:00
[ global :: System . CodeDom . Compiler . GeneratedCodeAttribute ( "" Umbraco . ModelsBuilder . Embedded "" , "" " + version +
@"" ")]
2021-11-03 13:05:43 +01:00
[global::System.Diagnostics.CodeAnalysis.MaybeNull]
[ImplementPropertyType(""prop1"")]
public virtual string Prop1 = > this . Value < string > ( _publishedValueFallback , "" prop1 "" ) ;
///<summary>
/// compositionPropName
///</summary>
2022-06-21 08:09:38 +02:00
[ global :: System . CodeDom . Compiler . GeneratedCodeAttribute ( "" Umbraco . ModelsBuilder . Embedded "" , "" " + version +
@"" ")]
2021-11-03 13:05:43 +01:00
[global::System.Diagnostics.CodeAnalysis.MaybeNull]
[ImplementPropertyType(""compositionProp"")]
public virtual string CompositionProp = > global :: Umbraco . Cms . Web . Common . PublishedModels . Composition1 . GetCompositionProp ( this , _publishedValueFallback ) ;
}
}
";
2022-06-21 08:09:38 +02:00
Console . WriteLine ( genComposed ) ;
Assert . AreEqual ( expectedComposed . ClearLf ( ) , genComposed ) ;
2021-11-03 13:05:43 +01:00
2022-06-21 08:09:38 +02:00
var sb2 = new StringBuilder ( ) ;
builder . Generate ( sb2 , builder . GetModelsToGenerate ( ) . Skip ( 1 ) . First ( ) ) ;
var genComposition = sb2 . ToString ( ) ;
2021-11-03 13:05:43 +01:00
2022-06-21 08:09:38 +02:00
var expectedComposition = @ "//------------------------------------------------------------------------------
2021-11-03 13:05:43 +01:00
// <auto-generated>
// This code was generated by a tool.
//
// Umbraco.ModelsBuilder.Embedded v" + version + @"
//
// Changes to this file will be lost if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System ;
using System.Linq.Expressions ;
using Umbraco.Cms.Core.Models.PublishedContent ;
using Umbraco.Cms.Core.PublishedCache ;
using Umbraco.Cms.Infrastructure.ModelsBuilder ;
using Umbraco.Cms.Core ;
using Umbraco.Extensions ;
namespace Umbraco.Cms.Web.Common.PublishedModels
{
// Mixin Content Type with alias ""composition1""
/// <summary>composition1Name</summary>
public partial interface IComposition1 : IPublishedContent
{
/// <summary>compositionPropName</summary>
2022-06-21 08:09:38 +02:00
[ global :: System . CodeDom . Compiler . GeneratedCodeAttribute ( "" Umbraco . ModelsBuilder . Embedded "" , "" " + version +
@"" ")]
2021-11-03 13:05:43 +01:00
[global::System.Diagnostics.CodeAnalysis.MaybeNull]
string CompositionProp { get ; }
}
/// <summary>composition1Name</summary>
[PublishedModel(""composition1"")]
public partial class Composition1 : PublishedContentModel , IComposition1
{
// helpers
#pragma warning disable 0109 // new is redundant
2022-06-21 08:09:38 +02:00
[ global :: System . CodeDom . Compiler . GeneratedCodeAttribute ( "" Umbraco . ModelsBuilder . Embedded "" , "" " + version +
@"" ")]
2021-11-03 13:05:43 +01:00
public new const string ModelTypeAlias = "" composition1 "" ;
2022-06-21 08:09:38 +02:00
[ global :: System . CodeDom . Compiler . GeneratedCodeAttribute ( "" Umbraco . ModelsBuilder . Embedded "" , "" " + version +
@"" ")]
2021-11-03 13:05:43 +01:00
public new const PublishedItemType ModelItemType = PublishedItemType . Content ;
2022-06-21 08:09:38 +02:00
[ global :: System . CodeDom . Compiler . GeneratedCodeAttribute ( "" Umbraco . ModelsBuilder . Embedded "" , "" " + version +
@"" ")]
2021-11-03 13:05:43 +01:00
[return: global::System.Diagnostics.CodeAnalysis.MaybeNull]
2024-10-01 15:03:02 +02:00
public new static IPublishedContentType GetModelContentType ( IPublishedContentTypeCache contentTypeCache )
= > PublishedModelUtility . GetModelContentType ( contentTypeCache , ModelItemType , ModelTypeAlias ) ;
2022-06-21 08:09:38 +02:00
[ global :: System . CodeDom . Compiler . GeneratedCodeAttribute ( "" Umbraco . ModelsBuilder . Embedded "" , "" " + version +
@"" ")]
2021-11-03 13:05:43 +01:00
[return: global::System.Diagnostics.CodeAnalysis.MaybeNull]
2024-10-01 15:03:02 +02:00
public static IPublishedPropertyType GetModelPropertyType < TValue > ( IPublishedContentTypeCache contentTypeCache , Expression < Func < Composition1 , TValue > > selector )
= > PublishedModelUtility . GetModelPropertyType ( GetModelContentType ( contentTypeCache ) , selector ) ;
2021-11-03 13:05:43 +01:00
#pragma warning restore 0109
private IPublishedValueFallback _publishedValueFallback ;
// ctor
public Composition1 ( IPublishedContent content , IPublishedValueFallback publishedValueFallback )
: base ( content , publishedValueFallback )
{
_publishedValueFallback = publishedValueFallback ;
}
// properties
///<summary>
/// compositionPropName
///</summary>
2022-06-21 08:09:38 +02:00
[ global :: System . CodeDom . Compiler . GeneratedCodeAttribute ( "" Umbraco . ModelsBuilder . Embedded "" , "" " + version +
@"" ")]
2021-11-03 13:05:43 +01:00
[global::System.Diagnostics.CodeAnalysis.MaybeNull]
[ImplementPropertyType(""compositionProp"")]
public virtual string CompositionProp = > GetCompositionProp ( this , _publishedValueFallback ) ;
/// <summary>Static getter for compositionPropName</summary>
2022-06-21 08:09:38 +02:00
[ global :: System . CodeDom . Compiler . GeneratedCodeAttribute ( "" Umbraco . ModelsBuilder . Embedded "" , "" " + version +
@"" ")]
2021-11-03 13:05:43 +01:00
[return: global::System.Diagnostics.CodeAnalysis.MaybeNull]
public static string GetCompositionProp ( IComposition1 that , IPublishedValueFallback publishedValueFallback ) = > that . Value < string > ( publishedValueFallback , "" compositionProp "" ) ;
}
}
";
2022-06-21 08:09:38 +02:00
Console . WriteLine ( genComposition ) ;
Assert . AreEqual ( expectedComposition . ClearLf ( ) , genComposition ) ;
}
2019-10-28 18:02:52 +11:00
2022-06-21 08:09:38 +02:00
[TestCase("int", typeof(int))]
[TestCase("global::System.Collections.Generic.IEnumerable<int>", typeof(IEnumerable<int>))]
[TestCase("global::Umbraco.Cms.Tests.UnitTests.Umbraco.ModelsBuilder.Embedded.BuilderTestsClass1", typeof(BuilderTestsClass1))]
[TestCase("global::Umbraco.Cms.Tests.UnitTests.Umbraco.ModelsBuilder.Embedded.BuilderTests.Class1", typeof(Class1))]
public void WriteClrType ( string expected , Type input )
{
// note - these assertions differ from the original tests in MB because in the embedded version, the result of Builder.IsAmbiguousSymbol is always true
// which means global:: syntax will be applied to most things
var builder = new TextBuilder { ModelsNamespaceForTests = "ModelsNamespace" } ;
var sb = new StringBuilder ( ) ;
builder . WriteClrType ( sb , input ) ;
Assert . AreEqual ( expected , sb . ToString ( ) ) ;
}
2019-10-28 18:02:52 +11:00
2022-06-21 08:09:38 +02:00
[TestCase("int", typeof(int))]
[TestCase("global::System.Collections.Generic.IEnumerable<int>", typeof(IEnumerable<int>))]
[TestCase("global::Umbraco.Cms.Tests.UnitTests.Umbraco.ModelsBuilder.Embedded.BuilderTestsClass1", typeof(BuilderTestsClass1))]
[TestCase("global::Umbraco.Cms.Tests.UnitTests.Umbraco.ModelsBuilder.Embedded.BuilderTests.Class1", typeof(Class1))]
public void WriteClrTypeUsing ( string expected , Type input )
{
// note - these assertions differ from the original tests in MB because in the embedded version, the result of Builder.IsAmbiguousSymbol is always true
// which means global:: syntax will be applied to most things
var builder = new TextBuilder ( ) ;
builder . Using . Add ( "Umbraco.Cms.Tests.UnitTests.Umbraco.ModelsBuilder" ) ;
builder . ModelsNamespaceForTests = "ModelsNamespace" ;
var sb = new StringBuilder ( ) ;
builder . WriteClrType ( sb , input ) ;
Assert . AreEqual ( expected , sb . ToString ( ) ) ;
}
2019-10-28 18:02:52 +11:00
2022-06-21 08:09:38 +02:00
[Test]
public void WriteClrType_WithUsing ( )
{
var builder = new TextBuilder ( ) ;
builder . Using . Add ( "System.Text" ) ;
builder . ModelsNamespaceForTests = "Umbraco.Tests.UnitTests.Umbraco.ModelsBuilder.Models" ;
var sb = new StringBuilder ( ) ;
builder . WriteClrType ( sb , typeof ( StringBuilder ) ) ;
// note - these assertions differ from the original tests in MB because in the embedded version, the result of Builder.IsAmbiguousSymbol is always true
// which means global:: syntax will be applied to most things
Assert . AreEqual ( "global::System.Text.StringBuilder" , sb . ToString ( ) ) ;
}
2019-10-28 18:02:52 +11:00
2022-06-21 08:09:38 +02:00
[Test]
public void WriteClrTypeAnother_WithoutUsing ( )
{
var builder = new TextBuilder
2019-10-28 18:02:52 +11:00
{
2022-06-21 08:09:38 +02:00
ModelsNamespaceForTests = "Umbraco.Tests.UnitTests.Umbraco.ModelsBuilder.Models" ,
} ;
var sb = new StringBuilder ( ) ;
builder . WriteClrType ( sb , typeof ( StringBuilder ) ) ;
Assert . AreEqual ( "global::System.Text.StringBuilder" , sb . ToString ( ) ) ;
}
2019-10-28 18:02:52 +11:00
2022-06-21 08:09:38 +02:00
[Test]
public void WriteClrType_Ambiguous1 ( )
{
var builder = new TextBuilder ( ) ;
builder . Using . Add ( "System.Text" ) ;
builder . Using . Add ( "Umbraco.Tests.UnitTests.Umbraco.ModelsBuilder.Embedded" ) ;
builder . ModelsNamespaceForTests = "SomeRandomNamespace" ;
var sb = new StringBuilder ( ) ;
builder . WriteClrType ( sb , typeof ( global :: System . Text . ASCIIEncoding ) ) ;
// note - these assertions differ from the original tests in MB because in the embedded version, the result of Builder.IsAmbiguousSymbol is always true
// which means global:: syntax will be applied to most things
Assert . AreEqual ( "global::System.Text.ASCIIEncoding" , sb . ToString ( ) ) ;
}
2019-10-28 18:02:52 +11:00
2022-06-21 08:09:38 +02:00
[Test]
public void WriteClrType_Ambiguous ( )
{
var builder = new TextBuilder ( ) ;
builder . Using . Add ( "System.Text" ) ;
builder . Using . Add ( "Umbraco.Tests.UnitTests.Umbraco.ModelsBuilder.Embedded" ) ;
builder . ModelsNamespaceForTests = "SomeBorkedNamespace" ;
var sb = new StringBuilder ( ) ;
builder . WriteClrType ( sb , typeof ( global :: System . Text . ASCIIEncoding ) ) ;
// note - these assertions differ from the original tests in MB because in the embedded version, the result of Builder.IsAmbiguousSymbol is always true
// which means global:: syntax will be applied to most things
Assert . AreEqual ( "global::System.Text.ASCIIEncoding" , sb . ToString ( ) ) ;
}
2019-10-28 18:02:52 +11:00
2022-06-21 08:09:38 +02:00
[Test]
public void WriteClrType_Ambiguous2 ( )
{
var builder = new TextBuilder ( ) ;
builder . Using . Add ( "System.Text" ) ;
builder . Using . Add ( "Umbraco.Cms.Tests.UnitTests.Umbraco.ModelsBuilder.Embedded" ) ;
builder . ModelsNamespaceForTests = "SomeRandomNamespace" ;
var sb = new StringBuilder ( ) ;
builder . WriteClrType ( sb , typeof ( ASCIIEncoding ) ) ;
// note - these assertions differ from the original tests in MB because in the embedded version, the result of Builder.IsAmbiguousSymbol is always true
// which means global:: syntax will be applied to most things
Assert . AreEqual ( "global::Umbraco.Cms.Tests.UnitTests.Umbraco.ModelsBuilder.Embedded.ASCIIEncoding" , sb . ToString ( ) ) ;
}
2019-10-28 18:02:52 +11:00
2022-06-21 08:09:38 +02:00
[Test]
public void WriteClrType_AmbiguousNot ( )
{
var builder = new TextBuilder ( ) ;
builder . Using . Add ( "System.Text" ) ;
builder . Using . Add ( "Umbraco.Cms.Tests.UnitTests.Umbraco.ModelsBuilder.Embedded" ) ;
builder . ModelsNamespaceForTests = "Umbraco.Cms.Tests.UnitTests.Umbraco.ModelsBuilder.Models" ;
var sb = new StringBuilder ( ) ;
builder . WriteClrType ( sb , typeof ( ASCIIEncoding ) ) ;
// note - these assertions differ from the original tests in MB because in the embedded version, the result of Builder.IsAmbiguousSymbol is always true
// which means global:: syntax will be applied to most things
Assert . AreEqual ( "global::Umbraco.Cms.Tests.UnitTests.Umbraco.ModelsBuilder.Embedded.ASCIIEncoding" , sb . ToString ( ) ) ;
2019-10-28 18:02:52 +11:00
}
2022-06-21 08:09:38 +02:00
[Test]
public void WriteClrType_AmbiguousWithNested ( )
2019-10-28 18:02:52 +11:00
{
2022-06-21 08:09:38 +02:00
var builder = new TextBuilder ( ) ;
builder . Using . Add ( "System.Text" ) ;
builder . Using . Add ( "Umbraco.Cms.Tests.UnitTests.Umbraco.ModelsBuilder.Embedded" ) ;
builder . ModelsNamespaceForTests = "SomeRandomNamespace" ;
var sb = new StringBuilder ( ) ;
builder . WriteClrType ( sb , typeof ( ASCIIEncoding . Nested ) ) ;
// note - these assertions differ from the original tests in MB because in the embedded version, the result of Builder.IsAmbiguousSymbol is always true
// which means global:: syntax will be applied to most things
Assert . AreEqual ( "global::Umbraco.Cms.Tests.UnitTests.Umbraco.ModelsBuilder.Embedded.ASCIIEncoding.Nested" , sb . ToString ( ) ) ;
2019-10-28 18:02:52 +11:00
}
2022-06-21 08:09:38 +02:00
public class Class1
2020-12-20 08:36:11 +01:00
{
}
2022-06-21 08:09:38 +02:00
}
2019-10-28 18:02:52 +11:00
2022-06-21 08:09:38 +02:00
// make it public to be ambiguous (see above)
public class ASCIIEncoding
{
// can we handle nested types?
public class Nested
2020-12-20 08:36:11 +01:00
{
}
2019-10-28 18:02:52 +11:00
}
2022-06-21 08:09:38 +02:00
public class BuilderTestsClass1
{
}
public class System
{
}