How can I implement a unit test for database transfer from remote server into localhost using smo. Also is it possible to test the sql connection? I don't have so much experience in Moq , NUnit. Any recommendations are highly appreciated.
Asked
Active
Viewed 301 times
1 Answers
1
This is a better suited question for StackOverflow but NUnit is a pretty standard and easy to use Unit Testing framework. You can follow this guide by Microsoft on Testing with NUnit.
Testing that the connection string for the server is valid and the server is online make for good Unit Tests, also doing some mock schema changes to your Source Database, running your SMO process, and testing the changes are replicated on the Target Database is a good Unit Test.
Ideally you should have a Unit Test for each piece of your database you want replicated from Source to Target, e.g. the Table schema, the data, indexes, constraints (primary keys, foreign keys), database properties and extended properties, etc.

J.D.
- 954
- 6
- 22
-
1Testing a server is online is integration testing, not unit testing. – Charlieface Jan 31 '21 at 05:10
-
@Charlieface Hi again ;). I respectfully disagree. **Integration Testing** is ["*Integration testing is the phase in software testing in which individual software modules are combined and tested as a group*"](https://en.m.wikipedia.org/wiki/Integration_testing). Individually testing if a server is online in an isolated single test is a valid **Unit Test**, as it is a specific single thing being tested (independent of the integration of multiple pieces of software). – J.D. Jan 31 '21 at 05:14