Compile function Test_MetrologyServices(@Test)
#pragma precomp SRP_PreCompiler

$Insert LOGICAL

Declare subroutine Metrology_Services, Error_Services
Declare function Metrology_Services, Error_Services

Error_Services('Clear')

GotoTest

// TODO: Code to run after each test goes here

Return TestResult or 1

//-----------------------------------------------------------------------------
// TESTS
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
// GetCalculatedLayer Tests
//-----------------------------------------------------------------------------

Test GetCalculatedLayerEpiProWithoutWoIsEpiProOrScannedLayerShouldReturnL2
	CalculatedLayer = Metrology_Services('GetCalculatedLayer', 649130, 'BioRad', 2)
	Assert CalculatedLayer equals 2
end test

Test GetCalculatedLayerEpiProShouldReturnL2
	CalculatedLayer = Metrology_Services('GetCalculatedLayer', 649130, 'BioRad', 2, 1, 1)
	Assert CalculatedLayer equals 2
end test

Test GetCalculatedLayerSingleLayerNonEpiProWithoutWoIsEpiProOrScannedLayerShouldReturnL1
	CalculatedLayer = Metrology_Services('GetCalculatedLayer', 648685, 'BioRad', '')
	Assert CalculatedLayer equals 'L1'
end test

Test GetCalculatedLayerSingleLayerNonEpiProShouldReturnL1
	CalculatedLayer = Metrology_Services('GetCalculatedLayer', 648685, 'BioRad', '', 0, 1)
	Assert CalculatedLayer equals 'L1'
end test

Test GetCalculatedLayerMultiLayerNonEpiProWithoutWoIsEpiProOrScannedLayerShouldReturn2
	CalculatedLayer = Metrology_Services('GetCalculatedLayer', 649834, 'BioRad', '')
	Assert CalculatedLayer equals 2
end test

Test GetCalculatedLayerMultiLayerNonEpiProShouldReturnL1
	CalculatedLayer = Metrology_Services('GetCalculatedLayer', 649834, 'BioRad', '', 0, 'L1')
	Assert CalculatedLayer equals 'L1'
end test

//-----------------------------------------------------------------------------
// ScanRecipeMatchesRdsTestSpecThickMrecipe Tests
//-----------------------------------------------------------------------------

Test ScanRecipeMatchesRdsTestSpecThickMrecipeWithEmptyRdsNoShouldReturnFalse
	Matches = Metrology_Services('ScanRecipeMatchesRdsTestSpecThickMrecipe', '', 'peach', 'mango', 'banana':@VM:'apple')
	Assert Matches equals False$
end test

Test ScanRecipeMatchesRdsTestSpecThickMrecipeWithEmptyRecipeLayerShouldReturnFalse
	Matches = Metrology_Services('ScanRecipeMatchesRdsTestSpecThickMrecipe', 'peach', '', 'mango', 'banana':@VM:'apple')
	Assert Matches equals False$
end test

Test ScanRecipeMatchesRdsTestSpecThickMrecipeWithEmptyScanRecipeShouldReturnFalse
	Matches = Metrology_Services('ScanRecipeMatchesRdsTestSpecThickMrecipe', 'peach', 'mango', '', 'banana':@VM:'apple')
	Assert Matches equals False$
end test

Test ScanRecipeMatchesRdsTestSpecThickMrecipeWithEmptyRdsTestKeysShouldReturnFalse
	Matches = Metrology_Services('ScanRecipeMatchesRdsTestSpecThickMrecipe', 'peach', 'apple', 'banana', '')
	Assert Matches equals False$
end test

Test ScanRecipeMatchesRdsTestSpecThickMrecipeWithWrongRdsNoShouldReturnFalse
	Matches = Metrology_Services('ScanRecipeMatchesRdsTestSpecThickMrecipe', 'peach', 'L2', 'Thin8inch', '1722576')
	Assert Matches equals False$
end test

Test ScanRecipeMatchesRdsTestSpecThickMrecipeWithWrongLayerShouldReturnFalse
	Matches = Metrology_Services('ScanRecipeMatchesRdsTestSpecThickMrecipe', '650214', 'L2', 'Thin8inch', '1722576')
	Assert Matches equals False$
end test

Test ScanRecipeMatchesRdsTestSpecThickMrecipeWithWrongRecipeShouldReturnFalse
	Matches = Metrology_Services('ScanRecipeMatchesRdsTestSpecThickMrecipe', '650214', 'L1', 'banana', '1722576')
	Assert Matches equals False$
end test

Test ScanRecipeMatchesRdsTestSpecThickMrecipeWithWrongRdsTestKeysShouldReturnFalse
	Matches = Metrology_Services('ScanRecipeMatchesRdsTestSpecThickMrecipe', '650214', 'L1', 'Thin8inch', '1722578')
	Assert Matches equals False$
end test

Test ScanRecipeMatchesRdsTestSpecThickMrecipeWithCorrectArgsShouldReturnTrue
	Matches = Metrology_Services('ScanRecipeMatchesRdsTestSpecThickMrecipe', '650214', 'L1', 'Thin8inch', '1722576')
	Assert Matches equals True$
end test

Test ScanRecipeMatchesRdsTestSpecThickMrecipeEpiProWithWrongZoneShouldReturnFalse
	Matches = Metrology_Services('ScanRecipeMatchesRdsTestSpecThickMrecipe', '650028', '2', '6inTHICK', '1722253':@VM:'1722259', 4)
	Assert Matches equals False$
end test

Test ScanRecipeMatchesRdsTestSpecThickMrecipeEpiProWithCorrectArgsShouldReturnTrue
	Matches = Metrology_Services('ScanRecipeMatchesRdsTestSpecThickMrecipe', '650028', '2', '6inTHICK', '1722253':@VM:'1722259', 2)
	Assert Matches equals True$
