私は関数archive_lb_files
を持っています。テスト関数を使ってマッチしたものの1つを除いてすべてをスタブアウトしたいと思います。私は、スタブマッチを修正する方法がわからないので、私はF#マッチと満足のタイプを構成する方法
この式は、文字列型を持っていることが予想された得ることはありません - > BOOLが、ここでは部
エラーを入力しています。
ここにコードスニペットがあり、FileMaint.fm.archive_lb_file lb_dir archive_dir fn
はboolを返します。回答やコメントへの答えで
(* Subroutine to process files we fetch from IC, and then need to be uploaded to Munis. *)
let process_payment_processor_files spool_dir unload_dir paymt_dir report_date =
use fHLog = FileMaint.fm.open_log_file_out (FileMaint.fm.generate_log_file())
// We'll flesh this in when Stratus is installed, and we know the directory names. cmn 5/26/2017
ignore
let test_print fn =
printfn "%A" fn
let archive_lb_files lb_dir archive_dir report_date =
use fHLog = FileMaint.fm.open_log_file_out(FileMaint.fm.generate_log_file())
let lb_fnam_template = "*_lockbox.txt"
let dir_list = Directory.GetFiles(lb_dir, lb_fnam_template)
for pfn in dir_list do
let fn = Path.GetFileName(pfn)
match fn with
| "cb_lockbox.txt" -> FileMaint.fm.archive_lb_file lb_dir archive_dir fn
| "ics_lockbox.txt" -> (test_print fn)
| "ic_lockbox.txt" -> test_print fn
| _ -> test_print "does not exist"
は、どのように関数を返しarchive_lb_file
ていますか?
(* Moves a file to a unique file name but not including a central directory in between a source and destination. *)
let archive_lb_file lb_path archive_path lockbox_file_name copy_only =
use fH = new StreamWriter(base_log_file, true)
let rc =
try
if (0 = String.Compare(copy_only, "copy_only")) then
File.Move((lb_path + lockbox_file_name), archive_path) |> ignore
fH.WriteLine(generate_time_stamp + ": " + lb_path + lockbox_file_name + " moved to " + archive_path)
else
File.Copy((lb_path + lockbox_file_name), archive_path) |> ignore
fH.WriteLine(generate_time_stamp + ": " + lb_path + lockbox_file_name + " copied to " + archive_path)
true
with ex ->
fH.WriteLine(generate_time_stamp + ": " + "An error occrred trying to move or copy " +
lb_path + lockbox_file_name + " to " + archive_path)
printfn "%A" ex
false
rc
いいえ、それはないでしょう:最初の分岐は '文字列型を持つ - > bool'だけではなく、' bool'を。 –
あなたは正しいです。奇妙なreturn文を追加するコメントを編集しました。 –
呼び出された関数を投稿しました。私はそれがブール関数ではなく返されたと考えました。 – octopusgrabbus