Ejemplo n.º 1
0
        public void CreateDbConnection_prepares_the_db_context()
        {
            using var factory = new NorthWindDatabaseFactory();

            using var dbConnection = factory.CreateDbConnection();

            TestHelpers.ShouldBePrepared(dbConnection);
        }
Ejemplo n.º 2
0
        public void CreateDbConnection_creates_an_instance()
        {
            using var factory = new NorthWindDatabaseFactory();

            using var dbConnection = factory.CreateDbConnection();

            // Assert
            dbConnection.Should().NotBeNull();
        }
Ejemplo n.º 3
0
        public void CreateDbConnection_opens_the_database()
        {
            // Arrange
            using var instance = new NorthWindDatabaseFactory();

            // Act
            using var connection = instance.CreateDbConnection();

            // Assert
            connection.State.Should().Be(ConnectionState.Open);
        }
Ejemplo n.º 4
0
        public void CreateDbConnection_calls_prepare_only_once()
        {
            // Arrange
            var count = 0;

            using var instance = new NorthWindDatabaseFactory();
            instance.Prepared += () => count++;

            // Act
            TestHelpers.MakeFirstCall(instance);
            using var dbConnection = instance.CreateDbConnection();

            // Assert
            count.Should().Be(1);
            TestHelpers.ShouldBePrepared(dbConnection);
        }