小编Ed.*_*ard的帖子

如何在Kotlin中声明枚举类型的变量?

根据文档创建了一个枚举类

enum class BitCount public constructor(val value : Int)
{
  x32(32),
  x64(64)
}
Run Code Online (Sandbox Code Playgroud)

然后我试图在某个函数中声明一个变量

val bitCount : BitCount = BitCount(32)
Run Code Online (Sandbox Code Playgroud)

但是有一个编译错误

如何声明BitCount类型的变量并从中初始化它Int

错误:(18,29)Kotlin:枚举类型无法实例化

enums kotlin

27
推荐指数
3
解决办法
2万
查看次数

如何断言该集合只包含一个具有给定属性值的元素?

如何断言该集合只包含一个具有给定属性值的元素?

例如:

class Node
{
  private readonly string myName;
  public Node(string name)
  {
    myName = name;
  }
  public string Name { get; set; }
}

[Test]
public void Test()
{
  var array = new[]{ new Node("1"), new Node("2"), new Node("1")};
  Assert.That(array, Has.Some.Property("Name").EqualTo("1"));
  Assert.That(array, Has.None.Property("Name").EqualTo("1"));

  // and how to assert that node with Name="1" is single?
  Assert.That(array, Has.???Single???.Property("Name").EqualTo("1"));
}
Run Code Online (Sandbox Code Playgroud)

c# nunit unit-testing constraints

11
推荐指数
1
解决办法
1万
查看次数

NUnit在单独的线程中断言

nunit是否适用于多线程上下文.我当然不希望nunit测试我的多线程应用程序,但是想要使用nunit断言

简单的例子 - 这个测试是"绿色".我错了什么?

[Test]
public void Test()
{
  Action action = Async;
  action.BeginInvoke(action.EndInvoke, null).AsyncWaitHandle.WaitOne();
}

private void Async()
{
  Assert.IsTrue(false);
  Assert.DoesNotThrow( () =>
                       {
                         Console.WriteLine("Async");
                         throw new InvalidOperationException();
                       });
}
Run Code Online (Sandbox Code Playgroud)

multithreading nunit

4
推荐指数
1
解决办法
4489
查看次数

JMVTI:Could not find agent library

I wrote an agent for Java which does nothing just exports two methods, just to check if it loaded on JVM start or not. Built it with mingw-w64 4.8.4 (using JetBrains CLion). Windows 7 x64.

JNIEXPORT jint JNICALL
Agent_OnLoad(JavaVM *jvm, char *options, void *reserved){
  return JNI_OK;
}

JNIEXPORT void JNICALL
Agent_OnUnload(JavaVM *vm){}
Run Code Online (Sandbox Code Playgroud)

Got an error running

java -agentlib:"C:\JMVAgent\agent.dll"

Error occurred during initialization of VM
Could not find agent library libSampleAgent.dll on the library path, 
with error: Can't find dependent libraries …
Run Code Online (Sandbox Code Playgroud)

java jvm jvmti

0
推荐指数
1
解决办法
8382
查看次数

标签 统计

nunit ×2

c# ×1

constraints ×1

enums ×1

java ×1

jvm ×1

jvmti ×1

kotlin ×1

multithreading ×1

unit-testing ×1