我正在尝试在F#中编写一些NUnit测试,并且无法将函数传递给ThrowsConstraint
.蒸馏(非)工作样品如下.
open System.IO
open NUnit.Framework
[<TestFixture>]
module Example =
[<Test>]
let foo() =
let f = fun () -> File.GetAttributes("non-existing.file")
Assert.That(f, Throws.TypeOf<FileNotFoundException>())
Run Code Online (Sandbox Code Playgroud)
这编译得很好,但我从NUnit测试运行器得到以下内容:
FsTest.Tests.Example.foo:
System.ArgumentException : The actual value must be a TestDelegate but was f@11
Parameter name: actual
Run Code Online (Sandbox Code Playgroud)
虽然我能够使用ExpectedException
属性解决问题,但我的问题是在这种情况下使用F#函数的正确方法是什么?
我有一个问题,我试图在Visual Studio 2010中生成一个表.我不太确定如何制定构成我的数据源的SQL查询.
基本上我有两张桌子.其中一个包含图片文件名,并有两列,picturefile (PK)
和username
.第二个表包含三个用户名列:第一个列定义用户名,第二个用户名为朋友,以形成朋友关系,第三列为a RelationshipID
.
我想让我的查询生成一个表格,显示当前用户的朋友拥有的图片表中的所有图片.我有@currentuser
可以使用的参数所以这将是你的朋友的图片表.
我的尝试,记住我是一个非常初学者,是这样的:
SELECT picturefile, username
FROM pictures_table1
WHERE (username = (SELECT User2 FROM friendslist_table1 WHERE friendslist_table1.Username1 = @currentuser AND friendslist.Username2 <> @currentuser))
Run Code Online (Sandbox Code Playgroud)
它给出一个错误,指出子查询不能返回多个值.
谢谢.
我试图用所享有与NUnit的为测试运行.测试用例取自" 入门",并在NUnit外部运行时按预期工作:
namespace FsTest.Tests
open NUnit.Framework
open Swensen.Unquote
[<TestFixture>]
module Example =
[<Test>]
let foo() =
test <@ (1+2)/3 = 1 @>
Run Code Online (Sandbox Code Playgroud)
在NUnit下我得到这个例外:
FsTest.Tests.Example.foo:System.MissingMethodException:找不到方法:'System.Tuple
2<Microsoft.FSharp.Collections.FSharpList
1,Microsoft.FSharp.Quotations.FSharpExpr> Internal.reduceFullyAndGetLast(Microsoft.FSharp.Quotations.FSharpExpr)'.
我想知道上面的代码是否有任何问题以及如何使其工作.raise
如果有帮助的话,Unquote 对我来说也是失败的.