예제 #1
0
        public void Instantiate_SqlClientAndQuery_CommandNotNull()
        {
            var client  = new SqlClient(new Uri("https://localhost:8081"), base64AuthKey, "db", "FoF");
            var query   = Mock.Of <IQuery>();
            var factory = new SqlCommandFactory();
            var command = factory.Instantiate(client, query);

            Assert.That(command, Is.Not.Null);
        }
예제 #2
0
        public void Instantiate_SqlClientAndQuery_ClientCorrectType()
        {
            var client  = new SqlClient(new Uri("https://localhost:8081"), base64AuthKey, "db", "FoF");
            var query   = Mock.Of <IQuery>();
            var factory = new SqlCommandFactory();
            var command = factory.Instantiate(client, query);
            var impl    = command.Client;

            Assert.That(impl, Is.Not.Null);
            Assert.That(impl, Is.InstanceOf <SqlClientOperation>());
        }
예제 #3
0
        public void Build_CommandTypeSetToStoredProcedure_CommandTypeSetStoredProcedure()
        {
            var conn  = new DbClient(DbProviderFactories.GetFactory("System.Data.SqlClient"), typeof(SqlConnection), "Data Source=server;Initial Catalog=database;Integrated Security=SSPI");
            var query = Mock.Of <IQuery>(
                x => x.ConnectionString == "Data Source=server;Initial Catalog=database;Integrated Security=SSPI" &&
                x.CommandType == System.Data.CommandType.StoredProcedure
                );

            var factory = new SqlCommandFactory();
            var cmd     = factory.Instantiate(conn, query, null);

            Assert.IsInstanceOf <SqlCommand>(cmd.Implementation);
            Assert.That((cmd.Implementation as SqlCommand).CommandType, Is.EqualTo(System.Data.CommandType.StoredProcedure));
        }
예제 #4
0
        public void Build_TimeoutSetTo30_TimeoutSet30Seconds()
        {
            var conn  = new DbClient(DbProviderFactories.GetFactory("System.Data.SqlClient"), typeof(SqlConnection), "Data Source=server;Initial Catalog=database;Integrated Security=SSPI");
            var query = Mock.Of <IQuery>(
                x => x.ConnectionString == "Data Source=server;Initial Catalog=database;Integrated Security=SSPI" &&
                x.Statement == "WAITFOR DELAY '00:00:15'" &&
                x.Timeout == new TimeSpan(0, 0, 30)
                );

            var factory = new SqlCommandFactory();
            var cmd     = factory.Instantiate(conn, query, null);

            Assert.IsInstanceOf <SqlCommand>(cmd.Implementation);
            Assert.That((cmd.Implementation as SqlCommand).CommandTimeout, Is.EqualTo(30));
        }
        public void Instantiate_NoParameter_CorrectResultSet()
        {
            var client = new SqlClientFactory().Instantiate(ConnectionStringReader.GetLocaleSql()) as SqlClient;
            var query  = Mock.Of <IQuery>(
                x => x.Statement == "SELECT * FROM FoF f WHERE f.label='person'"
                );
            var factory   = new SqlCommandFactory();
            var command   = (factory.Instantiate(client, query, null).Implementation) as SqlCommandOperation;
            var statement = command.Create();

            var clientOperation = client.CreateClientOperation();
            var results         = clientOperation.Run(statement);

            Assert.That(results.Count, Is.EqualTo(4));
        }