end test

//-----------------------------------------------------------------------------
// ScanNumDataPointsMatchesRdsTestSpecThickMPattern Tests
//-----------------------------------------------------------------------------

Test ScanNumDataPointsMatchesRdsTestSpecThickMPatternWithEmptyRdsNoShouldReturnFalse
	Matches = Metrology_Services('ScanNumDataPointsMatchesRdsTestSpecThickMPattern', '', 'peach', 5, 'banana':@VM:'apple', 'mango')
	Assert Matches equals False$
end test

Test ScanNumDataPointsMatchesRdsTestSpecThickMPatternWithEmptyRecipeLayerShouldReturnFalse
	Matches = Metrology_Services('ScanNumDataPointsMatchesRdsTestSpecThickMPattern', 'peach', '', 5, 'banana':@VM:'apple', 'mango')
	Assert Matches equals False$
end test

Test ScanNumDataPointsMatchesRdsTestSpecThickMPatternWithStringScanNumDataPointsShouldReturnFalse
	Matches = Metrology_Services('ScanNumDataPointsMatchesRdsTestSpecThickMPattern', 'peach', 'mango', 'potato', 'banana':@VM:'apple', 'pineapple')
	Assert Matches equals False$
end test

Test ScanNumDataPointsMatchesRdsTestSpecThickMPatternWithEmptyRdsTestKeysShouldReturnFalse
	Matches = Metrology_Services('ScanNumDataPointsMatchesRdsTestSpecThickMPattern', 'peach', 'apple', 5, '', 'banana')
	Assert Matches equals False$
end test

Test ScanNumDataPointsMatchesRdsTestSpecThickMPatternWithEmptyToolClassShouldReturnFalse
	Matches = Metrology_Services('ScanNumDataPointsMatchesRdsTestSpecThickMPattern', 'peach', 'apple', 5, 'banana':@VM:'apple', '')
	Assert Matches equals False$
end test

Test ScanNumDataPointsMatchesRdsTestSpecThickMPatternWithWrongRdsNoShouldReturnFalse
	Matches = Metrology_Services('ScanNumDataPointsMatchesRdsTestSpecThickMPattern', 'peach', 'L2', 10, '1722576', 'FTIR')
	Assert Matches equals False$
end test

Test ScanNumDataPointsMatchesRdsTestSpecThickMPatternWithWrongLayerShouldReturnFalse
	Matches = Metrology_Services('ScanNumDataPointsMatchesRdsTestSpecThickMPattern', '650214', 'L2', 10, '1722576', 'FTIR')
	Assert Matches equals False$
end test

Test ScanNumDataPointsMatchesRdsTestSpecThickMPatternWithWrongScanNumDataPointsShouldReturnFalse
	Matches = Metrology_Services('ScanNumDataPointsMatchesRdsTestSpecThickMPattern', '650214', 'L1', 5, '1722576', 'FTIR')
	Assert Matches equals False$
end test

Test ScanNumDataPointsMatchesRdsTestSpecThickMPatternWithWrongRdsTestKeysShouldReturnFalse
	Matches = Metrology_Services('ScanNumDataPointsMatchesRdsTestSpecThickMPattern', '650214', 'L1', 10, '1722578', 'FTIR')
	Assert Matches equals False$
end test

Test ScanNumDataPointsMatchesRdsTestSpecThickMPatternWithWrongToolClassShouldReturnFalse
	Matches = Metrology_Services('ScanNumDataPointsMatchesRdsTestSpecThickMPattern', '650214', 'L1', 10, '1722576', 'banana')
	Assert Matches equals False$
end test

Test ScanNumDataPointsMatchesRdsTestSpecThickMPatternWithCorrectArgsShouldReturnTrue
	Matches = Metrology_Services('ScanNumDataPointsMatchesRdsTestSpecThickMPattern', '650214', 'L1', 10, '1722576', 'FTIR')
	Assert Matches equals True$
end test

Test ScanNumDataPointsMatchesRdsTestSpecThickMPatternEpiProWithWrongZoneShouldReturnFalse
	Matches = Metrology_Services('ScanNumDataPointsMatchesRdsTestSpecThickMPattern', '650028', '2', 9, '1722253':@VM:'1722259', 'FTIR', 4)
	Assert Matches equals False$
end test

Test ScanNumDataPointsMatchesRdsTestSpecThickMPatternEpiProWithCorrectArgsShouldReturnTrue
	Matches = Metrology_Services('ScanNumDataPointsMatchesRdsTestSpecThickMPattern', '650028', '2', 9, '1722253':@VM:'1722259', 'FTIR', 2)
	Assert Matches equals True$
end test

//-----------------------------------------------------------------------------
// AllowImport Tests
//-----------------------------------------------------------------------------
Test AllowImportWithFeatureFlagTurnedOffShouldReturnTrue
	RunData = ''
	RunData<99> = 1
	AllowImport = Metrology_Services('AllowImport', RunData)
	Assert AllowImport equals True$
end test

Test AllowImportWithFeatureFlagTurnedOnAndImportFlagTrueShouldReturnTrue
	RunData = ''
	RunData<99> = 1
	AllowImport = Metrology_Services('AllowImport', RunData)
	Assert AllowImport equals True$
end test

Test AllowImportWithFeatureFlagTurnedOnAndImportFlagFalseShouldReturnFalse
	RunData = ''
	RunData<99> = 'not valid'
	AllowImport = Metrology_Services('AllowImport', RunData)
	Assert AllowImport equals False$
end test
