コード例 #1
0
        public static void RegisterConnection_GivenValidConnection_SetsConnection()
        {
            var connectionId = Guid.NewGuid();
            var connection   = Mock.Of <IDbConnectionFactory>();

            Assert.That(() => ConnectionRegistry.RegisterConnection(connectionId, connection), Throws.Nothing);
        }
コード例 #2
0
        public static void RegisterConnection_GivenTwoConnectionsWithSameId_SetsSecondConnection()
        {
            var connectionId     = Guid.NewGuid();
            var firstConnection  = Mock.Of <IDbConnectionFactory>();
            var secondConnection = Mock.Of <IDbConnectionFactory>();

            Assert.That(() =>
            {
                ConnectionRegistry.RegisterConnection(connectionId, firstConnection);
                ConnectionRegistry.RegisterConnection(connectionId, secondConnection);
            }, Throws.Nothing);
        }
コード例 #3
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));
            });
        }
コード例 #4
0
 public static void RegisterConnection_GivenNullConnection_ThrowsArgNullException()
 {
     Assert.That(() => ConnectionRegistry.RegisterConnection(Guid.NewGuid(), null), Throws.ArgumentNullException);
 }