'use strict';

const Connection = require('../../src/tedious').Connection;
const ISOLATION_LEVEL = require('../../src/tedious').ISOLATION_LEVEL;
const TYPES = require('../../src/tedious').TYPES;

exports.types = function(test) {
  test.ok(TYPES);
  test.ok(TYPES.VarChar);

  test.done();
};

exports.isolationLevel = function(test) {
  test.ok(ISOLATION_LEVEL);
  test.ok(ISOLATION_LEVEL.READ_UNCOMMITTED);

  test.done();
};

exports.connection = function(test) {
  test.ok(Connection);

  test.done();
};

exports.connectionDeepCopiesConfig = function(test) {
  var userName = 'sa';
  var password = 'sapwd';
  var port = 1234;
  var ciphers = 'RC4-MD5';

  var config = {};
  config.userName = userName;
  config.password = password;
  config.options = {};
  config.options.port = port;
  config.options.cryptoCredentialsDetails = {};
  config.options.cryptoCredentialsDetails.ciphers = ciphers;

  var configStr = JSON.stringify(config);
  var connection = new Connection(config);

  // Verify that Connection constructor did not change config object.
  test.ok(configStr === JSON.stringify(config));

  // Verify that Connection constructor copied fields correctly.
  test.ok(connection.config.userName === userName);
  test.ok(connection.config.password === password);
  test.ok(connection.config.options.port === port);
  test.ok(connection.config.options.cryptoCredentialsDetails.ciphers === ciphers);

  // Verify that Connection constructor did a deep copy of the config object.
  config.userName = '';
  config.password = '';
  config.options.port = 0;

  test.strictEqual(connection.config.userName, userName);
  test.strictEqual(connection.config.password, password);
  test.strictEqual(connection.config.options.port, port);

  // Test that we did not do a deep copy of the cryptoCredentialsDetails,
  // as we never modify that value inside tedious.
  test.strictEqual(connection.config.options.cryptoCredentialsDetails, config.options.cryptoCredentialsDetails);

  test.done();
};

@@ -525,17 +525,26 @@
 ionD
-eepCopies
+oesNotModifyPassed
 Conf
@@ -569,104 +569,8 @@
 ) %7B%0A
-  var userName = 'sa';%0A  var password = 'sapwd';%0A  var port = 1234;%0A  var ciphers = 'RC4-MD5';%0A%0A
   va
@@ -585,28 +585,21 @@
  = %7B
-%7D;
 %0A  
-config.
+  
 userName
  = u
@@ -598,887 +598,208 @@
 Name
- = userName;%0A  config.password = password;%0A  config.options = %7B%7D;%0A  config.options.port = port;%0A  config.options.cryptoCredentialsDetails = %7B%7D;%0A  config.options.cryptoCredentialsDetails.ciphers = ciphers;%0A%0A  var configStr = JSON.stringify(config);%0A  var connection = new Connection(config);%0A%0A  // Verify that Connection constructor did not change config object.%0A  test.ok(configStr === JSON.stringify(config));%0A%0A  // Verify that Connection constructor copied fields correctly.%0A  test.ok(connection.config.userName === userName);%0A  test.ok(connection.config.password === password);%0A  test.ok(connection.config.options.port === port);%0A  test.ok(connection.config.options.cryptoCredentialsDetails.ciphers === ciphers);%0A%0A  // Verify that Connection constructor did a deep copy of the config object.%0A  config.userName = '';%0A  config.password = '';%0A  config.options.port = 0;%0A%0A  test.s
+: 'sa',%0A    password: 'sapwd',%0A    options: %7B%0A      port: 1234,%0A      cryptoCredentialsDetails: %7B%0A        ciphers: 'RC4-MD5'%0A      %7D%0A    %7D%0A  %7D;%0A%0A  var connection = new Connection(config);%0A%0A  test.notS
 tric
@@ -826,27 +826,16 @@
 nfig
-.userName, userName
+, config
 );%0A 
@@ -832,33 +832,36 @@
 config);%0A  test.
-s
+notS
 trictEqual(conne
@@ -877,59 +877,17 @@
 fig.
+o
 p
-assword, password);%0A  test.strictEqual(connec
 tion
-.
+s, 
 conf
@@ -900,19 +900,8 @@
 ions
-.port, port
 );%0A%0A

Update test cases.