Skip to content
Permalink
Browse files

Fix for provider initialization sequence in fluent constructor (#508)

  • Loading branch information...
asherber authored and pleb committed Mar 12, 2019
1 parent 69edf7d commit 2018349f4af7042d5c85011eeac6998719055fed
Showing with 96 additions and 86 deletions.
  1. +19 −0 PetaPoco.Tests.Unit/DatabaseConfigurationTests.cs
  2. +1 −1 PetaPoco.Tests.Unit/DatabaseTests.cs
  3. +76 −85 PetaPoco/Database.cs
@@ -437,5 +437,24 @@ public void UsingConnectionWithProvider_AfterCreate_InstanceShouldBeValid()
db.ConnectionString.ShouldBe(connString);
db.Provider.ShouldBeOfType<FakeProvider>();
}

[Fact]
public void UsingConnectionWithProviderName_AfterCreate_InstanceShouldBeValid()
{
DatabaseProvider.RegisterCustomProvider<FakeProvider>("fake");
try
{
var connString = "Data Source = foo";
var connection = new SqlConnection(connString);
var db = new Database(config.UsingConnection(connection).UsingProviderName("FakeProvider"));

db.ConnectionString.ShouldBe(connString);
db.Provider.ShouldBeOfType<FakeProvider>();
}
finally
{
DatabaseProvider.ClearCustomProviders();
}
}
}
}
@@ -94,7 +94,7 @@ public void Construct_GivenInvalidArguments_ShouldThrow()
}
catch (Exception e)
{
e.Message.ShouldContain("Either a provider name or provider must be registered");
e.Message.ShouldContain("Unable to locate a provider");
throw;
}
});
Oops, something went wrong.

0 comments on commit 2018349

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.