using Util.Generators.Contexts; using Xunit; namespace Util.Generators.Tests.Contexts { /// /// 实体上下文测试 /// public class EntityContextTest { /// /// 测试复制 /// [Fact] public void TestClone() { //创建实体上下文 var generatorContext = new GeneratorContext { TemplateRootPath = "Templates", OutputRootPath = "Output" }; var projectContext = new ProjectContext( generatorContext ) { Name = "Project" }; var context = new EntityContext( projectContext, "a" ) { Schema = "TestSchema", Description = "TestDescription", Output = { Extension = ".txt" } }; //复制副本 var clone = context.Clone( projectContext ); //验证实体上下文 Assert.NotSame( context, clone ); Assert.Equal( context.Name, clone.Name ); Assert.Equal( context.Schema, clone.Schema ); Assert.Equal( context.Description, clone.Description ); //验证输出 Assert.Equal( @"Output/Project", clone.Output.RootPath.Replace( "\\","/" ) ); Assert.Equal( ".txt", clone.Output.Extension ); } } }