示例#1
0
 public void VerifyOrdersSqliteNoDriverString()
 {
     using (DatabaseDriver driver = new DatabaseDriver("SQLITE", $"Data Source={ GetDByPath() }"))
     {
         var orders = driver.Query("select * from orders").ToList();
         Assert.AreEqual(11, orders.Count);
     }
 }
示例#2
0
        public void SellArticle_Failure()
        {
            DatabaseDriver databaseDriver = new DatabaseDriver();
            Logger         logger         = new Logger();
            ShopService    shopService    = new ShopService(databaseDriver, logger, new List <ISupplier>());

            shopService.SellArticle(null, -1, 1);
        }
示例#3
0
        public void OrderArticle_Failure()
        {
            DatabaseDriver databaseDriver = new DatabaseDriver();
            Logger         logger         = new Logger();
            ShopService    shopService    = new ShopService(databaseDriver, logger, new List <ISupplier>());

            Assert.AreEqual(null, shopService.OrderArticle(1, 100));
        }
示例#4
0
 public void InsertsNullObject(DatabaseDriver database)
 {
     using var con = database.GetConnection();
     var id = con.Insert(new Lead
     {
         Email = "*****@*****.**",
         Data  = null !,
     });
示例#5
0
        public void GetArticleById_Failure()
        {
            DatabaseDriver databaseDriver = new DatabaseDriver();
            Logger         logger         = new Logger();
            ShopService    shopService    = new ShopService(databaseDriver, logger, new List <ISupplier>());

            Assert.AreEqual(-1, shopService.GetArticleById(1).ID);
        }
示例#6
0
        public void VerifyStateTableExistsNoDriver()
        {
            DatabaseDriver driver = new DatabaseDriver();

            var table = driver.Query("SELECT * FROM information_schema.tables");

            Assert.IsTrue(table.Any(n => n.TABLE_NAME.Equals("States")));
        }
示例#7
0
        public void VerifyProceduresActionWithNoUpdatesNoDriver()
        {
            DatabaseDriver driver = new DatabaseDriver(DatabaseConfig.GetProviderTypeString(), DatabaseConfig.GetConnectionString());

            var result = driver.Execute("setStateAbbrevToSelf", new { StateAbbreviation = "ZZ" }, commandType: CommandType.StoredProcedure);

            Assert.AreEqual(0, result, "Expected 0 state abbreviation to be updated.");
        }
示例#8
0
        public void VerifyProceduresQueryWithoutResultNoDriver()
        {
            DatabaseDriver driver = new DatabaseDriver(DatabaseConfig.GetProviderTypeString(), DatabaseConfig.GetConnectionString());

            var result = driver.Query("getStateAbbrevMatch", new { StateAbbreviation = "ZZ" }, commandType: CommandType.StoredProcedure);

            Assert.AreEqual(0, result.Count(), "Expected 0 state abbreviation to be returned.");
        }
 public void SetUp()
 {
     container = DatabaseDriver.GetFullFastPackContainer();
     container.Configure(x =>
     {
         x.UseOnDemandNHibernateTransactionBoundary();
     });
 }
示例#10
0
 public void VerifyOrdersSqliteNoDriverDefault()
 {
     using (DatabaseDriver driver = new DatabaseDriver())
     {
         var orders = driver.Query("select * from orders").ToList();
         Assert.AreEqual(11, orders.Count);
     }
 }
示例#11
0
        public async Task SelectAndStatementAsync(DatabaseDriver database)
        {
            using var con = database.GetConnection();
            var id = await InsertLeadAsync(con);

            var leads = await con.SelectAsync <Lead>(p => p.Data !.FirstName == "Foo" && p.Data.LastName == "Bar" && p.Email == "*****@*****.**");

            Assert.NotEmpty(leads);
        }
示例#12
0
        public void SellArticle_Success()
        {
            DatabaseDriver databaseDriver = new DatabaseDriver();
            Logger         logger         = new Logger();
            ShopService    shopService    = new ShopService(databaseDriver, logger, new List <ISupplier>());

            shopService.SellArticle(new FirstSupplier(new Article(1, "Test", 1)), 1, 9);
            Assert.AreEqual(9, databaseDriver.GetArticleByID(1).BuyerUserID);
        }
示例#13
0
        /// <summary>
        /// Konstruktor mit Smart Meter Id
        /// </summary>
        /// <param name="_meterId">Fremdschlüssel zu Meter Management Tabelle</param>
        public MeterData(int _meterId)
        {
            DatabaseDriver driver = new DatabaseDriver();
            this.dataId = driver.GetUniqueMeterDataId();
            this.meterId = _meterId;
            driver.CloseConnection();

            this.timestamp = "946684800";
        }
示例#14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConnectionInfo"/> struct.
 /// </summary>
 /// <param name="driver">The <see cref="DatabaseDriver"/> value representing the database driver to use.</param>
 /// <param name="database">The name of the database.</param>
 /// <param name="host">The address of the database host.</param>
 /// <param name="user">The name of the database user to use.</param>
 /// <param name="pass">The password for the database user.</param>
 /// <param name="port">The port for the database server.</param>
 public ConnectionInfo(DatabaseDriver driver, string database, string host, string user, string pass, uint port = 3306)
 {
     this.Driver   = driver;
     this.Database = database;
     this.Host     = host;
     this.User     = user;
     this.Pass     = pass;
     this.Port     = port;
 }
示例#15
0
 public void Get(DatabaseDriver database)
 {
     using (var con = database.GetConnection())
     {
         var product = con.Get <Product>(1);
         Assert.NotNull(product);
         Assert.NotEmpty(product.Name);
     }
 }
        public void VerifyDataTableCountMatch()
        {
            var states      = DatabaseDriver.Query("SELECT * FROM States").ToList();
            var statesTable = DatabaseUtils.ToDataTable(states);

            // Our database only has 49 states
            Assert.AreEqual(states.Count, statesTable.Rows.Count, "Expected 49 states.");
            Assert.AreEqual(49, statesTable.Rows.Count, "Expected 49 states.");
        }
        public void VerifyDataTableColumnsCount()
        {
            var states      = DatabaseDriver.Query("SELECT * FROM States").ToList();
            var statesTable = DatabaseUtils.ToDataTable(states);

            // Validate Column Count
            Assert.AreEqual(3, statesTable.Columns.Count);
            Assert.AreEqual(((IDictionary <string, object>)states.First()).Keys.Count, statesTable.Columns.Count);
        }
示例#18
0
        public async Task SelectAsyncEqual(DatabaseDriver database)
        {
            using (var con = database.GetConnection())
            {
                var products = await con.SelectAsync <Product>(p => p.CategoryId == 1);

                Assert.Equal(10, products.Count());
            }
        }
示例#19
0
        protected async Task <DbConnection> GetConnectionAsync(CancellationToken cancellationToken)
        {
            await Table.SynchronizeSchemaAsync(ConnectionString, DatabaseDriver, cancellationToken).ConfigureAwait(false);

            var connection = DatabaseDriver.CreateConnection(ConnectionString);
            await connection.OpenAsync(cancellationToken).ConfigureAwait(false);

            return(connection);
        }
示例#20
0
 public void Project(DatabaseDriver database)
 {
     using (var con = database.GetConnection())
     {
         var p = con.Project <ProductSmall>(1);
         Assert.NotEqual(0, p.Id);
         Assert.NotNull(p.Name);
     }
 }
示例#21
0
        public void SetUp()
        {
            SchemaWriter.RemovePersistedConfiguration();

            DatabaseDriver.Bootstrap(true);

            container = DatabaseDriver.ContainerWithDatabase();
            source    = container.GetInstance <IConfigurationSource>();
        }
示例#22
0
 public void GetAll(DatabaseDriver database)
 {
     using (var con = database.GetConnection())
     {
         var products = con.GetAll <Product>();
         Assert.NotEmpty(products);
         Assert.All(products, p => Assert.NotEmpty(p.Name));
     }
 }
示例#23
0
        public void VerifyStateTableHasCorrectNumberOfRecordsNoDriver()
        {
            DatabaseDriver driver = new DatabaseDriver();

            var table = driver.Query("SELECT * FROM States").ToList();

            // Our database only has 49 states
            Assert.AreEqual(49, table.Count, "Expected 49 states.");
        }
 /// <summary>
 /// Do database setup for test run
 /// </summary>
 // [ClassInitialize] - Disabled because this step will fail as the template does not include access to a test database
 public static void TestSetup(TestContext context)
 {
     // Do database setup
     using (DatabaseDriver wrapper = new DatabaseDriver(DatabaseConfig.GetProviderTypeString(), DatabaseConfig.GetConnectionString()))
     {
         var result = wrapper.Query("getStateAbbrevMatch", new { StateAbbreviation = "MN" }, commandType: CommandType.StoredProcedure);
         Assert.AreEqual(1, result.Count(), "Expected 1 state abbreviation to be returned.");
     }
 }
示例#25
0
        public async Task SelectAsyncContains(DatabaseDriver database)
        {
            using (var con = database.GetConnection())
            {
                var products = await con.SelectAsync <Product>(p => p.Name.Contains("Anton"));

                Assert.Equal(4, products.Count());
            }
        }
示例#26
0
        public void try_to_build_out_the_test_harness_case_grid()
        {
            var container = DatabaseDriver.GetFullFastPackContainer();

            container.ExecuteInTransaction <CaseController>(x =>
            {
                Debug.WriteLine(x.AllCases().ToString());
            });
        }
示例#27
0
        /// <summary>
        /// Default constructor
        /// </summary>
        /// <param name="databaseDriver">
        /// A connection to a database
        /// If the databaseDriver is null, then the server will attempt to create it's own connection
        /// otherwise it will use the specified connection
        /// </param>
        public ChatServer(string serverName, DatabaseDriver databaseDriver, IPEndPoint bindTo, int MaxConnections) : base(serverName, bindTo, MaxConnections)
        {
            ChatHandler.DBQuery = new ChatDBQuery(databaseDriver);

            ChatClient.OnDisconnect += ClientDisconnected;

            // Begin accepting connections
            StartAcceptAsync();
        }
示例#28
0
        protected static Dictionary <string, object> GetUserDataReal(DatabaseDriver databaseDriver, string AppendFirst, string SecondAppend, string _P0, string _P1)
        {
            var Rows = databaseDriver.Query("SELECT profiles.profileid, profiles.firstname, profiles.lastname, profiles.publicmask, profiles.latitude, profiles.longitude, " +
                                            "profiles.aim, profiles.picture, profiles.occupationid, profiles.incomeid, profiles.industryid, profiles.marriedid, profiles.childcount, profiles.interests1, " +
                                            @"profiles.ownership1, profiles.connectiontype, profiles.sex, profiles.zipcode, profiles.countrycode, profiles.homepage, profiles.birthday, profiles.birthmonth, " +
                                            @"profiles.birthyear, profiles.location, profiles.icq, profiles.status, users.password, users.userstatus " + AppendFirst +
                                            " FROM profiles INNER JOIN users ON profiles.userid = users.userid WHERE " + SecondAppend, _P0, _P1);

            return((Rows.Count == 0) ? null : Rows[0]);
        }
示例#29
0
        public static Dictionary <string, object> GetProfileInfo(DatabaseDriver databaseDriver, uint id)
        {
            var Rows = databaseDriver.Query("SELECT profiles.profileid, profiles.firstname, profiles.lastname, profiles.publicmask, profiles.latitude, profiles.longitude, " +
                                            "profiles.aim, profiles.picture, profiles.occupationid, profiles.incomeid, profiles.industryid, profiles.marriedid, profiles.childcount, profiles.interests1, " +
                                            @"profiles.ownership1, profiles.connectiontype, profiles.sex, profiles.zipcode, profiles.countrycode, profiles.homepage, profiles.birthday, profiles.birthmonth, " +
                                            @"profiles.birthyear, profiles.location, profiles.icq, profiles.status, profiles.nick, profiles.uniquenick, users.email FROM profiles " +
                                            @"INNER JOIN users ON profiles.userid = users.userid WHERE profileid=@P0", id);

            return((Rows.Count == 0) ? null : Rows[0]);
        }
示例#30
0
        public async Task GetAllAsync(DatabaseDriver database)
        {
            using (var con = database.GetConnection())
            {
                var products = await con.GetAllAsync <Product>();

                Assert.NotEmpty(products);
                Assert.All(products, p => Assert.NotEmpty(p.Name));
            }
        }
 /// <summary>
 /// Sets the database driver
 /// </summary>
 /// <param name="factory"></param>
 public SelectQueryBuilder(DatabaseDriver Driver)
 {
     this.Driver= Driver;
 }
 public UpdateQueryBuilder(DatabaseDriver Driver)
 {
     this.Driver = Driver;
 }
 /// <summary>
 /// Creates a new instance of InsertQueryBuilder with the provided Database Driver.
 /// </summary>
 /// <param name="Table">The table we are inserting into</param>
 /// <param name="Driver">The DatabaseDriver that will be used to query this SQL statement</param>
 public InsertQueryBuilder(string Table, DatabaseDriver Driver)
 {
     this.Table = Table;
     this.Driver = Driver;
 }
 /// <summary>
 /// Sets the database driver
 /// </summary>
 /// <param name="Driver"></param>
 public void SetDbDriver(DatabaseDriver Driver)
 {
     this.Driver = Driver;
 }
 /// <summary>
 /// Creates a new instance of InsertQueryBuilder with the provided Database Driver.
 /// </summary>
 /// <param name="Driver">The DatabaseDriver that will be used to query this SQL statement</param>
 public InsertQueryBuilder(DatabaseDriver Driver)
 {
     this.Driver = Driver;
 }