草庐IT

unit-testing - FluentNhibernate 和 SQLite

coder 2023-07-21 原文

我无法让 SQLite 驱动程序在我的 session 工厂中工作。

我从 http://sqlite.phxsoftware.com/ 下载了 SQLite 1.0.48

我在我的测试项目中添加了对 System.Data.SQLite 的引用。

public static IPersistenceConfigurer GetSqlLiteConfigurer()
        {
            try
            {
                return SQLiteConfiguration
                .Standard
                .InMemory();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

这就是我生成配置器的方式

问题是当我构建 session 工厂时出现以下错误:

NHibernate.HibernateException: The IDbCommand and IDbConnection implementation in the assembly System.Data.SQLite could not be found. Ensure that the assembly System.Data.SQLite is located in the application directory or in the Global Assembly Cache. If the assembly is in the GAC, use <qualifyAssembly/> element in the application configuration file to specify the full name of the assembly.
at NHibernate.Driver.ReflectionBasedDriver..ctor(String driverAssemblyName, String connectionTypeName, String commandTypeName)
at NHibernate.Driver.SQLite20Driver..ctor() 

我尝试更改 SQLite 版本但没有解决问题。

我找不到问题所在,我已经为此工作了 2 天。

如果您需要更多信息,请告诉我。

感谢您的帮助!

查尔斯

最佳答案

当我遇到这个问题时,它是由我的应用程序的处理器属性设置为 anycpu 并在 64 位系统上运行引起的。为更正此问题,我将我的应用程序处理器属性设置为 x86。 我认为 System.Data.SQLite.dll 不支持在 x64 进程下运行。

关于unit-testing - FluentNhibernate 和 SQLite,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/845490/

有关unit-testing - FluentNhibernate 和 SQLite的更多相关文章

  1. ruby-on-rails - rails : "missing partial" when calling 'render' in RSpec test - 2

    我正在尝试测试是否存在表单。我是Rails新手。我的new.html.erb_spec.rb文件的内容是:require'spec_helper'describe"messages/new.html.erb"doit"shouldrendertheform"dorender'/messages/new.html.erb'reponse.shouldhave_form_putting_to(@message)with_submit_buttonendendView本身,new.html.erb,有代码:当我运行rspec时,它失败了:1)messages/new.html.erbshou

  2. ruby - Sinatra + Heroku + Datamapper 使用 dm-sqlite-adapter 部署问题 - 2

    出于某种原因,heroku尝试要求dm-sqlite-adapter,即使它应该在这里使用Postgres。请注意,这发生在我打开任何URL时-而不是在gitpush本身期间。我构建了一个默认的Facebook应用程序。gem文件:source:gemcuttergem"foreman"gem"sinatra"gem"mogli"gem"json"gem"httparty"gem"thin"gem"data_mapper"gem"heroku"group:productiondogem"pg"gem"dm-postgres-adapter"endgroup:development,:t

  3. ruby 单元测试 : run some code after each failed test - 2

    在Test::Unit中的ruby​​单元测试断言失败后,在执行teardown之前,是否有一些简洁优雅的方法来立即执行我的代码?我正在做一些自动化的GUI测试,并希望在出现问题后立即截图。 最佳答案 如果您使用的是1.9,请不要使用Test::Unit::TestCase作为您的基类。对其进行子类化并覆盖#run_test以进行救援,截取屏幕截图并重新提出:classMyAbstractTestCase或者,我认为这实际上是最简洁的方法,您可以使用before_teardownHook:classMyTestCase这不适用于1.

  4. ruby-on-rails - 如何扩展 Ruby Test::Unit 断言以包含 assert_false? - 2

    显然在Test::Unit中没有assert_false。您将如何通过扩展断言并添加文件config/initializers/assertions_helper.rb来添加它?这是最好的方法吗?我不想修改test/unit/assertions.rb。顺便说一句,我不认为这是多余的。我使用的是assert_equalfalse,something_to_evaluate。这种方法的问题是很容易意外使用assertfalse,something_to_evaluate。这将始终失败,不会引发错误或警告,并且会在测试中引入错误。 最佳答案

  5. ruby-on-rails - 脚本/服务器 custom_require.rb :36:in `require' : cannot load such file -- test/unit/error (LoadError) - 2

    我有一个基于1.8.7构建的应用程序,我正尝试在1.9.3的系统上启动它当我运行脚本/服务器时,我得到:/usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in`require':cannotloadsuchfile--test/unit/error(LoadError)from/usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in`require'我的服务器脚本如下所示:#!/usr/bin/envrubyrequireFile.expand_path('../.

  6. ruby-on-rails - rspec rails 测试 : how can I force ActiveJob job's to run inline for certain tests? - 2

    我希望我的后台作业能够内联运行某些标记测试。我可以通过用perform_enqueueddo包装测试来做到这一点,但我希望能够用元数据标记它们,如果可能的话,它会自动发生。我试过以下方法:it"doeseverythinginthejobtoo",perform_enqueued:truedoendconfig.around(:each)do|example|ifexample.metadata[:perform_enqueued]perform_enqueued_jobsdoexample.runendendend但它会导致错误:undefinedmethod`perform_enq

  7. ruby-on-rails - Rails 5 升级 :/actionpack-5. 0.0/lib/action_controller/test_case.rb:49:in `initialize':参数数量错误(0 代表 2)(ArgumentError) - 2

    我最近正在进行Rails5升级,当我尝试启动Rails控制台时遇到了这个错误:/actionpack-5.0.0/lib/action_controller/test_case.rb:49:ininitialize':wrongnumberofarguments(0for2)(ArgumentError)当前bundleupdaterails已经完成了gem依赖项的解决,足以更新到5.0.0,rspec正在运行(尽管我正在修复很多中断)。我也可以运行railss没有错误。这里是代码中断行:https://github.com/rails/rails/blob/master/action

  8. ruby-on-rails - ruby rails : Best way to test a failed call to a third party API - 2

    我现在调用第三方网络服务作为我的应用程序的一部分。我正在使用RestClientgem来执行此操作。有大量工具可以用来做同样的事情,所以这应该无关紧要。我很好奇的是有足够好的测试,没有什么太花哨的,我可以在其中模拟当第三方Web服务出于任何原因不可用时我的应用程序如何响应。无论是我超出了速率限制还是由于网络延迟/并发症而超时,我只想能够获取HTTP状态代码之类的东西并测试我的应用程序在该事件中执行的操作。使用Test::Unit执行此操作的最佳方法是什么?现在,对第三方服务的调用封装在我的一个Controller中。我有一个简单的模块,其中包含一些用于远程服务不同端点的包装器方法。我只

  9. ruby - 我如何在不使用 ruby​​ 中的 sleep() 的情况下 rspec/test 一个 updated_at 字段? - 2

    如何在不使用sleep(1.second)方法的情况下编写规范?当我取消sleep时,我的测试会因为返回相同的时间戳而中断吗?我有以下类方法:defskipqs=find_or_create_by(user_id:user_id)qs.set_updated_atqs.n_skip+=1qs.save!end和以下规范:qs=skip(user.id)sleep(1.second)qs2=skip(user.id)qs.should_notbe_nilqs2.should_notbe_nil(qs.updated_at 最佳答案 我

  10. ruby - 创建新数据库时 DataMapper SQLite 错误 - 2

    我是Sinatra的新手,我正在尝试使用SQLite3和Datamapper创建一个数据库。我安装了gem和适配器,然后尝试在文件中执行此代码:#configrequire'sinatra'require'sinatra/contrib'ifdevelopment?require'data_mapper'DataMapper::setup(:default,"sqlite3://#{Dir.pwd}/recall.db")DataMapper.finalize.auto_upgrade!当我执行文件时,命令行给了我这个错误:C:/Ruby193/lib/ruby/site_ruby/1

随机推荐