From f11b090553dae13e966cddebe262c380d97fef80 Mon Sep 17 00:00:00 2001 From: bubibubi Date: Thu, 24 Aug 2017 12:03:08 +0200 Subject: [PATCH] Added some tests --- .../DataTypesTest.cs | 4 +- .../EFCore.Jet.Integration.Test.csproj | 8 +++ .../Model12_ComplexType/Model.cs | 2 + .../Model18_CompositeKeys/Model.cs | 2 + .../Model19_1_1/Model.cs | 3 + .../Model19_1_1/Test.cs | 2 +- .../Model59_StackOverflow_TPT_TPH/Model.cs | 2 +- .../Context.cs | 26 +++++++++ .../JetTest.cs | 15 +++++ .../Model.cs | 55 +++++++++++++++++++ .../Test.cs | 36 ++++++++++++ .../Model75_Enums/Context.cs | 12 ++++ .../Model75_Enums/JetTest.cs | 15 +++++ .../Model75_Enums/Model.cs | 21 +++++++ .../Model75_Enums/Test.cs | 24 ++++++++ 15 files changed, 223 insertions(+), 4 deletions(-) create mode 100644 test/EFCore.Jet.Integration.Test/Model74_ComplexTypeContained_Github9536/Context.cs create mode 100644 test/EFCore.Jet.Integration.Test/Model74_ComplexTypeContained_Github9536/JetTest.cs create mode 100644 test/EFCore.Jet.Integration.Test/Model74_ComplexTypeContained_Github9536/Model.cs create mode 100644 test/EFCore.Jet.Integration.Test/Model74_ComplexTypeContained_Github9536/Test.cs create mode 100644 test/EFCore.Jet.Integration.Test/Model75_Enums/Context.cs create mode 100644 test/EFCore.Jet.Integration.Test/Model75_Enums/JetTest.cs create mode 100644 test/EFCore.Jet.Integration.Test/Model75_Enums/Model.cs create mode 100644 test/EFCore.Jet.Integration.Test/Model75_Enums/Test.cs diff --git a/test/EFCore.Jet.Integration.Test/DataTypesTest.cs b/test/EFCore.Jet.Integration.Test/DataTypesTest.cs index 8cdc185..e42b5b1 100644 --- a/test/EFCore.Jet.Integration.Test/DataTypesTest.cs +++ b/test/EFCore.Jet.Integration.Test/DataTypesTest.cs @@ -34,10 +34,10 @@ namespace EFCore.Jet.Integration.Test public void Booleans() { - + // ReSharper disable ReturnValueOfPureMethodIsNotUsed - Context.TableWithSeveralFieldsTypes.Where(c => c.MyBool).Select(c => c.MyBool).First(); Context.TableWithSeveralFieldsTypes.Where(c => c.MyBool).Select(c => c.MyBool != false).First(); + Context.TableWithSeveralFieldsTypes.Where(c => c.MyBool).Select(c => c.MyBool).First(); // ReSharper restore ReturnValueOfPureMethodIsNotUsed } diff --git a/test/EFCore.Jet.Integration.Test/EFCore.Jet.Integration.Test.csproj b/test/EFCore.Jet.Integration.Test/EFCore.Jet.Integration.Test.csproj index 6c62e46..1156308 100644 --- a/test/EFCore.Jet.Integration.Test/EFCore.Jet.Integration.Test.csproj +++ b/test/EFCore.Jet.Integration.Test/EFCore.Jet.Integration.Test.csproj @@ -152,6 +152,14 @@ + + + + + + + + diff --git a/test/EFCore.Jet.Integration.Test/Model12_ComplexType/Model.cs b/test/EFCore.Jet.Integration.Test/Model12_ComplexType/Model.cs index 12b2773..5393df5 100644 --- a/test/EFCore.Jet.Integration.Test/Model12_ComplexType/Model.cs +++ b/test/EFCore.Jet.Integration.Test/Model12_ComplexType/Model.cs @@ -6,6 +6,7 @@ namespace EFCore.Jet.Integration.Test.Model12_ComplexType + [Table("Friend12")] public class Friend { public Friend() @@ -17,6 +18,7 @@ namespace EFCore.Jet.Integration.Test.Model12_ComplexType public FullAddress Address { get; set; } } + [Table("LessThanFriend12")] public class LessThanFriend { public LessThanFriend() diff --git a/test/EFCore.Jet.Integration.Test/Model18_CompositeKeys/Model.cs b/test/EFCore.Jet.Integration.Test/Model18_CompositeKeys/Model.cs index a936b97..2fedd59 100644 --- a/test/EFCore.Jet.Integration.Test/Model18_CompositeKeys/Model.cs +++ b/test/EFCore.Jet.Integration.Test/Model18_CompositeKeys/Model.cs @@ -4,6 +4,7 @@ using System.ComponentModel.DataAnnotations.Schema; namespace EFCore.Jet.Integration.Test.Model18_CompositeKeys { + [Table("GoodsIssueProcesses18")] public class GoodsIssueProcess { @@ -20,6 +21,7 @@ namespace EFCore.Jet.Integration.Test.Model18_CompositeKeys public Product Product { get; set; } } + [Table("Products18")] public class Product { // the unique ID of the product diff --git a/test/EFCore.Jet.Integration.Test/Model19_1_1/Model.cs b/test/EFCore.Jet.Integration.Test/Model19_1_1/Model.cs index dfe6684..91fa8d1 100644 --- a/test/EFCore.Jet.Integration.Test/Model19_1_1/Model.cs +++ b/test/EFCore.Jet.Integration.Test/Model19_1_1/Model.cs @@ -1,7 +1,9 @@ using System; +using System.ComponentModel.DataAnnotations.Schema; namespace EFCore.Jet.Integration.Test.Model19_1_1 { + [Table("ClassAs19")] public class ClassA { public int Id { get; set; } @@ -9,6 +11,7 @@ namespace EFCore.Jet.Integration.Test.Model19_1_1 public virtual ClassB ClassB { get; set; } } + [Table("ClassBs19")] public class ClassB { public int Id { get; set; } diff --git a/test/EFCore.Jet.Integration.Test/Model19_1_1/Test.cs b/test/EFCore.Jet.Integration.Test/Model19_1_1/Test.cs index be250e5..b9e9bb7 100644 --- a/test/EFCore.Jet.Integration.Test/Model19_1_1/Test.cs +++ b/test/EFCore.Jet.Integration.Test/Model19_1_1/Test.cs @@ -9,7 +9,7 @@ namespace EFCore.Jet.Integration.Test.Model19_1_1 [TestMethod] - public void Run() + public void Model19_1_1Run() { { ClassA classA; diff --git a/test/EFCore.Jet.Integration.Test/Model59_StackOverflow_TPT_TPH/Model.cs b/test/EFCore.Jet.Integration.Test/Model59_StackOverflow_TPT_TPH/Model.cs index cf76329..9b83050 100644 --- a/test/EFCore.Jet.Integration.Test/Model59_StackOverflow_TPT_TPH/Model.cs +++ b/test/EFCore.Jet.Integration.Test/Model59_StackOverflow_TPT_TPH/Model.cs @@ -44,7 +44,7 @@ namespace EFCore.Jet.Integration.Test.Model59_StackOverflow_TPT_TPH { A, B, - Caa + C } public enum DataCaptureActivityType diff --git a/test/EFCore.Jet.Integration.Test/Model74_ComplexTypeContained_Github9536/Context.cs b/test/EFCore.Jet.Integration.Test/Model74_ComplexTypeContained_Github9536/Context.cs new file mode 100644 index 0000000..fa44a0d --- /dev/null +++ b/test/EFCore.Jet.Integration.Test/Model74_ComplexTypeContained_Github9536/Context.cs @@ -0,0 +1,26 @@ +using Microsoft.EntityFrameworkCore; + +namespace EFCore.Jet.Integration.Test.Model74_ComplexTypeContained_Github9536 +{ + public class TestContext : DbContext + { + public TestContext(DbContextOptions options) : base(options) { } + + public DbSet Friends { get; set; } + public DbSet LessThanFriends { get; set; } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + + modelBuilder.Entity() + .OwnsOne(_ => _.Address) + .OwnsOne(_ => _.CityAddress1); + modelBuilder.Entity() + .OwnsOne(_ => _.Address) + .OwnsOne(_ => _.CityAddress2); + modelBuilder.Entity() + .OwnsOne(_ => _.Address); + } + } +} diff --git a/test/EFCore.Jet.Integration.Test/Model74_ComplexTypeContained_Github9536/JetTest.cs b/test/EFCore.Jet.Integration.Test/Model74_ComplexTypeContained_Github9536/JetTest.cs new file mode 100644 index 0000000..b0712ab --- /dev/null +++ b/test/EFCore.Jet.Integration.Test/Model74_ComplexTypeContained_Github9536/JetTest.cs @@ -0,0 +1,15 @@ +using System; +using System.Data.Common; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace EFCore.Jet.Integration.Test.Model74_ComplexTypeContained_Github9536 +{ + [TestClass] + public class Model12ComplexType : Test + { + protected override DbConnection GetConnection() + { + return Helpers.GetJetConnection(); + } + } +} diff --git a/test/EFCore.Jet.Integration.Test/Model74_ComplexTypeContained_Github9536/Model.cs b/test/EFCore.Jet.Integration.Test/Model74_ComplexTypeContained_Github9536/Model.cs new file mode 100644 index 0000000..735e372 --- /dev/null +++ b/test/EFCore.Jet.Integration.Test/Model74_ComplexTypeContained_Github9536/Model.cs @@ -0,0 +1,55 @@ +using System; +using System.ComponentModel.DataAnnotations.Schema; + +namespace EFCore.Jet.Integration.Test.Model74_ComplexTypeContained_Github9536 +{ + + [Table("Friend74")] + public class Friend + { + public Friend() + { + Address = new FullAddress(); + } + + public int Id { get; set; } + public string Name { get; set; } + + public FullAddress Address { get; set; } + } + + [Table("LessThanFriend74")] + public class LessThanFriend + { + public LessThanFriend() + { + Address = new CityAddress(); + } + + public int Id { get; set; } + public string Name { get; set; } + + public CityAddress Address { get; set; } + } + + + public class CityAddress + { + public string Cap { get; set; } + public string City { get; set; } + } + + + public class FullAddress + { + public FullAddress() + { + CityAddress1 = new CityAddress(); + CityAddress2 = new CityAddress(); + } + + public string Street { get; set; } + public CityAddress CityAddress1 { get; set; } + public CityAddress CityAddress2 { get; set; } + } +} diff --git a/test/EFCore.Jet.Integration.Test/Model74_ComplexTypeContained_Github9536/Test.cs b/test/EFCore.Jet.Integration.Test/Model74_ComplexTypeContained_Github9536/Test.cs new file mode 100644 index 0000000..c9b3795 --- /dev/null +++ b/test/EFCore.Jet.Integration.Test/Model74_ComplexTypeContained_Github9536/Test.cs @@ -0,0 +1,36 @@ +using System; +using System.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace EFCore.Jet.Integration.Test.Model74_ComplexTypeContained_Github9536 +{ + public abstract class Test : TestBase + { + [TestMethod] + public void Model74_ComplexType_Github9536() + { + var friend = new Friend + { + Name = "Bubi", + Address = + { + CityAddress1 = { Cap = "40100" }, + CityAddress2 = { Cap = "40101" }, + Street = "The street" + } + }; + + Context.Friends.Add(friend); + + Context.SaveChanges(); + + DisposeContext(); + CreateContext(); + + var readFriend = Context.Friends.First(); + Assert.AreEqual("40100", readFriend.Address.CityAddress1.Cap); + Assert.AreEqual("40101", readFriend.Address.CityAddress2.Cap); + + } + } +} diff --git a/test/EFCore.Jet.Integration.Test/Model75_Enums/Context.cs b/test/EFCore.Jet.Integration.Test/Model75_Enums/Context.cs new file mode 100644 index 0000000..4c52266 --- /dev/null +++ b/test/EFCore.Jet.Integration.Test/Model75_Enums/Context.cs @@ -0,0 +1,12 @@ +using System; +using Microsoft.EntityFrameworkCore; + +namespace EFCore.Jet.Integration.Test.Model75_Enums +{ + public class TestContext : DbContext + { + public TestContext(DbContextOptions options) : base(options) { } + + public DbSet Entities { get; set; } + } +} diff --git a/test/EFCore.Jet.Integration.Test/Model75_Enums/JetTest.cs b/test/EFCore.Jet.Integration.Test/Model75_Enums/JetTest.cs new file mode 100644 index 0000000..e16b8ef --- /dev/null +++ b/test/EFCore.Jet.Integration.Test/Model75_Enums/JetTest.cs @@ -0,0 +1,15 @@ +using System; +using System.Data.Common; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace EFCore.Jet.Integration.Test.Model75_Enums +{ + [TestClass] + public class Model12ComplexType : Test + { + protected override DbConnection GetConnection() + { + return Helpers.GetJetConnection(); + } + } +} diff --git a/test/EFCore.Jet.Integration.Test/Model75_Enums/Model.cs b/test/EFCore.Jet.Integration.Test/Model75_Enums/Model.cs new file mode 100644 index 0000000..78a4926 --- /dev/null +++ b/test/EFCore.Jet.Integration.Test/Model75_Enums/Model.cs @@ -0,0 +1,21 @@ +using System; +using System.ComponentModel.DataAnnotations.Schema; + +namespace EFCore.Jet.Integration.Test.Model75_Enums +{ + + [Table("NTT75")] + public class Entity + { + public int Id { get; set; } + + public EnumDataType EnumDataType { get; set; } + } + + public enum EnumDataType + { + a, + b, + c + } +} diff --git a/test/EFCore.Jet.Integration.Test/Model75_Enums/Test.cs b/test/EFCore.Jet.Integration.Test/Model75_Enums/Test.cs new file mode 100644 index 0000000..96efb5e --- /dev/null +++ b/test/EFCore.Jet.Integration.Test/Model75_Enums/Test.cs @@ -0,0 +1,24 @@ +using System; +using System.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace EFCore.Jet.Integration.Test.Model75_Enums +{ + public abstract class Test : TestBase + { + [TestMethod] + public void Model75_EnumsRun() + { + Context.Entities.AddRange( + new Entity() {EnumDataType = EnumDataType.a}, + new Entity() {EnumDataType = EnumDataType.b}, + new Entity() {EnumDataType = EnumDataType.c}); + + Context.SaveChanges(); + + Context.Entities.Select(_ => _.EnumDataType).ToList(); + Context.Entities.Single(_ => _.EnumDataType == EnumDataType.c); + + } + } +}