Skip to content

Commit

Permalink
Initial Integration Tests for #536.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikependon committed Sep 2, 2020
1 parent b8667e4 commit 3968068
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions RepoDb.Core/RepoDb.Tests/RepoDb.IntegrationTests/AnonymousTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using Microsoft.Data.SqlClient;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using RepoDb.IntegrationTests;
using RepoDb.IntegrationTests.Models;
using RepoDb.IntegrationTests.Setup;
using System;
using System.Collections.Generic;
using System.Linq;

namespace RepoDb.SqlServer.IntegrationTests
{
[TestClass]
public class AnonymousTest
{
[TestInitialize]
public void Initialize()
{
Database.Initialize();
Cleanup();
}

[TestCleanup]
public void Cleanup()
{
Database.Cleanup();
}

#region Helpers

private object CreateIdentityTableTypeDef()
{
return new
{
Id = default(long),
RowGuid = default(Guid),
ColumnBit = default(bool?),
ColumnDateTime = default(DateTime?),
ColumnDateTime2 = default(DateTime?),
ColumnDecimal = default(decimal?),
ColumnFloat = default(float?),
ColumnInt = default(int?),
ColumnNVarChar = default(string)
};
}

#endregion

[TestMethod]
public void TestQueryAllForAnonymous()
{
var result = TestQueryAllForAnonymous(CreateIdentityTableTypeDef());
Assert.IsTrue(result.Any());
}

private IEnumerable<TAnonymous> TestQueryAllForAnonymous<TAnonymous>(TAnonymous typeDef)
where TAnonymous : class
{
// Setup
var tables = Helper.CreateIdentityTables(10);

using (var connection = new SqlConnection(Database.ConnectionStringForRepoDb))
{
// Act
connection.InsertAll<IdentityTable>(tables);

// Act
return connection.QueryAll<TAnonymous>();
}
}
}
}

0 comments on commit 3968068

Please sign in to comment.