Skip to content

Commit

Permalink
improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pwelter34 committed Oct 12, 2023
1 parent 8c39107 commit aab58db
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ namespace FluentCommand.Entities
if (dataRecord == null)
throw new global::System.ArgumentNullException(nameof(dataRecord));

int v_id = default;
string v_name = default;
bool v_isActive = default;
System.DateTimeOffset v_updated = default;
byte[] v_rowVersion = default;
int v_id = default!;
string v_name = default!;
bool v_isActive = default!;
System.DateTimeOffset v_updated = default!;
byte[] v_rowVersion = default!;

for (var __index = 0; __index < dataRecord.FieldCount; __index++)
{
Expand Down
20 changes: 18 additions & 2 deletions test/FluentCommand.SqlServer.Tests/DataConfigurationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ public void GetServices()

var sqlGenerator = services.GetService<SqlServerGenerator>();
sqlGenerator.Should().NotBeNull();



var dataCache = services.GetService<IDataCache>();
dataCache.Should().NotBeNull();

Expand All @@ -48,5 +47,22 @@ public void GetServices()
var sessionFactory = services.GetService<IDataSessionFactory>();
sessionFactory.Should().NotBeNull();

var dataConfiguration = services.GetService<IDataConfiguration>();
dataConfiguration.Should().NotBeNull();
dataConfiguration.ConnectionString.Should().NotEndWith("ApplicationIntent=ReadOnly;");

var dataSession = services.GetService<IDataSession>();
dataSession.Should().NotBeNull();

var readonlyFactory = services.GetService<IDataSessionFactory<ReadOnlyIntent>>();
readonlyFactory.Should().NotBeNull();

var readonlyConfiguration = services.GetService<IDataConfiguration<ReadOnlyIntent>>();
readonlyConfiguration.Should().NotBeNull();
readonlyConfiguration.ConnectionString.Should().EndWith("ApplicationIntent=ReadOnly;");

var readonlySession = services.GetService<IDataSession<ReadOnlyIntent>>();
readonlySession.Should().NotBeNull();

}
}
9 changes: 9 additions & 0 deletions test/FluentCommand.SqlServer.Tests/DatabaseFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ protected override void ConfigureServices(HostBuilderContext context, IServiceCo
.AddSqlServerGenerator()
.AddDistributedDataCache()
);

var readOnlyConnection = trackerConnection + "ApplicationIntent=ReadOnly;";

services.AddFluentCommand<ReadOnlyIntent>(builder => builder
.UseConnectionString(readOnlyConnection)
.AddProviderFactory(SqlClientFactory.Instance)
.AddSqlServerGenerator()
.AddDistributedDataCache()
);
}

}
3 changes: 3 additions & 0 deletions test/FluentCommand.SqlServer.Tests/ReadOnlyIntent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
namespace FluentCommand.SqlServer.Tests;

public readonly struct ReadOnlyIntent { }
2 changes: 1 addition & 1 deletion test/FluentCommand.SqlServer.Tests/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"ConnectionStrings": {
"Tracker": "Data Source=(local);Initial Catalog=TrackerTest;Integrated Security=True;TrustServerCertificate=True",
"Tracker": "Data Source=(local);Initial Catalog=TrackerTest;Integrated Security=True;TrustServerCertificate=True;",
"DistributedCache": "localhost:6379"
}
}

0 comments on commit aab58db

Please sign in to comment.