docs: update documentation for extraction functions migration
- Add ExtractionFunctions.md reference document - Update database-schema spec with 11 extraction functions - Update data-access spec to document extraction function approach - Update search-processing spec with new query builder interface - Add Database.Tests to Testing.md architecture doc - Update DataFlow.md with extraction function flow
This commit is contained in:
@@ -5,22 +5,34 @@ The test project uses xUnit for the framework, Shouldly for assertions, and NSub
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
JdeScoping.Tests/
|
||||
├── Unit/
|
||||
│ ├── Services/
|
||||
│ │ ├── SearchServiceTests.cs
|
||||
│ │ ├── ExcelExportServiceTests.cs
|
||||
│ │ └── DataSyncOrchestratorTests.cs
|
||||
│ ├── Repositories/
|
||||
│ │ └── SearchRepositoryTests.cs
|
||||
│ └── Models/
|
||||
│ └── SearchCriteriaTests.cs
|
||||
└── Integration/
|
||||
├── ApiTests/
|
||||
│ ├── SearchControllerTests.cs
|
||||
│ └── LookupControllerTests.cs
|
||||
└── RepositoryTests/
|
||||
└── JdeRepositoryTests.cs
|
||||
tests/
|
||||
├── JdeScoping.Tests/
|
||||
│ ├── Unit/
|
||||
│ │ ├── Services/
|
||||
│ │ │ ├── SearchServiceTests.cs
|
||||
│ │ │ ├── ExcelExportServiceTests.cs
|
||||
│ │ │ └── DataSyncOrchestratorTests.cs
|
||||
│ │ ├── Repositories/
|
||||
│ │ │ └── SearchRepositoryTests.cs
|
||||
│ │ └── Models/
|
||||
│ │ └── SearchCriteriaTests.cs
|
||||
│ └── Integration/
|
||||
│ ├── ApiTests/
|
||||
│ │ ├── SearchControllerTests.cs
|
||||
│ │ └── LookupControllerTests.cs
|
||||
│ └── RepositoryTests/
|
||||
│ └── JdeRepositoryTests.cs
|
||||
├── JdeScoping.Api.IntegrationTests/
|
||||
│ └── ... (API integration tests)
|
||||
└── JdeScoping.Database.Tests/
|
||||
├── Infrastructure/
|
||||
│ └── DatabaseTestBase.cs
|
||||
├── Functions/
|
||||
│ ├── ScalarFunctionTests.cs
|
||||
│ ├── SimpleTableFunctionTests.cs
|
||||
│ └── ComplexTableFunctionTests.cs
|
||||
└── Procedures/
|
||||
└── ValidateSearchCriteriaProcedureTests.cs
|
||||
```
|
||||
|
||||
## Unit Tests
|
||||
@@ -175,7 +187,64 @@ public class SearchRepositoryIntegrationTests : IDisposable
|
||||
}
|
||||
```
|
||||
|
||||
## Database Tests
|
||||
|
||||
The `JdeScoping.Database.Tests` project tests SQL functions and stored procedures against a live SQL Server instance.
|
||||
|
||||
### Test Infrastructure
|
||||
|
||||
Tests inherit from `DatabaseTestBase` which provides:
|
||||
- Connection management via `DatabaseTestFixture`
|
||||
- Automatic test data cleanup
|
||||
- Helper methods for inserting test searches
|
||||
|
||||
```csharp
|
||||
[Collection("DatabaseTests")]
|
||||
public class ScalarFunctionTests : DatabaseTestBase
|
||||
{
|
||||
[Fact]
|
||||
public async Task fn_GetSearchMinimumDt_ValidSearch_ReturnsDateTime()
|
||||
{
|
||||
// Arrange
|
||||
var criteria = new SearchCriteria { MinimumDt = new DateTime(2024, 6, 15) };
|
||||
var searchId = await InsertTestSearchAsync(criteria);
|
||||
|
||||
// Act
|
||||
var result = await Connection.QuerySingleOrDefaultAsync<DateTime?>(
|
||||
"SELECT dbo.fn_GetSearchMinimumDt(@SearchId)",
|
||||
new { SearchId = searchId });
|
||||
|
||||
// Assert
|
||||
result.Should().BeCloseTo(criteria.MinimumDt.Value, TimeSpan.FromSeconds(1));
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Test Categories
|
||||
|
||||
| Category | Tests | Description |
|
||||
|----------|-------|-------------|
|
||||
| Scalar Functions | 15 | Test `fn_GetSearchMinimumDt`, `fn_GetSearchMaximumDt`, `fn_GetSearchExtractMisData` |
|
||||
| Simple Table Functions | 38 | Test array extraction for work orders, items, profit centers, work centers, operators |
|
||||
| Complex Table Functions | 23 | Test object extraction for component lots and part operations |
|
||||
| Validation Procedure | 6 | Test `usp_ValidateSearchCriteria` error handling |
|
||||
|
||||
**Total: 82 database tests**
|
||||
|
||||
### Running Database Tests
|
||||
|
||||
```bash
|
||||
# Run all database tests
|
||||
dotnet test tests/JdeScoping.Database.Tests
|
||||
|
||||
# Run specific test class
|
||||
dotnet test tests/JdeScoping.Database.Tests --filter "FullyQualifiedName~ScalarFunctionTests"
|
||||
```
|
||||
|
||||
**Prerequisites**: SQL Server must be running on localhost:1434 with the ScopingTool database.
|
||||
|
||||
## Related Documentation
|
||||
|
||||
- [Core Project](./CoreProject.md)
|
||||
- [Dependencies](./Dependencies.md)
|
||||
- [Database](./Database.md)
|
||||
|
||||
Reference in New Issue
Block a user