Skip to content

Commit

Permalink
integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Del Bianco committed May 19, 2018
1 parent e72a0e1 commit 7859d66
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@

namespace TableDependency.SqlClient.IntegrationTests
{
public class CancellationTokenTestModel
{
public int Id { get; set; }
public string Name { get; set; }
public string Surname { get; set; }
public DateTime Born { get; set; }
public int Quantity { get; set; }
}

[TestClass]
public class CancellationTokenTest : SqlTableDependencyBaseTest
{
private class LoadAndCountTestSqlServerModel
{
public int Id { get; set; }
public string Name { get; set; }
public string Surname { get; set; }
public DateTime Born { get; set; }
public int Quantity { get; set; }
}

private static readonly string TableName = typeof(LoadAndCountTestSqlServerModel).Name;
private static readonly string TableName = typeof(CancellationTokenTestModel).Name;

[ClassInitialize]
public static void ClassInitialize(TestContext testContext)
Expand Down Expand Up @@ -112,15 +112,15 @@ public void Test()

public class ListenerSlq : SqlTableDependencyBaseTest, IDisposable
{
private readonly SqlTableDependency<LoadAndCountTestSqlServerModel> _tableDependency;
private readonly SqlTableDependency<CancellationTokenTestModel> _tableDependency;
public string ObjectNaming { get; }

public ListenerSlq(string tableName)
{
var mapper = new ModelToTableMapper<LoadAndCountTestSqlServerModel>();
var mapper = new ModelToTableMapper<CancellationTokenTestModel>();
mapper.AddMapping(c => c.Name, "First Name").AddMapping(c => c.Surname, "Second Name");

_tableDependency = new SqlTableDependency<LoadAndCountTestSqlServerModel>(ConnectionStringForTestUser, mapper: mapper);
_tableDependency = new SqlTableDependency<CancellationTokenTestModel>(ConnectionStringForTestUser, mapper: mapper);
_tableDependency.OnChanged += (o, args) => { Debug.WriteLine("Received:" + args.Entity.Name); };
_tableDependency.Start(60, 120);
this.ObjectNaming = this._tableDependency.DataBaseObjectsNamingConvention;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@

namespace TableDependency.SqlClient.IntegrationTests
{
public class CultureInfoTestModel
{
public string Name { get; set; }

public DateTime BirthDate { get; set; }
}

[TestClass]
public class CultureInfoTest : SqlTableDependencyBaseTest
{
private class CultureInfoTestModel
{
public string Name { get; set; }

public DateTime BirthDate { get; set; }
}

private static readonly string TableName1 = typeof(CultureInfoTestModel).Name + "1";
private static readonly string TableName2 = typeof(CultureInfoTestModel).Name + "2";
private static int _counter1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@

namespace TableDependency.SqlClient.IntegrationTests
{
[Table("ANItemsTableSQL2")]
public class DataAnnotationTestSqlServer2Model
[TestClass]
public class DataAnnotationTest02 : SqlTableDependencyBaseTest
{
public long Id { get; set; }
[Table("ANItemsTableSQL2")]
private class DataAnnotationTestSqlServer2Model
{
public long Id { get; set; }

public string Name { get; set; }
public string Name { get; set; }

[Column("Long")]
public string Description { get; set; }
}
[Column("Long")]
public string Description { get; set; }
}

[TestClass]
public class DataAnnotationTest02 : SqlTableDependencyBaseTest
{
private const string TableName = "ANItemsTableSQL2";
private static int _counter;
private static Dictionary<string, Tuple<DataAnnotationTestSqlServer2Model, DataAnnotationTestSqlServer2Model>> _checkValues = new Dictionary<string, Tuple<DataAnnotationTestSqlServer2Model, DataAnnotationTestSqlServer2Model>>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@

namespace TableDependency.SqlClient.IntegrationTests
{
public class DatabaseObjectCleanUpTestSqlServerModel
{
public int Id { get; set; }
public string Name { get; set; }
public string Surname { get; set; }
public DateTime Born { get; set; }
public int Quantity { get; set; }
}

[TestClass]
public class DatabaseObjectAutoCleanUpTest : SqlTableDependencyBaseTest
{
private class DatabaseObjectCleanUpTestSqlServerModel
{
public int Id { get; set; }
public string Name { get; set; }
public string Surname { get; set; }
public DateTime Born { get; set; }
public int Quantity { get; set; }
}

private static string _dbObjectsNaming;
private const string TableName = "SpiderManTable";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ public static void ClassCleanup()
[TestMethod]
public void Test()
{
var mapper = new ModelToTableMapper<EventForAllColumnsTestSqlServerModel>();
var mapper = new ModelToTableMapper<DatabaseObjectCleanUpAfterHugeInsertsTestSqlServerModel>();
mapper.AddMapping(c => c.Name, "FIRST name").AddMapping(c => c.Surname, "Second Name");

var tableDependency = new SqlTableDependency<EventForAllColumnsTestSqlServerModel>(
var tableDependency = new SqlTableDependency<DatabaseObjectCleanUpAfterHugeInsertsTestSqlServerModel>(
ConnectionStringForTestUser,
includeOldValues: true,
tableName: TableName,
Expand Down Expand Up @@ -115,7 +115,7 @@ private static void SmalModifyTableContent()
}
}

private void TableDependency_OnChanged(object sender, TableDependency.EventArgs.RecordChangedEventArgs<EventForAllColumnsTestSqlServerModel> e)
private void TableDependency_OnChanged(object sender, TableDependency.EventArgs.RecordChangedEventArgs<DatabaseObjectCleanUpAfterHugeInsertsTestSqlServerModel> e)
{
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ public enum TypeEnum : byte
Figlio = 2
}

public class EnumTestSqlServerModel
{
public string Name { get; set; }
public string Surname { get; set; }
public TypeEnum Tipo { get; set; }
}

[TestClass]
public class EnumTestSqlServer : SqlTableDependencyBaseTest
{
private class EnumTestSqlServerModel
{
public string Name { get; set; }
public string Surname { get; set; }
public TypeEnum Tipo { get; set; }
}

private static readonly string TableName = typeof(EnumTestSqlServerModel).Name.ToUpper();
private static int _counter;
private static readonly Dictionary<string, Tuple<EnumTestSqlServerModel, EnumTestSqlServerModel>> CheckValues = new Dictionary<string, Tuple<EnumTestSqlServerModel, EnumTestSqlServerModel>>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@

namespace TableDependency.SqlClient.IntegrationTests
{
public class EventForAllColumnsTestSqlServerModel
{
public int Id { get; set; }
public string Name { get; set; }
public string Surname { get; set; }
public DateTime Born { get; set; }
public int Quantity { get; set; }
}

[TestClass]
public class EventForAllColumnsTest : SqlTableDependencyBaseTest
{
private class EventForAllColumnsTestSqlServerModel
{
public int Id { get; set; }
public string Name { get; set; }
public string Surname { get; set; }
public DateTime Born { get; set; }
public int Quantity { get; set; }
}

private static readonly string TableName = typeof(EventForAllColumnsTestSqlServerModel).Name;
private static int _counter;
private static Dictionary<string, Tuple<EventForAllColumnsTestSqlServerModel, EventForAllColumnsTestSqlServerModel>> _checkValues = new Dictionary<string, Tuple<EventForAllColumnsTestSqlServerModel, EventForAllColumnsTestSqlServerModel>>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@

namespace TableDependency.SqlClient.IntegrationTests
{
public class NotificationOnlyWhenNewValueIsDifferentFromOldValueSqlServerModel
{
public int Id { get; set; }
public string Name { get; set; }
public string Surname { get; set; }
}

[TestClass]
public class NotificationOnlyWhenNewValueIsDifferentFromOldValueTest : SqlTableDependencyBaseTest
{
private class NotificationOnlyWhenNewValueIsDifferentFromOldValueSqlServerModel
{
public int Id { get; set; }
public string Name { get; set; }
public string Surname { get; set; }
}

private static readonly string TableName = typeof(NotificationOnlyWhenNewValueIsDifferentFromOldValueSqlServerModel).Name;
private static int _counter1;
private static int _counter2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ private class TableWithSpacesModel

private const string TableName = "BranchABC$Sales Invoice Header";
private static int _counter;
private static readonly Dictionary<string, Tuple<EventForAllColumnsTestSqlServerModel, EventForAllColumnsTestSqlServerModel>> _checkValues = new Dictionary<string, Tuple<EventForAllColumnsTestSqlServerModel, EventForAllColumnsTestSqlServerModel>>();
private static readonly Dictionary<string, Tuple<EventForAllColumnsTestSqlServerModel, EventForAllColumnsTestSqlServerModel>> _checkValuesOld = new Dictionary<string, Tuple<EventForAllColumnsTestSqlServerModel, EventForAllColumnsTestSqlServerModel>>();
private static readonly Dictionary<string, Tuple<TableWithSpacesModel, TableWithSpacesModel>> _checkValues = new Dictionary<string, Tuple<TableWithSpacesModel, TableWithSpacesModel>>();
private static readonly Dictionary<string, Tuple<TableWithSpacesModel, TableWithSpacesModel>> _checkValuesOld = new Dictionary<string, Tuple<TableWithSpacesModel, TableWithSpacesModel>>();

[ClassInitialize]
public static void ClassInitialize(TestContext testContext)
Expand All @@ -40,7 +40,7 @@ public static void ClassInitialize(TestContext testContext)

sqlCommand.CommandText =
$"CREATE TABLE [{TableName}]( " +
"[Id][int] IDENTITY(1, 1) NOT NULL, " +
"[Id] [int] IDENTITY(1, 1) NOT NULL, " +
"[First Name] [nvarchar](50) NOT NULL, " +
"[Second Name] [nvarchar](50) NOT NULL)";
sqlCommand.ExecuteNonQuery();
Expand All @@ -66,13 +66,13 @@ public void TestInitialize()

_counter = 0;

_checkValues.Add(ChangeType.Insert.ToString(), new Tuple<EventForAllColumnsTestSqlServerModel, EventForAllColumnsTestSqlServerModel>(new EventForAllColumnsTestSqlServerModel { Name = "Christian", Surname = "Del Bianco" }, new EventForAllColumnsTestSqlServerModel()));
_checkValues.Add(ChangeType.Update.ToString(), new Tuple<EventForAllColumnsTestSqlServerModel, EventForAllColumnsTestSqlServerModel>(new EventForAllColumnsTestSqlServerModel { Name = "Velia", Surname = "Ceccarelli" }, new EventForAllColumnsTestSqlServerModel()));
_checkValues.Add(ChangeType.Delete.ToString(), new Tuple<EventForAllColumnsTestSqlServerModel, EventForAllColumnsTestSqlServerModel>(new EventForAllColumnsTestSqlServerModel { Name = "Velia", Surname = "Ceccarelli" }, new EventForAllColumnsTestSqlServerModel()));
_checkValues.Add(ChangeType.Insert.ToString(), new Tuple<TableWithSpacesModel, TableWithSpacesModel>(new TableWithSpacesModel { Name = "Christian", Surname = "Del Bianco" }, new TableWithSpacesModel()));
_checkValues.Add(ChangeType.Update.ToString(), new Tuple<TableWithSpacesModel, TableWithSpacesModel>(new TableWithSpacesModel { Name = "Velia", Surname = "Ceccarelli" }, new TableWithSpacesModel()));
_checkValues.Add(ChangeType.Delete.ToString(), new Tuple<TableWithSpacesModel, TableWithSpacesModel>(new TableWithSpacesModel { Name = "Velia", Surname = "Ceccarelli" }, new TableWithSpacesModel()));

_checkValuesOld.Add(ChangeType.Insert.ToString(), new Tuple<EventForAllColumnsTestSqlServerModel, EventForAllColumnsTestSqlServerModel>(new EventForAllColumnsTestSqlServerModel { Name = "Christian", Surname = "Del Bianco" }, new EventForAllColumnsTestSqlServerModel()));
_checkValuesOld.Add(ChangeType.Update.ToString(), new Tuple<EventForAllColumnsTestSqlServerModel, EventForAllColumnsTestSqlServerModel>(new EventForAllColumnsTestSqlServerModel { Name = "Velia", Surname = "Ceccarelli" }, new EventForAllColumnsTestSqlServerModel()));
_checkValuesOld.Add(ChangeType.Delete.ToString(), new Tuple<EventForAllColumnsTestSqlServerModel, EventForAllColumnsTestSqlServerModel>(new EventForAllColumnsTestSqlServerModel { Name = "Velia", Surname = "Ceccarelli" }, new EventForAllColumnsTestSqlServerModel()));
_checkValuesOld.Add(ChangeType.Insert.ToString(), new Tuple<TableWithSpacesModel, TableWithSpacesModel>(new TableWithSpacesModel { Name = "Christian", Surname = "Del Bianco" }, new TableWithSpacesModel()));
_checkValuesOld.Add(ChangeType.Update.ToString(), new Tuple<TableWithSpacesModel, TableWithSpacesModel>(new TableWithSpacesModel { Name = "Velia", Surname = "Ceccarelli" }, new TableWithSpacesModel()));
_checkValuesOld.Add(ChangeType.Delete.ToString(), new Tuple<TableWithSpacesModel, TableWithSpacesModel>(new TableWithSpacesModel { Name = "Velia", Surname = "Ceccarelli" }, new TableWithSpacesModel()));
}

[ClassCleanup]
Expand All @@ -93,15 +93,15 @@ public static void ClassCleanup()
[TestMethod]
public void Test()
{
SqlTableDependency<EventForAllColumnsTestSqlServerModel> tableDependency = null;
SqlTableDependency<TableWithSpacesModel> tableDependency = null;
string naming;

try
{
var mapper = new ModelToTableMapper<EventForAllColumnsTestSqlServerModel>();
mapper.AddMapping(c => c.Name, "FIRST name").AddMapping(c => c.Surname, "Second Name");
var mapper = new ModelToTableMapper<TableWithSpacesModel>();
mapper.AddMapping(c => c.Name, "First Name").AddMapping(c => c.Surname, "Second Name");

tableDependency = new SqlTableDependency<EventForAllColumnsTestSqlServerModel>(ConnectionStringForTestUser, tableName: TableName, mapper: mapper);
tableDependency = new SqlTableDependency<TableWithSpacesModel>(ConnectionStringForTestUser, includeOldValues: false, tableName: TableName, mapper: mapper);
tableDependency.OnChanged += TableDependency_Changed;
tableDependency.Start();
naming = tableDependency.DataBaseObjectsNamingConvention;
Expand Down Expand Up @@ -137,15 +137,15 @@ public void Test()
[TestMethod]
public void TestWithOldValues()
{
SqlTableDependency<EventForAllColumnsTestSqlServerModel> tableDependency = null;
SqlTableDependency<TableWithSpacesModel> tableDependency = null;
string naming;

try
{
var mapper = new ModelToTableMapper<EventForAllColumnsTestSqlServerModel>();
mapper.AddMapping(c => c.Name, "FIRST name").AddMapping(c => c.Surname, "Second Name");
var mapper = new ModelToTableMapper<TableWithSpacesModel>();
mapper.AddMapping(c => c.Name, "First Name").AddMapping(c => c.Surname, "Second Name");

tableDependency = new SqlTableDependency<EventForAllColumnsTestSqlServerModel>(ConnectionStringForTestUser, includeOldValues: true, tableName: TableName, mapper: mapper);
tableDependency = new SqlTableDependency<TableWithSpacesModel>(ConnectionStringForTestUser, includeOldValues: true, tableName: TableName, mapper: mapper);
tableDependency.OnChanged += TableDependency_Changed;
tableDependency.Start();
naming = tableDependency.DataBaseObjectsNamingConvention;
Expand Down Expand Up @@ -178,7 +178,7 @@ public void TestWithOldValues()
Assert.IsTrue(base.CountConversationEndpoints(naming) == 0);
}

private static void TableDependency_Changed(object sender, RecordChangedEventArgs<EventForAllColumnsTestSqlServerModel> e)
private static void TableDependency_Changed(object sender, RecordChangedEventArgs<TableWithSpacesModel> e)
{
_counter++;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@

namespace TableDependency.SqlClient.IntegrationTests
{
public class TwoIntancesModel
{
public long Id { get; set; }
public string Name { get; set; }
}

[TestClass]
public class TwoIntancesTest : SqlTableDependencyBaseTest
{
private class TwoIntancesModel
{
public long Id { get; set; }
public string Name { get; set; }
}

private const string TableName1 = "TwoIntancesModel1";
private const string TableName2 = "TwoIntancesModel2";
private static readonly Dictionary<string, IList<TwoIntancesModel>> CheckValues1 = new Dictionary<string, IList<TwoIntancesModel>>();
Expand Down

0 comments on commit 7859d66

Please sign in to comment.