Skip to content

Commit

Permalink
Migrate to .NET Standard 2.0 to use in .NET Core versions
Browse files Browse the repository at this point in the history
  • Loading branch information
DungAT98 committed Oct 4, 2022
1 parent d33329b commit 0d960b5
Show file tree
Hide file tree
Showing 40 changed files with 2,176 additions and 2,419 deletions.
53 changes: 0 additions & 53 deletions Helpers/Helpers.csproj

This file was deleted.

36 changes: 0 additions & 36 deletions Helpers/Properties/AssemblyInfo.cs

This file was deleted.

21 changes: 0 additions & 21 deletions SqlBulkTools.IntegrationTests/App.config

This file was deleted.

98 changes: 48 additions & 50 deletions SqlBulkTools.IntegrationTests/BookRandomizer.cs
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();
}
}
}
31 changes: 0 additions & 31 deletions SqlBulkTools.IntegrationTests/Migrations/Configuration.cs

This file was deleted.

41 changes: 19 additions & 22 deletions SqlBulkTools.IntegrationTests/Model/Book.cs
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; }
}
11 changes: 5 additions & 6 deletions SqlBulkTools.IntegrationTests/Model/BookDto.cs
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 SqlBulkTools.IntegrationTests/Model/CustomColumnMappingTest.cs
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; }
}
Loading

0 comments on commit 0d960b5

Please sign in to comment.