我有一个ParseService,我想模拟测试所有使用它的控制器,我一直在阅读有关茉莉花间谍的信息,但我仍然不清楚.有人能给我一个如何模拟自定义服务并在Controller测试中使用它的例子吗?
现在我有一个使用服务插入书籍的控制器:
BookCrossingApp.controller('AddBookCtrl', function ($scope, DataService, $location) {
$scope.registerNewBook = function (book) {
DataService.registerBook(book, function (isResult, result) {
$scope.$apply(function () {
$scope.registerResult = isResult ? "Success" : result;
});
if (isResult) {
//$scope.registerResult = "Success";
$location.path('/main');
}
else {
$scope.registerResult = "Fail!";
//$location.path('/');
}
});
};
});
Run Code Online (Sandbox Code Playgroud)
服务是这样的:
angular.module('DataServices', [])
/**
* Parse Service
* Use Parse.com as a back-end for the application.
*/
.factory('ParseService', function () {
var ParseService = {
name: "Parse",
registerBook: function registerBook(bookk, callback) {
var …Run Code Online (Sandbox Code Playgroud) 嗨,我正在尝试通过Chrome在我的设备上调试我的phonegap应用程序我已按照所有步骤操作,我的手机被adb devices命令识别,
然后我去chrome:// inspect /#devices我可以看到我的手机,但是这条消息出现在浏览器上:
离线
待认证:请接受设备上的调试会话.
事情是我的手机里没有这样的信息,我有一个带有kitkat的Sansumg Galaxy S2.我将版本从4.1更新到4.4,因为我认为这是问题,但在升级到4.4同样的问题之后.
以前有人遇到过这个问题吗?
android google-chrome remote-debugging google-chrome-devtools cordova
我想保存一个在Parse云代码中随机生成的registrationId,所以我需要检查该值是否已经在DB中,我必须以递归的方式执行此操作,直到我得到正确的字符串.这是我到目前为止尝试的,问题是findRegistrationId()不是一个承诺所以我不能使用then()有没有办法让它成为一个承诺或任何其他解决方法?对于云代码
function getRandomString()
{
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZ";
var string_length = 4;
var randomstring = '';
for (var i=0; i<string_length; i++) {
var rnum = Math.floor(Math.random() * chars.length);
randomstring += chars.substring(rnum,rnum + 1);
}
return randomstring;
}
function findRegistrationId()
{
console.log("Enter findRegistrationId")
var randomString = getRandomString();
var query = new Parse.Query("Book");
query.equalTo("registrationId", randomString);
query.find.then(function(results){
if(results.length === 0)
{
console.log("no registrationId duplicated")
return randomString;
}
//if there is other registrationId we concatenate
else
{
console.log("registrationId duplicated let's recursive it")
return findRegistrationId(); …Run Code Online (Sandbox Code Playgroud) 我试图用angularjs为我的服务器响应(PARSE)实现一个拦截器,我看到这个项目使用$ httpProvider来注册拦截器.
既然我的服务没有使用$ http服务(正在使用PARSE),有没有办法以与项目样本相同的清洁方式实现我的拦截器?
我们对如何集成phonegap插件然后用phonegap构建我们的移动应用程序有一些疑问,这可能吗?
使用Phonegapbuild构建应用程序时,它会为所有支持的设备构建,但有关如何在phonegap中安装任何插件的说明特定于Android/ios/Windows phone等.所以
我们如何安装特定的插件然后使用phonegap构建?
如果不可能,我们还有什么其他选择来构建一个phonegap应用程序?
提前致谢.
我想整合Karma和webstorm for windows,我已经按照这个网页的步骤:http://mobicon.tistory.com/273 (将其翻译成英文)但不起作用.
我创建了一个Karma Server和一个Karma运行:
在Path to Node Js File textfield中,我指出了来自node-modules的karma文件:
C:\用户\ XXX \应用程序数据\漫游\ NPM-缓存\因缘\ 0.8.4 \包\ BIN \因果报应
在服务器启动和Karma Run运行的应用程序参数中
我收到以下错误:
module.js:340
throw err;
^
Error: Cannot find module 'optimist'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at Object.<anonymous> (C:\Users\Javito\AppData\Roaming\npm-cache\karma\0.8.4\package\lib\cli.js:2:16)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:362:17)
Process finished with exit code 1
Run Code Online (Sandbox Code Playgroud) 我有一个对象列表,其中一些具有相同的ID,所以我想删除那些重复的元素.
我尝试过这样的事情:
List<post> posts = postsFromDatabase.Distinct().ToList();
Run Code Online (Sandbox Code Playgroud)
但它不起作用!
所以我写了这个方法以避免重复:
public List<Post> PostWithOutDuplicates(List<Post> posts)
{
List<Post> postWithOutInclude = new List<Post>();
var noDupes = posts.Select(x => x.Id).Distinct();
if (noDupes.Count() < posts.Count)
{
foreach (int idPost in noDupes)
{
postWithOutInclude.Add(posts.Where(x => x.Id == idPost).First());
}
return postWithOutInclude;
}
else
{
return posts;
}
}
Run Code Online (Sandbox Code Playgroud)
任何关于如何提高性能的想法?
Thanx提前.
从上周四开始,当我们提交代码时,我们的一个Team Services构建开始失败,
错误是下一个:
2016-06-20T10:15:29.7964057Z ##[error]System.AggregateException: One or more errors occurred. ---> System.NotSupportedException: The given path's format is not supported.
2016-06-20T10:15:29.8120276Z ##[error] at System.Security.Permissions.FileIOPermission.QuickDemand(FileIOPermissionAccess access, String fullPath, Boolean checkForDuplicates, Boolean needFullPath)
2016-06-20T10:15:29.8120276Z ##[error] at System.IO.Path.GetFullPath(String path)
2016-06-20T10:15:29.8120276Z ##[error] at System.Linq.Enumerable.<>c__DisplayClass7_0`3.<CombineSelectors>b__0(TSource x)
2016-06-20T10:15:29.8120276Z ##[error] at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
2016-06-20T10:15:29.8120276Z ##[error] at NuGet.CommandLine.RestoreCommand.ProcessSolutionFile(String solutionFileFullPath, PackageRestoreInputs restoreInputs)
2016-06-20T10:15:29.8120276Z ##[error] at NuGet.CommandLine.RestoreCommand.GetInputsFromFile(String projectFilePath, PackageRestoreInputs packageRestoreInputs)
2016-06-20T10:15:29.8120276Z ##[error] at NuGet.CommandLine.RestoreCommand.DetermineRestoreInputs()
2016-06-20T10:15:29.8120276Z ##[error] at NuGet.CommandLine.RestoreCommand.<ExecuteCommandAsync>d__23.MoveNext()
2016-06-20T10:15:29.8120276Z ##[error] --- End of inner exception stack trace ---
2016-06-20T10:15:29.8120276Z ##[error] at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean …Run Code Online (Sandbox Code Playgroud) I have an Activity where I declared a InArgument without a type (because I want to know the type of the Expression at design time).
When I execute the activity I get this error in var contentTelegram line:
"The argument of type '<type>' cannot be used. Make sure that it is declared on an activity."
Run Code Online (Sandbox Code Playgroud)
Here is my code:
public InArgument Content { get; set; }
protected override PlcMessage Execute(CodeActivityContext context)
{
try
{
var contentTelegram = Content.Get(context);
return new …Run Code Online (Sandbox Code Playgroud) 我正在为项目模板实现一个向导,我想获取用户在“新建项目”窗口中选择的项目/解决方案路径。我知道有一些参数,比如 $saferootprojectname$ 来获取项目的名称,但不知道如何获取位置路径
问候
现在我们在调用DataService(Parse)的控制器中遇到一个问题,问题是这段代码不起作用:
function MainCtrl($scope, DataService, $location)
{
$scope.actionList = function() {
// Call the service and fetch the list of signatures that match the given action ID
DataService.getActions(function (results) {
$scope.$apply(function () {
// Apply the results to the signatureList model so it will refresh the table in the view
$scope.actionList = results;
});
});
};
}
Run Code Online (Sandbox Code Playgroud)
我在DataService行中设置了一个断点,但它没有被击中,但是如果我以这种方式实现Ctrl它会接到调用并且它可以工作!!:
function MainCtrl($scope, DataService, $location)
{
// Call the service and fetch the list of signatures that match the given action ID
DataService.getActions(function (results) …Run Code Online (Sandbox Code Playgroud) angularjs ×4
javascript ×3
c# ×2
cordova ×2
nuget ×2
.net ×1
android ×1
azure-devops ×1
c#-4.0 ×1
distinct ×1
jasmine ×1
karma-runner ×1
linq ×1
sitefinity ×1
webstorm ×1