小编Ban*_*San的帖子

将测试连接到Sauce Connect的代码示例在哪里?

我读过: Sauce Labs:Connect页面

并通过互联网查看,但我找不到任何关于如何转换我的Selenium测试以使用Sauce Connect的文档.

有人能指出我正确的方向吗?

干杯

戴夫

webdriver saucelabs

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

.NET异步中的可伸缩性与响应性

我正在阅读考试参考文献70-483:C#编程书,并给出了以下代码示例:

上市1-19

public Task SleepAsyncA(int millisecondsTimeout)
{
    return Task.Run(() => thread.Sleep(millisecondsTimeout);
}

public Task SleepAsyncB(int millisecondsTimeout)
{
    TaskCompletionSource<bool> tcs = null;
    var t = new Timer(delegate { tcs.TrySetResult(true); }, -1, -1);
    tcs = new TaskCompletionSource<bool>(t);
    t.Change(millisecondsTimeout, -1);
    return tcs.Task;
}
Run Code Online (Sandbox Code Playgroud)

该段下述:

SleepAsyncA方法在休眠时使用线程池中的线程.但是,第二种方法具有完全不同的实现,在等待定时器运行时不占用线程.第二种方法为您提供可伸缩性.

为什么A响应但B可扩展?

.net c# multithreading scalability async-await

7
推荐指数
2
解决办法
736
查看次数

使用几个构造函数参数创建Quartz.NET作业

我有一份工作需要在另一个对象上启动一些方法.我希望能够在构造函数中将这些传递给作业.

环顾四周,似乎实现这一目标的唯一方法是使用一个IoC框架.虽然这种方法将来会成为我的解决方案,但现在我需要一个香草解决方案,不需要任何IoC.

我知道JobDataMap但是由于序列化,最佳实践文档建议不要这样做.该对象是多线程和有状态的,因此无论如何序列化将是代码自杀.

如何创建类似于以下的工作:

public class MyJob : IJob
{
    private readonly IFoo _foo;

        public StopMonitoring(IFoo foo)
        {
            _foo = foo;
        }

        public void Execute(IJobExecutionContext context)
        {
            foo.GetCurrentState();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

.net quartz-scheduler quartz.net

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

对于MVC控制器,HttpContext为null

我有一个漂亮的香草控制器:

public class HomeController : Controller
{
    private readonly ApplicationUserManager _applicationUserManager;

    public HomeController()
    {
        _applicationUserManager = HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>();
    }
}
Run Code Online (Sandbox Code Playgroud)

但是,当我点击它时HttpContext它就是空的.

.net c# asp.net-mvc asp.net-mvc-5

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

将 Moq 与 Linq Any() 结合使用

我有一个类似于下面的设置:

    [TestMethod]
    public void NoIntegers()
    {
        Mock<IBar> mockBar = new Mock<IBar>(MockBehavior.Strict);
        Mock<IEnumerable<int>> mockIntegers = new Mock<IEnumerable<int>>(MockBehavior.Strict);

        mockBar
            .SetupGet(x => x.Integers)
            .Returns(mockIntegers.Object);

        mockIntegers
            .Setup(x => x.Any())
            .Returns(false);

        Assert.IsFalse(new Foo(mockBar.Object).AreThereIntegers());
    }

    public interface IBar
    {
        IEnumerable<int> Integers { get; }
    }

    public class Foo
    {
        private IBar _bar;

        public Foo(IBar bar)
        {
            _bar = bar;
        }

        public bool AreThereIntegers()
        {
            return _bar.Integers.Any();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

当它运行时,它无法初始化模拟

Test method NoIntegers threw exception: System.NotSupportedException: Expression references a method that does not belong to the …
Run Code Online (Sandbox Code Playgroud)

.net c# unit-testing moq mocking

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

我在哪里可以找到Mongo DB中执行的TTL命令

我想知道通过TTL索引删除的文档日志.我尝试使用db.setProfileLevel(2)并搜索过db.system.profile.find({op:"remove"}).pretty(),但它没有返回任何内容.

你能告诉我IDs使用TTL MongoDB功能自动删除的文件的位置(种类等)吗?

ttl mongodb

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

Git push,成功推送但在输出中放入一个巨大的ASCII"X"

我刚刚把一些代码推到了BitBucket,它似乎已经成功推出了,但我得到的回答是,很奇怪.

$ git push
Counting objects: 11, done.
Delta compression using up to 12 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 924 bytes | 0 bytes/s, done.
Total 6 (delta 4), reused 1 (delta 0)
remote:
remote: ++++                               ++++
remote:   +++++++                     +++++++
remote:      +++++++++++++++++++++++++++++
remote:          +++++++++++++++++++++
remote:                 +++++++
remote:       +++                     +++
remote:       ++++++     +++++     ++++++
remote:        ++++++    +++++    ++++++
remote:        +++++++    +++    +++++++
remote:         ++++++++   +   ++++++++
remote:          ++++++++     ++++++++
remote:            ++++++++ +++++++++
remote:             +++++++++++++++ …
Run Code Online (Sandbox Code Playgroud)

git bitbucket

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

Visual Studio经常抛出异常

Visual Studio 2015经常变得奇怪.

键入的键以半随机顺序出现,有时我必须按键两次或更多次.

认为这似乎是关键词,而不是变量名或文字.

大约五分钟后,我将收到错误对话框,告诉我有一个可能由扩展引起的异常.

参赛作品ActivityLog.xml如下:

<entry>
  <record>762</record>
  <time>2015/08/11 20:17:02.056</time>
  <type>Error</type>
  <source>Editor or Editor Extension</source>
  <description>System.InvalidOperationException: IWpfTextView has not completed its layout.&#x000D;&#x000A;   at Microsoft.VisualStudio.Text.Editor.Implementation.WpfTextView.PerformLayout(ITextSnapshot newSnapshot, ITextSnapshot newVisualSnapshot, SnapshotPoint anchorPosition, Double verticalDistance, ViewRelativePosition relativeTo, Double effectiveViewportWidth, Double effectiveViewportHeight, Boolean preserveViewportTop, Nullable`1 cancel)&#x000D;&#x000A;   at Microsoft.VisualStudio.Text.Editor.Implementation.WpfTextView.DisplayTextLineContainingBufferPosition(SnapshotPoint bufferPosition, Double verticalDistance, ViewRelativePosition relativeTo, Nullable`1 viewportWidthOverride, Nullable`1 viewportHeightOverride)&#x000D;&#x000A;   at Microsoft.VisualStudio.Text.Editor.Implementation.WpfTextView.DisplayTextLineContainingBufferPosition(SnapshotPoint bufferPosition, Double verticalDistance, ViewRelativePosition relativeTo)&#x000D;&#x000A;   at Microsoft.VisualStudio.Text.InterTextAdornmentSupport.Implementation.InterLineAdornmentManager.PerformLayout(SnapshotPoint trackingPoint)&#x000D;&#x000A;   at Microsoft.VisualStudio.Text.InterTextAdornmentSupport.Implementation.InterLineAdornmentManager.OnBatchedTagsChanged(Object sender, BatchedTagsChangedEventArgs e)&#x000D;&#x000A;   at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.RaiseEvent[TArgs](Object sender, EventHandler`1 eventHandlers, TArgs …
Run Code Online (Sandbox Code Playgroud)

resharper visual-studio visual-studio-extensions ncrunch visual-studio-2015

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

在Windows中发送SIGUSR1 IPC

我有以下 NodeJS 代码:

setInterval(function() {}, 1e6);
process.on('SIGUSR1', function() {
    console.log('Got a signal');
});
Run Code Online (Sandbox Code Playgroud)

在 Unix 中我应该能够使用它kill -s SIGUSR1 1234来发送这个信号。Windows 没有kill命令,我可以看到 Powershell 有,但它似乎没有类似 -s 的选项。

NAME
    Stop-Process

SYNTAX
    Stop-Process [-Id] <int[]> [-PassThru] [-Force] [-WhatIf] [-Confirm]  [<CommonParameters>]

    Stop-Process -Name <string[]> [-PassThru] [-Force] [-WhatIf] [-Confirm]  [<CommonParameters>]

    Stop-Process [-InputObject] <Process[]> [-PassThru] [-Force] [-WhatIf] [-Confirm]  [<CommonParameters>]


ALIASES
    spps
    kill


REMARKS
    Get-Help cannot find the Help files for this cmdlet on this computer. It is displaying only partial help.
        -- …
Run Code Online (Sandbox Code Playgroud)

windows powershell posix ipc node.js

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

Visual Studio不编译TypeScript

我有一个Visual Studio项目,其结构如下:

文件夹结构

tsconfig.json看起来像:

{
  "compilerOptions": {
    "noImplicitAny": false,
    "noEmitOnError": true,
    "removeComments": false,
    "sourceMap": true,
    "target": "es5",
    "outDir": "../wwwroot/"
  },
  "exclude": [
    "node_modules",
    "wwwroot"
  ]
}
Run Code Online (Sandbox Code Playgroud)

但是,VS没有编译app.tswwwroot文件夹中.

我错过了什么?

visual-studio typescript visual-studio-2015 asp.net-core

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