草庐IT

test-status

全部标签

C#,NUnit : Is it possible to test that a DateTime is very close, 但不一定等于另一个?

假设我有这个测试:[Test]publicvoidSomeTest(){varmessage=newThing("foobar");Assert.That(thing.Created,Is.EqualTo(DateTime.Now));}例如,这可能会使Thing的构造函数失败,这会花费一些时间。是否有某种NUnit构造允许我指定Created时间不必完全等于DateTime.Now,只要它在一秒之内?是的,我知道构造函数不应该花费太多时间,但只是作为一个例子:p 最佳答案 没试过,但根据thedocs看起来这应该可行:Assert

c# - 单元测试 Asp.Net WebApi : how to test correct routing of a method with [FromUri] parameters

我想测试这个Controller:[HttpGet]publicIListGetNotificationsByCustomerAndId([FromUri]string[]name,[FromUri]int[]lastNotificationID){return_storage.GetNotifications(name,lastNotificationID,_topX);}特别是,在此方法中,我想测试传入输入以形成请求Url的数组是否与进入routeData.Values的数组相同。如果对于单值参数(不是数组)它有效,但不适用于数组。如果我调试Values,我只会看到controll

JavaScript 样式/优化 : String. indexOf() v. Regex.test()

我最近遇到了这段JavaScript代码:if(",>=,,".indexOf(","+sCompOp+",")!=-1)我很感兴趣,因为要编写这个测试我会这样做:if(/(>=|)/.test(sCompOp))这只是风格上的差异,还是其他代码的作者了解一些我不知道的优化知识?或者也许有不同的充分理由这样做,或者不使用正则表达式......?在我看来,为此使用String.indexOf()有点难以阅读(但是,我对正则表达式很满意),但是有没有实例可能比编写等效的正则表达式“更好”?通过可能更快或更有效的“更好”(尽管显然这取决于浏览器的JavaScript引擎)或其他一些我不知道的

javascript - jquery ajax 调用返回一个错误,readystate 4,status 200,statustext ok

这真的让我很困惑。我从ajax收到错误回调。但是,如果我从错误消息中获取res.responseText(顺便说一句,返回正确)并使用它,它就会做正确的事情。就好像我收到了一个成功的回调。数据是这样设置的:vardataToSend={fieldname:textdata};ajax调用是这样的:varajaxOptions={url:'/newpage',data:JSON.stringify(dataToSend),contentType:'application/json;charset=utf-8',dataType:'json',cache:false,processData

java: 无法访问org.testng.annotations.Test

目录一、报错 二、原因三、解决办法一、报错java:无法访问org.testng.annotations.Test 错误的类文件:/D:/maven_repository/org/testng/testng/7.6.1/testng-7.6.1.jar!/org/testng/annotations/Test.class  类文件具有错误的版本55.0,应为52.0  请删除该文件或确保该文件位于正确的类路径子目录中。 二、原因testing版本过高导致三、解决办法换一个低版本testing(大家使用最多即可)官方Maven地址:https://mvnrepository.com/artifa

javascript - Angular Testing 异步管道不会触发可观察的

我想测试一个使用异步管道的组件。这是我的代码:@Component({selector:'test',template:`{{number|async}}`})classAsyncComponent{number=Observable.interval(1000).take(3)}fdescribe('AsyncCompnent',()=>{letcomponent:AsyncComponent;letfixture:ComponentFixture;beforeEach(async(()=>{TestBed.configureTestingModule({declarations:[

javascript - Rails + Jasmine-Ajax : what is the correct way to test code triggered by `ajax:success` (jquery-ujs)

我正在尝试测试某个内部库,该库在ajax:success事件上触发了一些JS行为。库创建一个如下所示的链接:在库的JS部分有事件绑定(bind)代码,这是我想通过它对DOM的影响进行黑盒测试的部分:$(document).on'ajax:success','.special-link',(e,data,status,xhr)->#CodethathassomeeffectontheDOMasafunctionoftheserverresponse该库在浏览器中按预期工作。但是,当我尝试通过调用$('.special-link').click()测试Jasmine中的库时,无法观察到对D

javascript - react 和 Jest : Cannot find module from test file

为目录中的Redux操作('App.js')设置Jest测试('App-test.js')app/__tests__:这是App.js的header:jest.unmock('../../modules/actions/App.js')importReactfrom'react'importReactDOMfrom'react-dom'importTestUtilsfrom'react-addons-test-utils'import*asAppfrom'../../modules/actions/App.js'在app/有一个模块config.js.这是在需要的地方导入的。问题是,当

javascript - 非常简单的 AngularJS $http POST 结果为 '400 (Bad Request)' 和 'Invalid HTTP status code 400'

我有一个非常简单的.NETWebAPI托管在Azure中,有两个非常简单的方法:[EnableCors(origins:"http://simpleapiearl.azurewebsites.net",headers:"*",methods:"*")]publicclassEnvelopesController:ApiController{//GET:api/EnvelopespublicIEnumerableGet(){returnnewstring[]{"value1","value2"};}//POST:api/EnvelopespublicstringPost([FromBod

javascript - jqXHR - http-status-code-403(但状态码为 0)

我得到状态码0...但它是代码403。谁能告诉我问题出在哪里?JQUERYvarjqxhr=$.ajax({url:'http://gdata.youtube.com/feeds/api/users/bernd/favorites?alt=json',dataType:'json'}).success(function(xhr){alert(xhr.status);}).error(function(xhr){alert(xhr.status);returnfalse;})演示->http://jsfiddle.net/QFuBr/提前致谢!彼得 最佳答案