我知道简短的回答是Mocks,但任何例子都会很好.我需要能够测试以下内容:
作为一个开始,我正在考虑定义一个接口,它将使用一个流,这将允许我简单地让我的类连接到任何流,我可以控制比串行端口更好,并允许我这样做programmaticly.如果有人有更好的想法,我会非常感激.
我有一个使用集成安全性的ASP.Net MVC应用程序,我需要能够授予对特定路由的开放访问权限.有问题的路线是~/Agreements/Upload.我尝试了一些事情,迄今为止没有任何工作.
<configuration>
<location path="~/Agreements/Upload">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
</configuration>
Run Code Online (Sandbox Code Playgroud)
在目录安全性>身份验证方法下的IIS中,我只选择了"集成Windows身份验证".现在,这可能是我的问题的一部分(尽管IIS允许上面的IIS没有).但是,如果是这种情况,我该如何配置它以便集成安全性工作但允许未经过身份验证的人访问给定路由?
.net asp.net-mvc authorization web-config integrated-security
我必须写很多处理串口的代码.通常会在电线的另一端连接一个设备,我通常会创建自己的模拟来模拟它们的行为.
我开始看Moq来帮助我进行单元测试.当你只需要一个存根时,使用它非常简单,但我想知道它是否可行,如果是,我如何为硬件设备创建一个模拟器,根据我想要测试的内容做出不同的响应.
一个简单的例子:
我与之接口的设备之一接收命令(移动到位置x),返回ACK消息并进入"移动"状态,直到它到达有序位置.
我想创建一个测试,我发送移动命令,然后继续查询状态,直到它到达最终位置.
我想为两个不同的测试创建两个版本的模拟,一个是我希望设备成功到达最终位置,另一个是失败.
要问的问题太多了?
我有用于设置和拆除NHibernate的通用代码,我几乎所有的测试都需要它.有没有办法在一个地方包含"需要所有测试"代码,然后将其应用于所有测试?(比如Nunit setup和teardown方法)
[Subject("Accessing the TAE allocation page")]
public class when_a_request_to_the_tae_allocation_page_is_made
{
Establish context = () => NHTestHelper.StartTest(); //need for all tests
Because of = () => result = new AllocationController(true).Index();
It should_display_the_page = () => result.ShouldBeAView();
Cleanup nh = () => NHTestHelper.EndTest(); //need for all tests
static ActionResult result;
}
Run Code Online (Sandbox Code Playgroud) 使用Jenkins管道插件时,构建失败并出现java.io.NotSerializableException错误,如下所示:
java.io.NotSerializableException: org.codehaus.groovy.control.ErrorCollector
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:860)
at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
...
Caused by: an exception which occurred:
in field collector
in field abnormal
in field outcome
in field body
in field step
in field thread
in field this$0
in field returnAddress
in field parent
in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@6ae7e4f1
...
Finished: FAILURE
Run Code Online (Sandbox Code Playgroud)
当我使用带有一些import语句的自定义库时会发生这种情况.我已经尝试了几件事,比如用@NonCPS封装调用方法,但错误仍然存在.
管道脚本
#!groovy
@Library('utils')
pipeline {
agent any
stages …Run Code Online (Sandbox Code Playgroud) 我有一个依赖于几个DLL引用的Visual Studio项目.以下是我的csproj中这些引用的示例:
<ItemGroup>
<Reference Include="Class1.Project1">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\bin\Class1.Project1.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Class1.Project2">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\bin\Class1.Project2.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
Run Code Online (Sandbox Code Playgroud)
但是,当我将此类作为项目依赖项包含在Web站点项目中时,Visual Studio将查找上面显示的依赖项的依赖项.在构建期间,Visual Studio将"复制本地"属性默认为"True",并将这些依赖项复制到我的网站的〜/ bin目录中.
反过来,这会覆盖此目录中已存在的DLL文件的版本.这会导致以下错误:
无法加载文件或程序集'Class5.Project5,Version = 3.6.1861.2,Culture = neutral,PublicKeyToken = dfeaee0e3978ac79'或其依赖项之一.定位的程序集的清单定义与程序集引用不匹配.(HRESULT异常:0x80131040)
如何让我的Visual Studio默认情况下,"复制本地"设置为"假"的一切?我不希望Visual Studio在构建期间自动复制DLL文件.我也不希望我的领带构建以非常一个DLL的特定版本.
我的开发机器运行的是Windows 7 Ultimate x64.我安装了Visual Studio 2010 Ultimate.当我打开Visual Studio命令提示符(2010)时,我收到消息
设置使用Microsoft Visual Studio 2010 x86工具的环境.
我还在Windows PowerShell用户配置文件中设置了PowerShell社区扩展.我使用Invoke-BatchFilecmdlet将Visual Studio工具安装到我的所有PowerShell会话中
$vcargs = ?: {$Pscx:Is64BitProcess} {'amd64'} {'x86'}
$vcvars = "${env:VS100COMNTOOLS}..\..\VC\vcvarsall.bat"
Invoke-BatchFile $vcvars $vcargs
Run Code Online (Sandbox Code Playgroud)
我vcargs做出决定amd64.我在vcvarsall.bat文件中查找了x64批处理文件的位置并得到了~dp0bin\amd64\vcvars64.bat.该目录(和文件)不存在.
如何vcvars64.bat正确安装文件?
我想运行我在Mahout In Action中找到的代码:
package org.help;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.SequenceFile;
import org.apache.hadoop.io.Text;
import org.apache.mahout.math.DenseVector;
import org.apache.mahout.math.NamedVector;
import org.apache.mahout.math.VectorWritable;
public class SeqPrep {
public static void main(String args[]) throws IOException{
List<NamedVector> apples = new ArrayList<NamedVector>();
NamedVector apple;
apple = new NamedVector(new DenseVector(new double[]{0.11, 510, 1}), "small round green apple");
apples.add(apple);
Configuration conf = new Configuration();
FileSystem fs = FileSystem.get(conf);
Path path = new Path("appledata/apples");
SequenceFile.Writer writer = new SequenceFile.Writer(fs, conf, path, Text.class, …Run Code Online (Sandbox Code Playgroud) 我正在使用DDay库来创建iCal事件,以便我的网站用户可以在他们的日历中添加内容.
我希望他们在Office 2010中添加约会而不是会议请求(希望其他人也是如此).当我使用库并将方法设置为PUBLISH时,它确实显示为约会,但它报告在日历中找不到会议.然后,当我点击不需要回复时,该项目将被删除,并且不会保留在他们的日历中.
如果我将方法更改为REQUEST,它将显示为会议请求.这可能是第二好的选择,但'to'字段是空白的.如果这是我能做的最好的,我怎样才能设置'到'字段?我想我会让他们回应自己.
private static string CreateCalendarEvent(
string title, string body, DateTime startDate, double duration,
string location, string organizer, string eventId, bool allDayEvent)
{
// mandatory for outlook 2007
if(String.IsNullOrEmpty(organizer))
throw new Exception("Organizer provided was null");
var iCal = new iCalendar
{
Method = "PUBLISH",
Version = "2.0"
};
// "REQUEST" will update an existing event with the same UID (Unique ID) and a newer time stamp.
//if (updatePreviousEvent)
//{
// iCal.Method = "REQUEST";
//}
var evt = iCal.Create<Event>(); …Run Code Online (Sandbox Code Playgroud) 我知道你可以运行并重新加载ahk脚本.我已经看到了提供调试的基于scintilla的编辑器.但是,有没有任何基于命令行的REPL?
我正在测试语句以获取活动窗口的进程名称,并认为它真的很有用!
ahk> WinGet, active, ProcessName, A
powershell.exe
Run Code Online (Sandbox Code Playgroud) .net ×3
c# ×3
mocking ×2
unit-testing ×2
64-bit ×1
asp.net ×1
asp.net-mvc ×1
autohotkey ×1
copy-local ×1
dday ×1
groovy ×1
hadoop ×1
icalendar ×1
java ×1
jenkins ×1
mahout ×1
moq ×1
mspec ×1
nhibernate ×1
web-config ×1
windows-7 ×1