Skip to content

Unit Tests

Alessio Di Salvo edited this page Oct 30, 2026 · 4 revisions

Unit Tests (ModularNet.UnitTests)

The ModularNet.UnitTests project verifies ModularNet.Business managers in isolation using xUnit and Moq.

For mandatory test naming conventions and helper rules, see Coding Standards — Section 4 (Tests).

Structure

  • Test Classes:
    • UsersManagerTests.cs: Tests user registration, transaction-coordinated login, and retrieval in UsersManager.
    • UsersSettingsManagerTests.cs: Tests user settings caching, retrieval, and transaction-coordinated batch updates.
    • UnitOfWorkTests.cs: Tests transaction coordination delegation to IDbConnectionFactory.
    • DbConnectionFactoryTests.cs: Tests scoped connection lifecycle, transaction begin, commit, rollback, and disposal in DbConnectionFactory.
    • CacheManagerTests.cs: Tests in-memory and Redis cache routing in CacheManager.
    • EncryptManagerTests.cs: Tests AES encryption/decryption, hashing, and verification codes in EncryptManager.
  • Test Data Helpers (Helpers/):
    • UsersHelper.GetUser(): Returns a populated User instance so tests only override properties relevant to the case under test.
    • UserSettingsHelper: Returns populated UserSetting, UserSettingDto, and CreateOrUpdateUserSettingsRequest instances.
    • AppSettingsHelper.GetAppSettings(): Returns a populated AppSettings instance for unit tests.

Clone this wiki locally