这个问题是我的另一个问题的可能解决方案(他们建议使用addMockModule量角器):使用Protractor运行测试时调用其他api.
我有以下文件:mockedRest.js这是我要添加到量角器的模块.它应该拦截任何REST调用并替换地址(api /到apiMock /).
exports.apiMockModule = function () {
console.log('apiMockModule executing');
var serviceId = 'mockedApiInterceptor';
angular.module('apiMockModule', ['myApp'])
.config(['$httpProvider', configApiMock])
.factory(serviceId,
[mockedApiInterceptor]);
function mockedApiInterceptor() {
return {
request: function (config) {
console.log('apiMockModule intercepted');
if ((config.url.indexOf('api')) > -1) {
config.url.replace('api/', 'apiMock/');
}
return config;
},
response: function (response) {
return response
}
};
}
function configApiMock($httpProvider) {
$httpProvider.interceptors.push('mockedApiInterceptor');
}
};
Run Code Online (Sandbox Code Playgroud)
然后我在实际测试中加载模块.
describe('E2E addMockModule', function() {
beforeEach(function() {
var mockModule = require('./mockedRest');
browser.addMockModule('apiMockModule', mockModule.apiMockModule);
console.log('apiMockModule loaded');
browser.get('#page'); …Run Code Online (Sandbox Code Playgroud) 将基本的express.js配置(使用TypeScript)添加到使用angular-cli初始化的Angular2项目时ng new [project-name],我需要添加以下类型以使用gulp编译快速服务器:
typings安装--ambient --save node
这会将以下行添加到typings/browser.d.ts和typings/main.d.ts
/// <reference path="browser/ambient/node/index.d.ts" />
and
/// <reference path="main/ambient/node/index.d.ts" />
Run Code Online (Sandbox Code Playgroud)
在快递server.ts文件中,我可以添加引用main而不是browser保持TypeScript快乐
/// <reference path="../typings/main.d.ts" />
Run Code Online (Sandbox Code Playgroud)
但是当我将节点输入引用留在browser.d.ts文件中时,该ng build命令将失败:
Build failed.
The Broccoli Plugin: [BroccoliTypeScriptCompiler] failed with:
Error: Typescript found the following errors:
C:/Users/user123/Downloads/my-catalog-master/my-catalog-master/tmp/broccoli_type_script_compiler-input_base_path-7VFCE2dg.tmp/0/src/typings.d.ts (3, 13): Subsequent variable declarations must have the same type. Variable 'module' must be of type 'NodeModule', but here has type '{ id: string; }'. …Run Code Online (Sandbox Code Playgroud) 该应用程序作为(32位.NET Core 2.2)应用程序服务部署在Azure上。使用标准AspNetCoreModule而不是AspNetCoreModuleV2支持InProcesshostingmodel 的较新版本时,它可以正常工作。
使用新的InProcess托管模型时,实际错误是
找不到进程内请求处理程序。从调用hostfxr捕获的输出:无效的runtimeconfig.json [D:\ home \ site \ wwwroot \ Foo.Api.runtimeconfig.json] [D:\ home \ site \ wwwroot \ Foo.Api.runtimeconfig.dev.json]
wwwroot位置的Foo.Api.runtimeconfig.json
{
"runtimeOptions": {
"tfm": "netcoreapp2.2",
"framework": {
"name": "Microsoft.AspNetCore.App",
"version": "2.2.0"
},
"configProperties": {
"System.GC.Server": true
}
}
}
Run Code Online (Sandbox Code Playgroud)
Web.config
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\Foo.Api.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="InProcess">
<handlerSettings>
<handlerSetting name="debugLevel" value="file" />
<handlerSetting name="debugFile" value=".\logs\ancm.log" /> …Run Code Online (Sandbox Code Playgroud) 我正在使用Angular2 RC5并@angular/router使用一个简单的router-outlet元素.我有一个Observable在视图中正常工作,但是当你进行页面刷新(F5或CTRL-F5)时它不起作用.我在Chrome(最新)和IE11(可能还有其他浏览器)中都有这个.目前我有一个解决方法,但我不明白为什么我的更改没有自动反映在视图中.
该项目相当大,所以试图在这里尽量减少它:
在MyService.ts中
@Injectable()
export class MyService {
initialValue: MyObject = new MyObject(); // actually I read this from local storage...
_information: BehaviorSubject<MyObject> = new BehaviorSubject(this.initialValue);
get obsMyObj(): Observable<MyObject> {
return this._information.asObservable();
}
myServiceFunction() {
return this.http.get(`api/myUrl`)
.map(this.extractMyInfo);
}
extractMyInfo = (res: Response): MyObject {
let body = res.json();
var myObject = new MyObject().mapAllProperties(body);
this._information.next(myObject);
return myObject;
}
}
Run Code Online (Sandbox Code Playgroud)
在MyComponent.ts中:
@Component({
selector: '[header]',
templateUrl: 'app.component.header.html'
})
export class HeaderComponent implements OnInit …Run Code Online (Sandbox Code Playgroud) 我正在尝试执行以下代码(来源:http://geekswithblogs.net/PearlFactory/archive/2011/11/23/convert-mp3-to-aacflac-to-aac-or-any-other-combination.aspx)使用System.Diagnostics.Process.它在命令行中运行良好.但在C#中它失败了 字符.
var myProcess = new Process();
var p = new ProcessStartInfo();
var sArgs = " -i emp.mp3 -f wav - | neroAacEnc -ignorelength -q 0.5 -if - -of emp.mp4";
p.FileName = "ffmpeg.exe";
p.CreateNoWindow = false;
p.RedirectStandardOutput = false;
p.UseShellExecute = false;
p.Arguments = sArgs;
myProcess.StartInfo = p;
myProcess.Start();
myProcess.WaitForExit();
Run Code Online (Sandbox Code Playgroud)
它给出以下错误:
无法为"|"找到合适的输出格式:参数无效
我查看了stackoverflow并找到了以下提示,但它也无法正常工作:
var psi = new ProcessStartInfo("ffmpeg.exe");
psi.Arguments =
"\"-i emp.mp3 -f wav -\" | \"neroAacEnc -ignorelength -q 0.5 -if - -of emp.mp4\"";
psi.CreateNoWindow = …Run Code Online (Sandbox Code Playgroud) 我一直在阅读以下文章,该文章介绍了如何更改您网站的网络托管计划.
这似乎工作正常,但如果我使用相同的命令来更改Web托管模式(使用property:"sku": "Free"to "sku": "Standard")它不会给出任何错误反馈,只返回未更改的(上一个)存储配置.
执行命令:
$standardServer=@{"sku" = "Standard"; }
Set-AzureResource -Name 'tmtest2' -ResourceGroupName 'Default-Web-JapanWest' -ResourceType Microsoft.Web/sites -ApiVersion 2014-04-01 -PropertyObject $standardServer
Run Code Online (Sandbox Code Playgroud)
任何人都有运气改变使用Powershell的网络托管模式?
编辑:我也试过这个链接,准确描述了我想要实现的目标.但它没有用.
angular ×2
c# ×2
angular-cli ×1
angularjs ×1
asp.net-core ×1
cmdlets ×1
command-line ×1
ffmpeg ×1
node.js ×1
observable ×1
protractor ×1
typescript ×1