Data access, unit testing, dependency injection

后端 未结 3 1253
伪装坚强ぢ
伪装坚强ぢ 2020-12-21 04:29

I\'ve recently got a task to create a simple utility that allows to import data from a file with special format to the database. I\'ve implemented console application with f

3条回答
  •  轮回少年
    2020-12-21 05:09

    Assuming that you are using LINQ to SQL, maybe you could use the repository pattern to wrap the DataContext into an interface that you can later mock, thus making unit testing possible.

    There are some articles about this subject around the internet, here is one: http://andrewtokeley.net/archive/2008/07/06/mocking-linq-to-sql-datacontext.aspx

提交回复
热议问题