对于我正在现代化的项目,我有一套由应用程序的原始开发人员提供的单元测试。在我的现代化改造早期,它们是完全绿色运行的。然而,它们已经变成红色,但大多数情况下都有相同的例外:
例外:
System.IO.FileLoadException: Could not load file or assembly 'MyApp.BusinessLayer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Access is denied.
at MyApp.SomeExecutable.SomeClass.SomeMethod(args)
at MyApp.UnitTests.SomeExecutableFixture.CanValidateSomething() in [place of invocation of SomeClass.SomeMethod]
Run Code Online (Sandbox Code Playgroud)
异常没有内部异常。
从我所看到的,这发生在任何引用MyApp.BusinessLayer程序集中定义的东西的方法中,友好的错误消息通知我无法加载......显然是由于拒绝访问。
我尝试了以下方法来访问程序集:
fuslogvw.exe,并在运行时运行测试以了解绑定过程。没有信息出现;就好像在 Visual Studio 2015 中运行测试对 Fusion Log Viewer 完全不可见!即使在重新启动后,Fusion Log Viewer 也没有关于正在发生的程序集绑定的信息。(感谢@AndrewAu、@CodeCaster)在我正在研究的项目上,我一直在编写一个JavaScript对象.其中一个行为涉及删除一系列类中的任何子项,如下:
function Foo () {
var $a = $('.a'),
$b = $('.b'),
// ...etc...
$n = $('.n');
$a.remove();
$b.remove();
// ...etc again...
$n.remove();
}
Run Code Online (Sandbox Code Playgroud)
虽然有一些方法可以修改它以便更容易维护(将选择器放入单个数组弹簧中立刻想到),我想知道是否有任何优雅的方法.remove()在一系列选择器上执行操作,如下:
function FooPrime() {
var selectors = [
'.a',
'.b',
// ...
'.n'
];
// Perform remove on all given selectors?
$(selectors).remove();
}
Run Code Online (Sandbox Code Playgroud)
因此,问题:我可以通过多种方式在多个选择器上执行单个jQuery操作?
编辑:这是一个JSFiddle来显示问题上下文的简化版本.
对于我正在处理的应用程序,我们有一个功能,我们在服务器端为对象生成报告,并在客户端的新选项卡(暂时)中打开它.
我正在使用该URL.createObjectURL函数为a创建一个URL Blob,该URL 由AJAX调用的结果组成.$window.open(generatedFileUrl)但是,无论何时进行调用,我都会收到JavaScript错误.
控制器:
(function() {
angular.module('app').controller('someCtrl', [
'$window', 'someSvc', controller
]);
function controller($window, someSvc) {
var vm = this;
vm.thing = {}; // How we get the object is unimportant for this question.
vm.printThing = printThing;
function printThing() {
someSvc.printThing(vm.thing.id, vm.someFlag)
.then(function(result) {
var file = new Blob([result], {type: 'application/pdf'});
var fileURL = URL.createObjectURL(file);
$window.open(fileURL);
});
}
}
)();
Run Code Online (Sandbox Code Playgroud)
服务:
(function () {
angular.module('app').factory('someSvc', [
'$http', someSvc
]);
function someSvc($http) {
var service …Run Code Online (Sandbox Code Playgroud) 我最近在我使用的代码库中看到了一些代码,ReSharper提供了重构代码collection.Any(Func< bool >).
我想知道这对性能的影响.假设我有一个看起来像这样的电话:
bool hasEvenValue = collection.Any(i => (i % 2) == 0);
......以及看起来像这样的数据......
{ 1, 2, 3, 5, 3, 5, 1, 3, 5, 2 }
Enumerable.Any()何时返回值?在这种情况下,第二个数据元素,还是会在返回true之前处理每个元素?
对于我正在研究的项目,我们重构了一些重复的视图并将代码编写到Angular 1.5组件中.
这些组件专门打开一个Angular UI模式,当模态关闭时,应该在最上面的范围内执行一些回调.我们遇到的问题是,当我们关闭模态时,我们设置为回调的函数不会被调用.
我确保参考Angular 1.5 Documentation for Components,但关于'&'分类器如何工作的部分特别含糊.我引用:
输出通过&bindings实现,这些绑定用作组件事件的回调.
我发现这篇文章旁边没用了; 因此,在这种情况下,我不知道我正确使用'&'绑定分类器.这是我发生的事情:
MainFeature.html
<div ng-repeat="thing in vm.things">
<sub-feature onSave="vm.onSave()" thing="thing"></sub-feature>
</div>
Run Code Online (Sandbox Code Playgroud)
MainFeatureCtrl.js
(function () {
'use strict';
angular.module('app').controller('mainFeatureCtrl', [
mainFeatureCtrl
]);
function mainFeatureCtrl() {
var vm = this;
vm.onSave = function () {
// Save stuff
console.log('I should see this but do not.');
};
}
})();
Run Code Online (Sandbox Code Playgroud)
SubFeatureCmpt.js
(function () {
'use strict';
angular.module('app').component('subFeature', {
templateUrl: 'App/MainFeature/SubFeature/SubFeature.html',
controller: 'subFeatureCtrl',
controllerAs: 'vm',
bindings: {
thing: '=',
onSave: '&' // Point …Run Code Online (Sandbox Code Playgroud) 我在我正在处理的网页上发现了资源泄漏.
此网页有两个文本字段,在单击时显示模式对话框,对后端执行数据请求,然后在表中显示该信息,用户可以从中选择一个条目,以便在最初单击的文本框中使用.
我将点击事件绑定到文本框,如下所示:
var $field = $('#one-of-the-text-fields');
$field.click(function () {
App.DialogClass.show();
App.DialogClass.PopulateTable();
App.DialogClass.GotoPageButtonAction(actionArgs); // Offender!
});
Run Code Online (Sandbox Code Playgroud)
...哪个电话......
App.DialogClass = (function($) {
var pub {},
$gotoPage = $('#pageNumberNavigationField'),
$gotoPageButton = $('#pageNumberNavigationButton');
// ...SNIP unimportant other details...
pub.GotoPageButtonAction = function (args) {
$gotoPageButton.click(function () {
var pageNumber = $gotoPage.val();
pub.PopulateTable(args); // Breakpoint inserted here...
});
};
return pub;
})(jQuery);
Run Code Online (Sandbox Code Playgroud)
我注意到泄漏,因为当我使用Chrome的JavaScript调试器时,每次点击不同的按钮时,我总是会有一个额外的断点(例如,我第一次点击字段A时,断点被击中两次.当我击中字段时此后B,断点被击中三次.如果我点击后认为,断点命中四次.必要时外推.)
我的代码中没有任何地方可以处理给定字段的现有点击事件.我怀疑我的泄漏是因为事件没有得到清理.话虽这么说,我对JavaScript/jQuery也不是很熟悉.从控件中删除单击事件有哪些技巧?
对于我正在处理的应用程序,我最近实现了一个吸收用户输入的叠加层.当然,这只是我的目标之一 - 我还需要将生活在'内部'的popover居中.
这是我到目前为止的设置:
标记
<!-- snip extra HTML -->
<div id='some-overlay' class='input-eater hidden'>
<div id='some-prompt' class='overlay dialogue'>
This is a message that should be hidden.<br /><br />
<a href='javascript: $('#some-overlay').fadeOut();'>Click Here To Close</a>
</div>
</div>
<!-- ...SNIP... -->
Run Code Online (Sandbox Code Playgroud)
...后台页面上的某些操作会导致#some-overlay淡入,从而遮挡页面直到关闭操作发生.这是违规的JavaScript:
<!-- ...Continued from the markup above... -->
<script>
var $button = $('.some-element'),
$overlay = $('#some-overlay'),
$prompt = $('#some-prompt');
$(document).ready(function () {
$button.click(function(e) {
e.preventDefault();
var args = {
// ...snip. Unnecessary.
};
$.get('Home/SomeAction', args, function(result) {
// Some …Run Code Online (Sandbox Code Playgroud) 对于我正在进行的项目,我的团队使用 ActiveReports 在服务器上生成报告。我们生成了允许报告功能工作的许可证 DLL。
在我们的 VS2012 解决方案中,我们包含了一个 /lib/ 目录,该目录包含某些外部 DLL,例如 ActiveReports 程序集和此许可证 DLL。
但是,在尝试将 DLL 添加到项目时,我们会收到两个错误,连续出现。我尝试使用以下步骤添加现存的 DLL:
但是,在这样做时,我会收到两个背靠背的错误:
我已经检查了我的本地操作系统权限,以确保 DLL 所在的文件夹是可访问的,并且 VS 2012 中出现的对象的路径指向正确的位置。 问题:是什么导致了这个错误?当然,我错过了一些东西......
对于我从 AngularJS 重写的应用程序,我有一系列操作:
1) I got to the server to get a message
2) I display the returned message in a generic dialog, with a Yes and No button.
3-Yes) I go to the server to do something, proceed to 4
3-No) I terminate the sequence
4) Notfiy the user that the operation is complete.
Run Code Online (Sandbox Code Playgroud)
然而,我在将其转换为 Angular/ReactObservable系统时遇到问题。我想做这样的事情:
// Actual arguments are immaterial in this case...
this.webDataService.get('/api/GetEndUserMessage', args)
.pipe(
map((message: string) => {
const config = new MatDialogConfig();
config.data …Run Code Online (Sandbox Code Playgroud) 对于我正在开发的新项目,我的团队和我正在尝试使用ReSharper 10,NUnit,SpecFlow和Selenium设置一些功能测试.我们从一个已知的工作项目迁移了一堆旧代码,并使其构建没有问题.
但是,当我们运行代码时,我们不断收到以下错误:
OneTimeSetUp: System.IO.DirectoryNotFoundException : Could not find a part of the path 'C:\Users\Me\AppData\Local\SomeApp\App_Data\SomeApp.db'.
Exception doesn't have a stacktrace
Run Code Online (Sandbox Code Playgroud)
......这不对; 如果它找不到SomeApp.db文件,那应该是失败的C:\MyProjects\SomeApp\SomeApp.Web\App_Data\SomeApp.db!
这种情况下的相关代码在我们的TestSuite.cs类中:
[Binding]
public class TestSuite
{
private string _currentPath;
private string _localFile;
private string _websiteBinPath;
private string _websiteDataPath;
// Stuff...
[BeforeTestRun]
public static void BeforeTestRun()
{
_currentPath = Directory.GetCurrentDirectory() + @"\";
// Data:
// <add key="TestWebsiteDataRelativePath" value="..\..\..\SomeApp.Web\App_Data\" />
// <add key="TestWebsiteBinRelativePath" value="..\..\..\SomeApp.Web\bin\" />
_websiteBinPath = Path.Combine(_currentPath, ConfigurationManager.AppSettings["TestWebsiteBinRelativePath"]);
_websiteDataPath = Path.Combine(_currentPath, ConfigurationManager.AppSettings["TestWebsiteDataRelativePath"]);
//removes the ../../../ …Run Code Online (Sandbox Code Playgroud) javascript ×4
jquery ×3
angularjs ×2
c# ×2
html5 ×2
unit-testing ×2
angular ×1
components ×1
css3 ×1
directory ×1
ienumerable ×1
lambda ×1
linq ×1
memory-leaks ×1
modal-dialog ×1
nunit ×1
performance ×1
reactjs ×1
resharper ×1