$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib') require 'test/unit' require 'ostruct' require 'og' require 'og/adapters/sqlserver' if defined?(DBI) class TC_OgSqlserver < Test::Unit::TestCase # :nodoc: all # Forward declaration. class Comment; end class Article prop_accessor :name, String prop_accessor :age, Fixnum has_many :comments, Comment def initialize (name = nil, age = nil) @name, @age = name, age end end class Comment prop_accessor :text, String belongs_to :article, Article def initialize(text = nil) @text = text end end def setup config = { :adapter => 'sqlserver', :address => 'localhost', :database => 'test', :user => 'sa', :password => 'sa', :connection_count => 2 } $DBG = true # Og::Database.drop_db!(config) @og = Og::Database.new(config) end def teardown @og.shutdown end def test_all puts Article.all.size Article.each {|a| a.delete! } puts Article.all.size a = Article.new('gmosx', 30) a.save! baseoid = a.oid a1 = Article[baseoid] assert_equal 'gmosx', a1.name assert_equal 30, a1.age assert_equal baseoid, a1.oid Article.create('drak', 12) Article.create('ekarak', 34) Article.create('mario', 53) Article.create('elathan', 34) articles = Article.all assert_equal 5, articles.size a3 = Article['ekarak'] assert_equal 'ekarak', a3.name c1 = Comment.new('a comment') c1.save! a3.add_comment(c1) a5 = Article['ekarak'] assert_equal 1, a5.comments.size end end end