我是Testacular(现在的Karma)的新手.但我发现它对于自动跨浏览器JS测试非常强大和出色.所以我想知道是否有可能将它作为TFS构建过程的一部分来进行自动JS代码单元测试?如果有人以前的经验,请你告诉我们要注意什么,这样我们就不会采取错误的方式.
问候,君
有人能给我一个如何使用角度滤波器比较器的例子吗?
来自官方文件:
function(actual,expected):该函数将被赋予对象值和要比较的谓词值,如果该项应包含在过滤结果中,则应返回true.
有一篇很棒的博客文章谈论角度过滤器:
使用AngularJS过滤器的乐趣 - 第1部分:filter
过滤器
然而,在它的最后,我正在寻找函数比较器的一些有用的例子,我仍然没有发现任何东西.
对于更具体的匹配需求,您可以传递函数而不是布尔值作为比较器参数.
我自己尝试过几种组合.既不在表达式的末尾添加函数,也不指向范围内的函数来完成工作.
我发现当CSS3 Zoom适用于小型SVG图标(9px:9px,缩放:1.5)时,SVG图标可能会模糊不清.在这种情况下,有什么想要得到一个清晰而干净的图标?提前致谢.
SVG:
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve"
x="0px" y="0px" width="9px" height="9px" viewBox="0 0 9 9" enable-background="new 0 0 9 9">
<g>
<g fill="none" transform="translate(0.5, 0.5)">
<g stroke="#000000" stroke-width="0.5" stroke-linecap="square" >
<line x1="2" y1="4" x2="6" y2="4"/>
<line x1="4" y1="2" x2="4" y2="6"/>
</g>
<g stroke="#909090" stroke-width="1" stroke-linecap="square" >
<rect x="0" y="0" width="8" height="8"/>
</g>
</g>
</g>
</svg>
Run Code Online (Sandbox Code Playgroud) 我可以在Chrome开发者工具的控制台中修改document.cookie吗?
我当前的cookie字符串如下:
"coldcookie="
Run Code Online (Sandbox Code Playgroud)
如果我在下面运行以下代码,它似乎无效:
document.cookie = document.cookie + "; newcookie=something"
Run Code Online (Sandbox Code Playgroud)
document.cookie根本不会改变.
更新:我发现如果我跑:
document.cookie = "newcookie"
Run Code Online (Sandbox Code Playgroud)
它实际上在cookie字符串中添加了一个"newcookie",如:
"oldcookie=; newcookie"
Run Code Online (Sandbox Code Playgroud)
不应该清除当前的cookie字符串吗?
它在IE中做同样的事情.所以我认为必须有一些规则.有任何想法吗?
这是我发现在某些情况下很难调试等待任务中的死锁的一个简化示例:
class Program
{
static void Main(string[] args)
{
var task = Hang();
task.Wait();
}
static async Task Hang()
{
var tcs = new TaskCompletionSource<object>();
// do some more stuff. e.g. another await Task.FromResult(0);
await tcs.Task;
tcs.SetResult(0);
}
}
Run Code Online (Sandbox Code Playgroud)
这个例子很容易理解为什么它会死锁,它正在等待稍后完成的任务。这看起来很愚蠢,但在更复杂的生产代码中可能会发生类似的情况,并且由于缺乏多线程经验可能会错误地引入死锁。
这个例子的有趣之处在于Hang
方法内部没有像Task.Wait()
or那样的线程阻塞代码Task.Result
。然后当我附加 VS 调试器时,它只显示主线程正在等待任务完成。但是,没有线程显示代码在Hang
使用并行堆栈视图的方法内部停止的位置。
这是我在并行堆栈中的每个线程上的调用堆栈(总共 3 个):
头1:
[Managed to Native Transition]
Microsoft.VisualStudio.HostingProcess.HostProc.WaitForThreadExit
Microsoft.VisualStudio.HostingProcess.HostProc.RunParkingWindowThread
System.Threading.ThreadHelper.ThreadStart_Context
System.Threading.ExecutionContext.RunInternal
System.Threading.ExecutionContext.Run
System.Threading.ExecutionContext.Run
System.Threading.ThreadHelper.ThreadStart
Run Code Online (Sandbox Code Playgroud)
主题 2:
[Managed to Native Transition]
Microsoft.Win32.SystemEvents.WindowThreadProc
System.Threading.ThreadHelper.ThreadStart_Context
System.Threading.ExecutionContext.RunInternal
System.Threading.ExecutionContext.Run
System.Threading.ExecutionContext.Run
System.Threading.ThreadHelper.ThreadStart …
Run Code Online (Sandbox Code Playgroud) 我正在将用于Dynamics CRM 2015的SDK中的代码迁移到2016和365的最新版本.但是,我注意到生成的XrmServiceContext是继承Microsoft.Xrm.Sdk.Client.OrganizationServiceContext
而不是Microsoft.Xrm.Client.CrmOrganizationServiceContext
.这删除了相关实体的自动延迟加载CrmOrganizationServiceContext
.我浪费了几个小时试图找出相关实体在代码正确编译时为空的原因.我发现,在Microsoft.Xrm.Client
已经从8.x的SDK中删除.有没有人知道是否CrmOrganizationServiceContext
已经移动/重命名为其他东西或者它被删除了?有延迟加载支持的替代方案吗?不想找到所有相关实体直接使用的地方并添加一个LoadProperty
.谢谢.
我从github克隆了一些npm包,并将包放在一个本地文件夹中,例如
c:\git\package
Run Code Online (Sandbox Code Playgroud)
我用"npm install -g"来安装软件包,效果非常好.
npm install -g c:\git\package
Run Code Online (Sandbox Code Playgroud)
但是,当我对包的代码做了一些更改时,例如签出了一些分支.我无法使用"npm update"来更新已安装的软件包.我试过了:
npm update -g
Run Code Online (Sandbox Code Playgroud)
和
npm update -g packagename
Run Code Online (Sandbox Code Playgroud)
要么
npm update -g folderpath
Run Code Online (Sandbox Code Playgroud)
都没有奏效.我必须使用"npm install"重新安装它以进行更新,这是浪费时间重新安装所有依赖项.
为什么npm只支持从文件夹安装但不支持从文件夹更新?如果确实支持,我该怎么办?谢谢.
我最近在 Chrome 渲染 SVG 线性渐变时发现了一些问题。看看下面这个 SVG:
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<body>
<svg>
<g>
<linearGradient id="linearGradient" gradientUnits="userSpaceOnUse" x1="79px" x2="706px" y1="0" y2="0">
<stop class="" offset="54.54545454545455%" style="stop-color: red;"></stop>
<stop class="" offset="63.63636363636364%" style="stop-color: red;"></stop>
<stop class="" offset="63.63636363636364%" style="stop-color: green;"></stop>
<stop class="" offset="72.72727272727273%" style="stop-color: green;"></stop>
</linearGradient>
<path d="M79,241L136,196L193,194L250,212L307,159L364,152L421,339L478,46L535,205L592,134L649,215L706,74"
style="opacity: 1; fill: none; stroke: url(#linearGradient); stroke-width: 2px;">
</path>
</g>
</svg>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
在Chrome中加载此html后(我的版本是23.0.1271.64),很容易在peek中看到线性渐变的明显2px误差,在左侧线段中显示出一些绿色。在 IE 9 和最新的 Firefox 中,svg 都能正确呈现。我认为这可能是 Chrome 或 WebKit 的错误。有谁知道如何解决?谢谢!
我正在使用Visual Studio Online在CI构建过程后不断部署我的项目.但是,我必须使用发布配置文件来构建生产web.config转换,以便部署的网站将使用生产数据库而不是dev DB.我跟随Scott Hanselman的博客文章在CI构建定义中添加MSBuild参数.我的论点是这样的:
/p:DeployOnBuild=true /p:PublishProfile=[publish profile name] /p:AllowUntrustedCertificate=true /p:UserName=[credentials obtained from Azure Website portal] /p:Password=[from the portal as well]
Run Code Online (Sandbox Code Playgroud)
看起来很有效,部署的网站现在正在使用生产数据库.
然后我注意到在Deployment部分下的CI构建定义中,有一个参数叫做:部署设置的路径.从这篇文章中,它说:
"网站的.pubxml文件的路径,相对于repo的根文件夹.忽略云服务."
这正是我想要的.所以我删除了MSBuild参数,通过在弹出窗口中选择pubxml文件来设置"部署设置路径",然后再试一次.
但是,这种简单易用的方法根本不起作用.即使它指向相同的pubxml文件,并且两种方式都获得了绿色CI构建,后者似乎仍然使用默认的web.config而不是部署后的转换后的.
所以我很好奇是否有人知道MSBuild参数中的PublishProfile与部署设置路径之间有什么区别?我用正确的方法做到了这一点吗?
msbuild continuous-deployment azure-web-sites publish-profiles azure-devops
我按照这篇文章https://azure.microsoft.com/en-us/blog/announcing-app-service-authentication-authorization/为我的MVC应用程序设置Azure身份验证.首先,我打开了Azure AD提供程序.在身份验证/授权设置中,我为"请求未经过身份验证时要执行的操作"选择了"允许请求(无操作)",因为我只需要用户登录某些控制器操作.
然后我添加了一个自定义FilterAttribute以检查一个操作是否需要身份验证,如/sf/answers/1865697151/.在OnAuthenticationChallenge函数中,我将此代码重定向到登录页面:
public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
{
if (filterContext.Result is HttpUnauthorizedResult) {
filterContext.Result = new RedirectResult("~/.auth/login/aad");
}
}
Run Code Online (Sandbox Code Playgroud)
所有这些都有效,除非用户完成身份验证后,它会被重定向回mysite/.auth/login/done页面,说"你已经成功登录",并有一个按钮返回我网站的基本网址.
我想要的是重定向返回到用户的原始URL,所以我想我需要以某种方式设置登录重定向的返回URL.但我找不到任何关于此的文件.有人可以提出任何建议吗?
javascript ×2
svg ×2
angularjs ×1
antialiasing ×1
asp.net ×1
asp.net-mvc ×1
async-await ×1
azure-devops ×1
c# ×1
cookies ×1
css3 ×1
debugging ×1
dynamics-crm ×1
filter ×1
github ×1
gradient ×1
html ×1
karma-runner ×1
msbuild ×1
node.js ×1
npm ×1
tfs ×1