Skip to content

Commit 617de74

Browse files
Expand class dependency fixtures for loader stress
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent eb84442 commit 617de74

35 files changed

Lines changed: 439 additions & 173 deletions

.github/actions/Build-PSModule/src/helpers/Build/Get-DependencyOrderedScriptFiles.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function Get-DependencyOrderedScriptFiles {
5555
continue
5656
}
5757

58-
$typePattern = "(?<![\w\.])\[$([Regex]::Escape($typeName))\](?![\w\.])"
58+
$typePattern = "(?<![\w\.])\[$([Regex]::Escape($typeName))(?:\[\])?\](?![\w\.])"
5959
if ([Regex]::IsMatch($metadata.Content, $typePattern, [System.Text.RegularExpressions.RegexOptions]::IgnoreCase)) {
6060
$dependencyPath = $typeToPath[$typeName]
6161
[void]$dependenciesByPath[$metadata.File.FullName].Add($dependencyPath)

tests/srcTestRepo/src/classes/public/A-BookList.ps1

Lines changed: 0 additions & 86 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class ActiveLoanRegister {
2+
[System.Collections.Generic.List[BookLoan]] $Loans
3+
4+
ActiveLoanRegister() {
5+
$this.Loans = [System.Collections.Generic.List[BookLoan]]::new()
6+
}
7+
8+
[void] AddLoan([BookLoan]$Loan) {
9+
$this.Loans.Add($Loan)
10+
}
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class AuthorIndex {
2+
[string] $Name
3+
[AuthorProfile[]] $Authors
4+
[ZCatalog] $Catalog
5+
6+
AuthorIndex([string]$Name, [ZCatalog]$Catalog) {
7+
$this.Name = $Name
8+
$this.Catalog = $Catalog
9+
$this.Authors = @()
10+
}
11+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class AuthorProfile {
2+
[string] $Name
3+
[Book[]] $PublishedBooks
4+
5+
AuthorProfile([string]$Name, [Book[]]$PublishedBooks) {
6+
$this.Name = $Name
7+
$this.PublishedBooks = $PublishedBooks
8+
}
9+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class BookCopy {
2+
[string] $InventoryId
3+
[Book] $Book
4+
[ShelfLocation] $Location
5+
6+
BookCopy([string]$InventoryId, [Book]$Book, [ShelfLocation]$Location) {
7+
$this.InventoryId = $InventoryId
8+
$this.Book = $Book
9+
$this.Location = $Location
10+
}
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class BookInventory {
2+
[string] $Name
3+
[BookCopy[]] $Copies
4+
[ZCatalog] $Catalog
5+
6+
BookInventory([string]$Name, [ZCatalog]$Catalog) {
7+
$this.Name = $Name
8+
$this.Catalog = $Catalog
9+
$this.Copies = @()
10+
}
11+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
class BookList {
2+
static [System.Collections.Generic.List[Book]] $Books
3+
4+
static [void] Initialize() { [BookList]::Initialize($false) }
5+
static [bool] Initialize([bool]$force) {
6+
if ([BookList]::Books.Count -gt 0 -and -not $force) {
7+
return $false
8+
}
9+
10+
[BookList]::Books = [System.Collections.Generic.List[Book]]::new()
11+
12+
return $true
13+
}
14+
15+
static [void] Validate([Book]$Book) {
16+
$Prefix = @(
17+
'Book validation failed: Book must be defined with the Title,'
18+
'Author, and PublishDate properties, but'
19+
) -join ' '
20+
if ($null -eq $Book) { throw "$Prefix was null" }
21+
if ([string]::IsNullOrEmpty($Book.Title)) { throw "$Prefix Title wasn't defined" }
22+
if ([string]::IsNullOrEmpty($Book.Author)) { throw "$Prefix Author wasn't defined" }
23+
if ([datetime]::MinValue -eq $Book.PublishDate) { throw "$Prefix PublishDate wasn't defined" }
24+
}
25+
26+
static [void] Add([Book]$Book) {
27+
[BookList]::Initialize()
28+
[BookList]::Validate($Book)
29+
if ([BookList]::Books.Contains($Book)) { throw "Book '$Book' already in list" }
30+
31+
$findPredicate = {
32+
param([Book]$b)
33+
34+
$b.Title -eq $Book.Title -and
35+
$b.Author -eq $Book.Author -and
36+
$b.PublishDate -eq $Book.PublishDate
37+
}.GetNewClosure()
38+
if ([BookList]::Books.Find($findPredicate)) { throw "Book '$Book' already in list" }
39+
40+
[BookList]::Books.Add($Book)
41+
}
42+
43+
static [void] Clear() {
44+
[BookList]::Initialize()
45+
[BookList]::Books.Clear()
46+
}
47+
48+
static [Book] Find([scriptblock]$Predicate) {
49+
[BookList]::Initialize()
50+
return [BookList]::Books.Find($Predicate)
51+
}
52+
53+
static [Book[]] FindAll([scriptblock]$Predicate) {
54+
[BookList]::Initialize()
55+
return [BookList]::Books.FindAll($Predicate)
56+
}
57+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class BookLoan {
2+
[BookCopy] $Copy
3+
[MemberAccount] $Member
4+
[datetime] $LoanDate
5+
[datetime] $DueDate
6+
7+
BookLoan([BookCopy]$Copy, [MemberAccount]$Member, [DueDatePolicy]$Policy) {
8+
$this.Copy = $Copy
9+
$this.Member = $Member
10+
$this.LoanDate = Get-Date
11+
$this.DueDate = $this.LoanDate.AddDays($Policy.StandardLoanDays)
12+
}
13+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class BranchLibrary {
2+
[string] $Code
3+
[string] $Name
4+
[OpeningHours] $Hours
5+
6+
BranchLibrary([string]$Code, [string]$Name, [OpeningHours]$Hours) {
7+
$this.Code = $Code
8+
$this.Name = $Name
9+
$this.Hours = $Hours
10+
}
11+
}

0 commit comments

Comments
 (0)