Exemplo n.º 1
0
        public void get_connection_properties()
        {
            Assert.True(ServerConnectionOptions.IsNamedPipe(@"np:\\.\pipe\LOCALDB#678E2031\tsql\query".Split(@"\")));
            //Act
            var p = new ServerConnectionOptions(@"(localdb)\mssqllocaldb", false);

            //
            Assert.StartsWith(@"localdb#", p.PipeName);
            Assert.EndsWith(@"\tsql\query", p.PipeName);
            Assert.Equal(@".", p.PipeServerName);

            //Act
            p = new ServerConnectionOptions(@"tcp:localhost,1444", false);
            //
            Assert.Equal(@"localhost", p.IpServerName);
            Assert.Null(p.InstanceName);
            Assert.Equal(1444, p.IpPort);
            Assert.False(p.IsSsrpRequired);
            //Act
            p = new ServerConnectionOptions(@"tcp:localhost\instance", false);
            //Assert
            Assert.Equal(@"localhost", p.IpServerName);
            Assert.Equal("instance", p.InstanceName);
            Assert.Equal(-1, p.IpPort);
            Assert.True(p.IsSsrpRequired);
        }
Exemplo n.º 2
0
        public void get_npSniHandle()
        {
            const bool marsOn = false;
            var        p      = new ServerConnectionOptions(@"(localdb)\mssqllocaldb", false);
            var        handle = new TdsStreamNamedPipes(p.PipeServerName, p.PipeName, 15);
            var        writer = new TdsPackageWriter(handle);
            var        reader = new TdsPackageReader(handle);

            writer.SendPreLoginHandshake("", marsOn);
            reader.CheckBuffer(8);
            var result = ParserPreLogin.ParsePreLoginHandshake(reader.ReadBuffer, TdsEnums.HEADER_LEN, EncryptionOptions.OFF);

            Assert.Equal(EncryptionOptions.OFF, result);
        }