Пример #1
0
        public static void TryGetConnectionId_WhenNoConnectionSet_ReturnsEmptyGuid()
        {
            var connection = Mock.Of <IDbConnectionFactory>();
            var result     = ConnectionRegistry.TryGetConnectionId(connection, out var connectionId);

            Assert.Multiple(() =>
            {
                Assert.That(result, Is.False);
                Assert.That(connectionId, Is.EqualTo(Guid.Empty));
            });
        }
Пример #2
0
        public static void TryGetConnectionId_WhenConnectionSet_ReturnsConnectionId()
        {
            var connectionId = Guid.NewGuid();
            var connection   = Mock.Of <IDbConnectionFactory>();

            ConnectionRegistry.RegisterConnection(connectionId, connection);
            var result = ConnectionRegistry.TryGetConnectionId(connection, out var retrievedConnectionId);

            Assert.Multiple(() =>
            {
                Assert.That(result, Is.True);
                Assert.That(retrievedConnectionId, Is.EqualTo(connectionId));
            });
        }
Пример #3
0
 public static void TryGetConnectionId_GivenNullConnection_ThrowsArgNullException()
 {
     Assert.That(() => ConnectionRegistry.TryGetConnectionId(null, out _), Throws.ArgumentNullException);
 }