小编Nat*_*ema的帖子

如何使用Fluent Assertions来测试不等式测试中的异常?

我正在尝试使用C#中的Fluent Assertions为超过重写的运算符编写单元测试.如果其中一个对象为null,则此类中的大于运算符应该抛出异常.

通常在使用Fluent Assertions时,我会使用lambda表达式将该方法放入一个动作中.然后我会运行动作并使用action.ShouldThrow<Exception>.但是,我无法弄清楚如何将运算符放入lambda表达式.

我宁愿不使用NUnit Assert.Throws(),ThrowsConstraint或[ExpectedException]属性来保持一致性.

c# lambda nunit unit-testing fluent-assertions

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

将VisualVM与IntelliJ配合使用

我正在尝试使用VisualVM和IntelliJ来分析Java应用程序.我在IntelliJ中安装了VisualVM Launcher插件.我在IntelliJ中按下带有橙色圆圈的播放按钮,启动VisualVM并在我开始运行时打开该过程.但是,当我尝试配置CPU时,它似乎没有在我的程序中分析方法.我尝试了几个不同的程序,似乎无法让任何程序与VisualVM一起工作.这就是VisualVM的样子:

在此输入图像描述

分析器似乎认为总时间是857毫秒或6.21毫秒,而实际上我的程序需要大约一分钟才能运行.它似乎捕获了"DestroyJavaVM",这不是我的程序.我正在使用VisualVM,因为它是我能找到的唯一免费的Java分析器.有什么建议?这是我的VisualVM设置:

在此输入图像描述

java visualvm intellij-idea jvisualvm

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

找不到Microsoft.DiaSymReader.Native.x86.dll

我正在尝试使用Mono在Rider中构建一个项目,我可以继续收到此错误:

错误CS0041:写入调试信息时出现意外错误 - 'Windows PDB编写器不可用 - 找不到Microsoft.DiaSymReader.Native.x86.dll'

有没有人知道我为什么会收到这个错误?我试过在网上搜索它,所有我能找到的是以前的SO问题,从来没有得到答案:Monodevelop无法构建,找不到Microsoft.DiaSymReader.Native.x86.dll' 我不知道从哪里开始.任何帮助,将不胜感激.

c# dll mono rider

12
推荐指数
1
解决办法
4137
查看次数

在TypeScript中映射通用的spreaded参数类型

我正在尝试编写一个泛型方法,该方法接受任意数量的参数作为对象的键,并使用其键的值作为构造函数的参数.这是我最初的实现:

// Typescript 2.x
export function oldMethod<TProps>() {
  function create<
    TInstance extends Geometry | BufferGeometry,
  >(
    geometryClass: new () => TInstance,
  ): any;
  function create<
    TInstance extends Geometry | BufferGeometry,
    TKey1 extends Extract<keyof TProps, string>,
  >(
    geometryClass: new (param1: TProps[TKey1]) => TInstance,
    key1: TKey1,
  ): any;
  function create<
    TInstance extends Geometry | BufferGeometry,
    TKey1 extends Extract<keyof TProps, string>,
    TKey2 extends Extract<keyof TProps, string>,
  >(
    geometryClass: new (param1: TProps[TKey1], param2: TProps[TKey2]) => TInstance,
    key1: TKey1,
    key2: TKey2,
  ): any;
  function create< …
Run Code Online (Sandbox Code Playgroud)

generic-collections typescript

8
推荐指数
1
解决办法
389
查看次数

将带有任意/通用道具的组件传递给 TypeScript 中的 react-redux 连接函数

我正在尝试将react-redux具有任意/通用道具的 React 元素连接起来,但它没有正确编译。我已经尝试使用JSXElementConstructorand(new (props: Props) => React.Component<Props, any>)而不是ComponentType,但是关于如何Props使用不同的类型实例化出现了不同的错误。这是代码。任何帮助,将不胜感激。

https://github.com/piotrwitek/react-redux-typescript-guide/issues/55看起来相关,但这似乎是关于具有通用的道具,而不是道具本身是通用的。

代码

import React from "react";
import { connect } from "react-redux";

interface StoreState {
  someState: number;
}

// Tried `React.JSXElementConstructor<Pros>`
// and `(new (props: Props) => React.Component<Props, any>)`
// instead of `React.ComponentType<Props>`, but got a different error.
function createWrapperComponent<Props>(
  componentElement: React.ReactElement<
    Props,
    React.ComponentType<Props> & { update(props: Props): void }
  >
) {
  const props = componentElement.props;
  const UnconnectedComponent = componentElement.type; …
Run Code Online (Sandbox Code Playgroud)

typescript react-redux

7
推荐指数
1
解决办法
231
查看次数

根据当前鼠标位置缩放图形

我正在尝试根据鼠标的当前位置缩放绘图。现在我的 onMouseWheel 方法看起来像这样(基于这个 StackOverflow 答案):

    private void onMouseWheel(object sender, MouseEventArgs e)
    {
        if (e.Delta > 0)
        {
            _scale *= 1.25f;
            _translateY = e.Y - 1.25f * (e.Y - _translateY);
            _translateX = e.X - 1.25f * (e.X - _translateX);
        }
        else
        {
            _scale /= 1.25f;
            _translateY = e.Y - 0.8f * (e.Y - _translateY);
            _translateX = e.X - 0.8f * (e.X - _translateX);
        }
        this.Invalidate();
    }
Run Code Online (Sandbox Code Playgroud)

_scale, _translateX, 和_translateY是成员变量。

我正在缩放图形,翻译它,然后像这样绘制线条:

    protected override void OnPaint(PaintEventArgs e) …
Run Code Online (Sandbox Code Playgroud)

c# graphics zooming winforms

6
推荐指数
1
解决办法
3326
查看次数

HTML输入类型="文件"Chrome中的文件太多了?

鉴于这个最小,完整,可验证的例子:

<html>
  <head>
    <script>
      var handleFiles = function(event) {
        console.log('# of files: ' + event.target.files.length);
      };
    </script>
  </head>
  <body>
    <input type="file" onchange="handleFiles(event)" multiple/>
  </body>
</html>
Run Code Online (Sandbox Code Playgroud)

我无法在Chrome中选择1682个文件的测试用例(尽管它适用于Firefox).我的测试用例是316兆字节,因此我将其缩小到具有相似数量文件的文件夹,但包含一个字符的简单文本文件.问题依然存在.Chrome处理此控件的实现是否存在问题?如果是这样的话有一个polyfill?如何在Chrome中选择1682个文件?

html google-chrome input file-browser

5
推荐指数
1
解决办法
1164
查看次数