Trace: » databaseenvironment
DatabaseEnvironment
Generic class to control the connection properties for standalone fixtures (when DatabaseTest is not used); supports connecting to databases, Commit and Rollback.
This fixture allows you to access the current database environment instance or change it.
- If the fixture has an argument, then it changes the current database environment instance. The argument should describe the type of new database environment instance. Supported values for the fixture argument are
oracle,sqlserverandmysql. You will want to use it in this mode to connect to the database. Note that you do not have to re-initialise the database environment to connect to another database of the same type (just use theConnectmethod again). - If it does not have an argument, it uses the current instance. You will want to use it in this mode to commit, rollback, or connect to another database of the same type.
Most DbFit fixtures can be used in standalone mode with exactly the same syntax as in flow mode if you import the dbfit.fixture namespace. For example, DatabaseTest retrieves the dbfit.fixture.Query fixture in flow mode when you call its Query method. So, by importing dbfit.fixture namespace, your table calls that fixture directly. In flow mode, dbfit.fixture.Query gets the connection properties from DatabaseTest. In standalone mode, it will call out to the environment set up by DatabaseEnvironment fixture.
See standalone and flow mode comparison for more information on how to connect and manage transactions in standalone mode.
|import fixture| |dbfit.fixture| !|DatabaseEnvironment|oracle| |connect|localhost:1521|dftest|dftest|xe| !|Execute|Create table Test_DBFit(name varchar2(50), luckyNumber number)| !|Insert| |Test_DBFit| |name|luckyNumber| |pera|1| |nuja|2| |nnn|3| !|Query|Select * from Test_DBFit| |name|lucky Number| |pera|1| |nuja|2| |nnn|3| !|Execute|Drop table Test_DBFit| !|DatabaseEnvironment| |rollback|
For more examples, download the dbfit-complete package and then look at DotNet.AcceptanceTests.OracleAcceptanceTests.StandaloneFixtures, DotNet.AcceptanceTests.SqlServerAcceptanceTests.StandaloneFixtures, NewJava.AcceptanceTests.OracleTests.StandaloneFixtures and NewJava.AcceptanceTests.MySqlTests.StandaloneFixtures namespaces.
