Grad.Codebook.Testing
2.0.3
See the version list below for details.
dotnet add package Grad.Codebook.Testing --version 2.0.3
NuGet\Install-Package Grad.Codebook.Testing -Version 2.0.3
<PackageReference Include="Grad.Codebook.Testing" Version="2.0.3" />
<PackageVersion Include="Grad.Codebook.Testing" Version="2.0.3" />
<PackageReference Include="Grad.Codebook.Testing" />
paket add Grad.Codebook.Testing --version 2.0.3
#r "nuget: Grad.Codebook.Testing, 2.0.3"
#:package Grad.Codebook.Testing@2.0.3
#addin nuget:?package=Grad.Codebook.Testing&version=2.0.3
#tool nuget:?package=Grad.Codebook.Testing&version=2.0.3
Grad.Codebook.Testing
Testing utilities for Grad Codebook. This package allows projects that depend on Codebook to test functionality that requires database access.
Purpose
The Grad.Codebook package exposes data through database views that query from the EDW (Enterprise Data Warehouse). For testing purposes, projects need a way to set up a test database without depending on the EDW. This package provides that capability by creating tables instead of views and populating them with representative test data.
Usage
using Grad.Codebook.Testing;
// Create an instance with your test database connection string
var testDb = new CodebookTestDatabase(connectionString);
// Set up the database (creates tables and inserts test data)
testDb.Setup();
// Or use async version
await testDb.SetupAsync();
Test Data Constants
Instead of using magic strings in your tests, use the TestData class to access test data objects with all their properties:
using Grad.Codebook.Testing;
// Access test data as full objects with properties
var csProgram = TestData.GradPrograms.ComputerScienceMS;
Assert.Equal("10KS0112MS", csProgram.ProgramCode);
Assert.Equal("Computer Science", csProgram.MajorTitle);
// Use department codes
var csDepartment = TestData.Departments.ComputerScience;
Assert.Equal("434", csDepartment.DepartmentCode);
Assert.Equal("Department of Computer Science", csDepartment.FullName);
// Access all types of test data
var engineering = TestData.Colleges.Engineering;
var phdDegree = TestData.Degrees.PhD;
var mathMinor = TestData.Minors.Mathematics;
var csSubject = TestData.Subjects.ComputerScience;
Available test data categories:
TestData.Colleges- Test collegesTestData.Departments- Test departmentsTestData.Degrees- Test degreesTestData.GradPrograms- Test graduate programsTestData.Minors- Test minorsTestData.Majors- Test majorsTestData.Subcolleges- Test subcollegesTestData.Subjects- Test subjectsTestData.Concentrations- Test concentrationsTestData.Curriculums- Test curriculums
What it Does
The CodebookTestDatabase class:
- Creates the Codebook database if it doesn't exist
- Drops existing tables if they exist (to ensure a clean state)
- Creates tables that match the structure of the Codebook views:
- colleges
- departments
- concentrations
- curriculums
- degrees
- subcolleges
- subjects
- grad_programs
- minors
- majors
- joint_programs
- major_concentrations
- program_concentrations
- department_names
- program_names
- Inserts test data with representative examples of each entity type
Test Data
The package includes sample data for:
- 3 colleges (Engineering, Liberal Arts & Sciences, Graduate College)
- 3 departments (Computer Science, Mathematics, ECE)
- 4 graduate programs (CS MS, CS PhD, Math MS, Math PhD)
- 2 minors (CS, Math)
- 2 majors (CS, Math)
- 2 concentrations (AI, Database Systems)
- And corresponding relationships between these entities
Notes
While it's not ideal for dependent projects to use the database directly, this approach is necessary for scenarios involving complex joins that aren't feasible with API calls.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Dapper (>= 2.1.66)
- Grad.Codebook (>= 2.0.3)
- Microsoft.Data.SqlClient (>= 6.1.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.