<commit_before>﻿using System.Threading;
using NUnit.Framework;

namespace Tests.UserTests
{
	using LinqToDB;
	using LinqToDB.Mapping;

	public class Issue1128Tests : TestBase
	{
		private static int _cnt;

		class Issue1128Table
		{
			public int Id { get; set; }
		}

		class Issue1128TableDerived : Issue1128Table
		{
		}


		MappingSchema SetMappings()
		{
			// counter added to fix this issue with tests in Firebird
			// https://stackoverflow.com/questions/44353607
			// it was only working solution for Firebird3
			var cnt = Interlocked.Increment(ref _cnt).ToString();

			var ms = new MappingSchema(cnt);
			
			var tableName = "Issue1128Table" + cnt;

			var mappingBuilder = ms.GetFluentMappingBuilder();
			mappingBuilder.Entity<Issue1128Table>()
				.HasTableName(tableName)
				.Property(x => x.Id).IsColumn().IsNullable(false).HasColumnName("Id").IsPrimaryKey();

			return ms;
		}

		[Test, DataContextSource]
		public void TestED(string configuration)
		{
			var ms = SetMappings();

			var ed1 = ms.GetEntityDescriptor(typeof(Issue1128Table));
			var ed2 = ms.GetEntityDescriptor(typeof(Issue1128TableDerived));

			Assert.AreEqual(ed1.TableName, ed2.TableName);
		}

		[Test, DataContextSource]
		public void Test(string configuration)
		{
			var ms = SetMappings();

			using (var db = GetDataContext(configuration, ms))
			{
				try
				{
					db.CreateTable<Issue1128TableDerived>();
				}
				catch
				{
					db.DropTable<Issue1128TableDerived>(throwExceptionIfNotExists: false);
					db.CreateTable<Issue1128TableDerived>();
				}

				try
				{
					db.Insert(new Issue1128TableDerived { Id = 1 });
				}
				finally
				{
					db.DropTable<Issue1128TableDerived>();
				}
			}
		}
	}
}<commit_msg>change test for 1128, this worked before<commit_after>﻿using System.Threading;
using NUnit.Framework;

namespace Tests.UserTests
{
	using LinqToDB;
	using LinqToDB.Mapping;

	public class Issue1128Tests : TestBase
	{
		private static int _cnt;

		class Issue1128Table
		{
			public int Id { get; set; }
		}

		class Issue1128TableDerived : Issue1128Table
		{
			public string BlaBla { get; set; }
		}


		MappingSchema SetMappings()
		{
			// counter added to fix this issue with tests in Firebird
			// https://stackoverflow.com/questions/44353607
			// it was only working solution for Firebird3
			var cnt = Interlocked.Increment(ref _cnt).ToString();

			var ms = new MappingSchema(cnt);
			
			var tableName = "Issue1128Table" + cnt;

			var mappingBuilder = ms.GetFluentMappingBuilder();
			mappingBuilder.Entity<Issue1128Table>()
				.HasTableName(tableName)
				.Property(x => x.Id).IsColumn().IsNullable(false).HasColumnName("Id").IsPrimaryKey();

			return ms;
		}

		[Test, DataContextSource]
		public void TestED(string configuration)
		{
			var ms = SetMappings();

			var ed1 = ms.GetEntityDescriptor(typeof(Issue1128Table));
			var ed2 = ms.GetEntityDescriptor(typeof(Issue1128TableDerived));

			Assert.AreEqual(ed1.TableName, ed2.TableName);
		}

		[Test, DataContextSource]
		public void Test(string configuration)
		{
			var ms = SetMappings();

			using (var db = GetDataContext(configuration, ms))
			{
				try
				{
					db.CreateTable<Issue1128Table>();
				}
				catch
				{
					db.DropTable<Issue1128Table>(throwExceptionIfNotExists: false);
					db.CreateTable<Issue1128Table>();
				}

				try
				{
					db.Insert(new Issue1128TableDerived { Id = 1 });
				}
				finally
				{
					db.DropTable<Issue1128Table>();
				}
			}
		}
	}
}
{'fraction_non_alphanumeric': 0.10811585890450244, 'fraction_numerical': 0.039002007456266134, 'mean_word_length': 3.398486759142497, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6704066', 'n_tokens_mistral': 1476, 'n_tokens_neox': 1123, 'n_words': 237}