public void BuildMergeDataOutputTests() { var definition = new DataMergeDefinition(); DataMergeDefinition.AutoMap <UserImport>(definition); definition.Columns.Should().NotBeNullOrEmpty(); definition.IncludeOutput = true; definition.TargetTable = "dbo.User"; var column = definition.Columns.Find(c => c.SourceColumn == "EmailAddress"); column.Should().NotBeNull(); column.IsKey = true; column.CanUpdate = false; var users = new List <UserImport> { new UserImport { EmailAddress = "*****@*****.**", DisplayName = "Test User", FirstName = "Test", LastName = "User" }, new UserImport { EmailAddress = "*****@*****.**", DisplayName = "Blah User", FirstName = "Blah", LastName = "User" }, new UserImport { EmailAddress = $"random.{DateTime.Now.Ticks}@email.com", DisplayName = "Random User", FirstName = "Random", LastName = "User" } }; var dataTable = users.ToDataTable(); var sql = DataMergeGenerator.BuildMerge(definition, dataTable); sql.Should().NotBeNullOrEmpty(); Output.WriteLine("MergeStatement:"); Output.WriteLine(sql); }
public void ParseIdentifier() { string result = DataMergeGenerator.ParseIdentifier("[Name]"); result.Should().Be("Name"); result = DataMergeGenerator.ParseIdentifier("[Name"); result.Should().Be("[Name"); result = DataMergeGenerator.ParseIdentifier("Name]"); result.Should().Be("Name]"); result = DataMergeGenerator.ParseIdentifier("[Nam]e]"); result.Should().Be("Nam]e"); result = DataMergeGenerator.ParseIdentifier("[]"); result.Should().Be(""); result = DataMergeGenerator.ParseIdentifier("B"); result.Should().Be("B"); }
public void BuildMergeTests() { var definition = new DataMergeDefinition(); DataMergeDefinition.AutoMap <UserImport>(definition); definition.Columns.Should().NotBeNullOrEmpty(); definition.TargetTable = "dbo.User"; var column = definition.Columns.Find(c => c.SourceColumn == "EmailAddress"); column.Should().NotBeNull(); column.IsKey = true; column.CanUpdate = false; var sql = DataMergeGenerator.BuildMerge(definition); sql.Should().NotBeNullOrEmpty(); Output.WriteLine("MergeStatement:"); Output.WriteLine(sql); }
public void QuoteIdentifier() { string result = DataMergeGenerator.QuoteIdentifier("[Name]"); result.Should().Be("[Name]"); result = DataMergeGenerator.QuoteIdentifier("Name"); result.Should().Be("[Name]"); result = DataMergeGenerator.QuoteIdentifier("[Name"); result.Should().Be("[[Name]"); result = DataMergeGenerator.QuoteIdentifier("Name]"); result.Should().Be("[Name]]]"); result = DataMergeGenerator.QuoteIdentifier("Nam]e"); result.Should().Be("[Nam]]e]"); result = DataMergeGenerator.QuoteIdentifier(""); result.Should().Be("[]"); result = DataMergeGenerator.QuoteIdentifier("B"); result.Should().Be("[B]"); }