-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate to .NET Standard 2.0 to use in .NET Core versions
- Loading branch information
Showing
40 changed files
with
2,176 additions
and
2,419 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,73 +1,71 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
using Ploeh.AutoFixture; | ||
using Ploeh.AutoFixture.Kernel; | ||
using AutoFixture; | ||
using AutoFixture.Kernel; | ||
using SqlBulkTools.IntegrationTests.Model; | ||
|
||
namespace SqlBulkTools.IntegrationTests | ||
{ | ||
namespace SqlBulkTools.IntegrationTests; | ||
#pragma warning disable 618 | ||
public class BookRandomizer | ||
public class BookRandomizer | ||
{ | ||
public List<Book> GetRandomCollection(int count) | ||
{ | ||
|
||
public List<Book> GetRandomCollection(int count) | ||
{ | ||
var fixture = new Fixture(); | ||
fixture.Customizations.Add(new PriceBuilder()); | ||
fixture.Customizations.Add(new IsbnBuilder()); | ||
fixture.Customizations.Add(new TitleBuilder()); | ||
List<Book> books = new List<Book>(); | ||
books = fixture.Build<Book>().Without(x => x.Id).CreateMany(count).ToList(); | ||
return books; | ||
} | ||
|
||
var fixture = new Fixture(); | ||
fixture.Customizations.Add(new PriceBuilder()); | ||
fixture.Customizations.Add(new IsbnBuilder()); | ||
fixture.Customizations.Add(new TitleBuilder()); | ||
var books = new List<Book>(); | ||
books = fixture.Build<Book>().Without(x => x.Id).CreateMany(count).ToList(); | ||
return books; | ||
} | ||
} | ||
|
||
public class PriceBuilder : ISpecimenBuilder | ||
public class PriceBuilder : ISpecimenBuilder | ||
{ | ||
public object Create(object request, ISpecimenContext context) | ||
{ | ||
public object Create(object request, ISpecimenContext context) | ||
{ | ||
var pi = request as PropertyInfo; | ||
if (pi == null || | ||
pi.Name != "Price" || | ||
pi.PropertyType != typeof(decimal)) | ||
return new NoSpecimen(request); | ||
var pi = request as PropertyInfo; | ||
if (pi == null || | ||
pi.Name != "Price" || | ||
pi.PropertyType != typeof(decimal)) | ||
return new NoSpecimen(); | ||
|
||
return context.Resolve( | ||
new RangedNumberRequest(typeof(decimal), 1.0m, 268.5m)); | ||
} | ||
return context.Resolve( | ||
new RangedNumberRequest(typeof(decimal), 1.0m, 268.5m)); | ||
} | ||
} | ||
|
||
public class IsbnBuilder : ISpecimenBuilder | ||
public class IsbnBuilder : ISpecimenBuilder | ||
{ | ||
public object Create(object request, ISpecimenContext context) | ||
{ | ||
public object Create(object request, ISpecimenContext context) | ||
{ | ||
var pi = request as PropertyInfo; | ||
if (pi != null && | ||
pi.Name == "ISBN" && | ||
pi.PropertyType == typeof(string)) | ||
var pi = request as PropertyInfo; | ||
if (pi != null && | ||
pi.Name == "ISBN" && | ||
pi.PropertyType == typeof(string)) | ||
|
||
return context.Resolve(typeof(string)) | ||
.ToString().Substring(0, 13); | ||
.ToString() | ||
?.Substring(0, 13); | ||
|
||
return new NoSpecimen(request); | ||
} | ||
return new NoSpecimen(); | ||
} | ||
} | ||
|
||
public class TitleBuilder : ISpecimenBuilder | ||
public class TitleBuilder : ISpecimenBuilder | ||
{ | ||
public object Create(object request, ISpecimenContext context) | ||
{ | ||
public object Create(object request, ISpecimenContext context) | ||
{ | ||
var pi = request as PropertyInfo; | ||
if (pi != null && | ||
pi.Name == "Title" && | ||
pi.PropertyType == typeof(string)) | ||
var pi = request as PropertyInfo; | ||
if (pi != null && | ||
pi.Name == "Title" && | ||
pi.PropertyType == typeof(string)) | ||
|
||
return context.Resolve(typeof(string)) | ||
.ToString().Substring(0, 10); | ||
return context.Resolve(typeof(string)) | ||
.ToString() | ||
?.Substring(0, 10); | ||
|
||
return new NoSpecimen(request); | ||
} | ||
return new NoSpecimen(); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,33 +1,30 @@ | ||
using System; | ||
using System.ComponentModel.DataAnnotations; | ||
using System.ComponentModel.DataAnnotations.Schema; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace SqlBulkTools.IntegrationTests.Model | ||
{ | ||
public class Book | ||
{ | ||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] | ||
[Key] | ||
public int Id { get; set; } | ||
namespace SqlBulkTools.IntegrationTests.Model; | ||
|
||
[MaxLength(13)] | ||
[Index] | ||
public string ISBN { get; set; } | ||
[Index("ISBN", "Title", "Price")] | ||
public class Book | ||
{ | ||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] | ||
[Key] | ||
public int Id { get; set; } | ||
|
||
[MaxLength(256)] | ||
[Index] | ||
public string Title { get; set; } | ||
[MaxLength(13)] | ||
public string ISBN { get; set; } | ||
|
||
[MaxLength(2000)] | ||
public string Description { get; set; } | ||
[MaxLength(256)] | ||
public string Title { get; set; } | ||
|
||
public DateTime? PublishDate { get; set; } | ||
[MaxLength(2000)] | ||
public string Description { get; set; } | ||
|
||
[Required] | ||
[Index] | ||
public decimal? Price { get; set; } | ||
public DateTime? PublishDate { get; set; } | ||
|
||
public float? TestFloat { get; set; } | ||
} | ||
[Required] | ||
public decimal? Price { get; set; } | ||
|
||
} | ||
public float? TestFloat { 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
namespace SqlBulkTools.IntegrationTests.TestEnvironment | ||
namespace SqlBulkTools.IntegrationTests.TestEnvironment; | ||
|
||
internal class BookDto | ||
{ | ||
class BookDto | ||
{ | ||
public int Id { get; set; } | ||
} | ||
} | ||
public int Id { get; set; } | ||
} |
30 changes: 12 additions & 18 deletions
30
SqlBulkTools.IntegrationTests/Model/CustomColumnMappingTest.cs
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 |
---|---|---|
@@ -1,23 +1,17 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel.DataAnnotations; | ||
using System.ComponentModel.DataAnnotations; | ||
using System.ComponentModel.DataAnnotations.Schema; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace SqlBulkTools.IntegrationTests.Model | ||
namespace SqlBulkTools.IntegrationTests.Model; | ||
|
||
public class CustomColumnMappingTest | ||
{ | ||
public class CustomColumnMappingTest | ||
{ | ||
[DatabaseGenerated(DatabaseGeneratedOption.None)] | ||
[Key] | ||
public int NaturalId { get; set; } | ||
[DatabaseGenerated(DatabaseGeneratedOption.None)] | ||
[Key] | ||
public int NaturalId { get; set; } | ||
|
||
[Column("ColumnX"), StringLength(256)] | ||
public string ColumnXIsDifferent { get; set; } | ||
[Column("ColumnX")] [StringLength(256)] | ||
public string ColumnXIsDifferent { get; set; } | ||
|
||
[Column("ColumnY")] | ||
public int ColumnYIsDifferentInDatabase { get; set; } | ||
} | ||
} | ||
[Column("ColumnY")] | ||
public int ColumnYIsDifferentInDatabase { get; set; } | ||
} |
Oops, something went wrong.