System.Data.Common.DbConnection.Returns(System.Data.Common.DbConnection, params System.Data.Common.DbConnection[])

Here are the examples of the csharp api class System.Data.Common.DbConnection.Returns(System.Data.Common.DbConnection, params System.Data.Common.DbConnection[]) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Example 7

1. Example

Project: yadal
Source File: DbConstructorTests.cs
View license
[Fact]
        public void GivenDbWithConnectionString_WhenDisposed_ConnectionIsDisposed()
        {
            var fakeConnection = Substitute.For<DbConnection>();
            fakeConnection.ConnectionString = "MyConnectionString";
            var fakeFactory = Substitute.For<DbProviderFactory>();

            fakeFactory.CreateConnection().Returns(fakeConnection);

            using (var db = new Db("", DbConfig.Default, fakeFactory))
            {
                // ensure the connection is actually instantiated
                // ReSharper disable UnusedVariable
                var connection = db.Connection;
                // ReSharper restore UnusedVariable
            }

            fakeConnection.Received().Dispose();
        }