-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/KostovMartin/Dapper.Bulk
- Loading branch information
Showing
4 changed files
with
83 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel.DataAnnotations; | ||
using System.ComponentModel.DataAnnotations.Schema; | ||
using System.Linq; | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace Dapper.Bulk.Tests | ||
{ | ||
public class GuidTests : SqlServerTestSuite | ||
{ | ||
[Fact] | ||
public void InsertBulk() | ||
{ | ||
var data = new List<PETranslationPhrase>(); | ||
for (var i = 0; i < 10; i++) | ||
{ | ||
data.Add(new PETranslationPhrase { | ||
TranslationId = i, | ||
CultureName = i.ToString(), | ||
Phrase = i.ToString(), | ||
PhraseHash = i % 2 == 0 ? Guid.NewGuid() : (Guid?)null, | ||
RowAddedDateTime = DateTime.UtcNow | ||
}); | ||
} | ||
|
||
using (var connection = this.GetConnection()) | ||
{ | ||
connection.Open(); | ||
var inserted = connection.BulkInsertAndSelect(data).ToList(); | ||
for (var i = 0; i < data.Count; i++) | ||
{ | ||
IsValidInsert(inserted[i], data[i]); | ||
} | ||
} | ||
} | ||
|
||
private static void IsValidInsert(PETranslationPhrase inserted, PETranslationPhrase toBeInserted) | ||
{ | ||
inserted.TranslationId.Should().BePositive(); | ||
inserted.CultureName.Should().Be(toBeInserted.CultureName); | ||
inserted.Phrase.Should().Be(toBeInserted.Phrase); | ||
inserted.PhraseHash.Should().Be(toBeInserted.PhraseHash); | ||
inserted.RowAddedDateTime.Should().Be(toBeInserted.RowAddedDateTime); | ||
} | ||
|
||
[Table("PE_TranslationPhrase")] | ||
public class PETranslationPhrase | ||
{ | ||
[Key] | ||
public virtual int TranslationId { get; set; } | ||
|
||
public virtual string CultureName { get; set; } | ||
|
||
public virtual string Phrase { get; set; } | ||
|
||
public virtual Guid? PhraseHash { get; set; } | ||
|
||
public virtual DateTime RowAddedDateTime { get; set; } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters