Skip to main content

This is documentation for Caché & Ensemble. See the InterSystems IRIS version of this content.Opens in a new tab

For information on migrating to InterSystems IRISOpens in a new tab, see Why Migrate to InterSystems IRIS?

例 : OnBeforeProductionStart HL7

以下のコードは、テスト・クラス Tutorial.HL7ProductionTest に含まれており、OnBeforeProductionStart メソッドをオーバーライドします。このコードは、プロダクションが開始されてさまざまなセットアップ・タスクを実行する前に実行されます。特に、このコードは以下の処理を実行します。

  • MainDir の値を設定します。入力ファイルおよび参照ファイルは、このディレクトリに配置される必要があります。

  • ChangeSettings を使用して、ビジネス・サービスおよびビジネス・オペレーションの両方に関して FilePath の構成設定の値を変更します。いずれのケースでも、ChangeSettings はプロダクション・クラスの更新を行わないことに注意してください。これらの変更は、このテストの間の一次的なものです。プロダクション・クラスを新しい値に更新するには、ChangeSettings の呼び出し内の最後の引数の値を 1 に設定します。このテストでは、HL7InputDirHL7OutputDir のデフォルト値が使用されることにも注意してください。

  • CreateMainDirTree を使用して、テスト・ディレクトリを初期化します。ディレクトリのルートは、TestAutoNNN です。

  • CleanUpDirectory を使用して、入力ディレクトリおよび出力ディレクトリの両方を削除します。

  • HL7 入力ファイル ABC1.txt を、MainDir から HL7InputDir にコピーします。


 Method OnBeforeProductionStart() As %Library.Status
{
 Set ..MainDir = "C:\Tutorial"
 
 Set s = ..ChangeSetting("Tutorial.HL7ExampleProduction",
     "TutorialHL7FileOperation","FilePath",..HL7OutputDir,0)
 Do $$$AssertEquals(s,$$$OK)
    
 Set s0 = ..ChangeSetting("Tutorial.HL7ExampleProduction",
      "TutorialHL7FileService","FilePath",..HL7InputDir,0)
 Do $$$AssertEquals(s0,$$$OK)
 
 Set s1=$$$AssertStatusOK(..CreateMainDirTree())
 Set s2 = $$$AssertStatusOK(..CleanUpDirectory(..HL7InputDir))
 Set s3 = $$$AssertStatusOK(..CleanUpDirectory(..HL7OutputDir))
 Set s4 = $$$AssertStatusOK(..CopyFile("ABC1.txt",..MainDir))
 
 if 's||'s0||'s1||'s2||'s3||'s4 
 {Quit ..Error("Error in OnBeforeProductionStart()")}

 Quit $$$OK
}
Note:

上記で使用した予備のメソッドは、すべて %UnitTest.TestProductionOpens in a new tab のクラス・ドキュメントで詳細に説明されています。

FeedbackOpens in a new tab