我正在使用 Swagger UI 和 asp.net core web api。对于我的CRUD操作,我有一个基本控制器类,它定义了抽象方法:
public class BaseController<TDto, TEntity>
{
[HttpPost, Route("create-single")]
public abstract Task<ObjectResult> CreateAsync(TDto input);
[HttpPost, Route("create-many")]
public abstract Task<ObjectResult> CreateManyAsync(IList<TDto> input);
[HttpGet, Route("get-all")]
public abstract Task<ObjectResult> GetAllAsync();
[HttpGet, Route("get/{id}")]
public abstract Task<ObjectResult> GetByIdAsync(Guid id);
...
...
}
Run Code Online (Sandbox Code Playgroud)
某些控制器可能不需要所有 CRUD 方法,并且我需要从 swagger 中消失这些端点。
例如,我需要消失/get/{id}特定控制器的端点,实现此目的的最佳方法是什么?
我已经安装了nodejs 8,我无法使用角度1运行业力测试.正如Karma官方网站上指出的Note: Karma currently works on Node.js 0.10, 0.12.x, 4.x, 5.x, 6.x, and 7.x. See FAQ for more info.,我猜问题可能在我的节点版本中,他们建议通过NVM安装节点,但我已经安装了节点8.是否可以安装nvm并包含我当前的nodejs?
考虑我有这个简单的c#代码:
dynamic obj = new ExpandoObject();
obj.FirstName = "John";
obj.LastName = "Doe";
Run Code Online (Sandbox Code Playgroud)
John Doe在这种情况下,我想添加将返回全名的方法.我知道以下行会起作用,但不确定它是否是最好的方法
obj.GetFullName = new Func<string>(() => $"{obj.FirstName} {obj.LastName}");
Run Code Online (Sandbox Code Playgroud)
有没有其他方法dynamic object通过该GetFullName方法访问实例?
我有asp.net core 2.0 Web Api使用BLL( Business Logic Layer) 的项目。当我尝试BLL像Dependancy在我的Controller. 我已经实现了以下内容Controller:
namespace MyProject.WebApi.Controllers
{
[Route("api/test")]
public class TestController : Controller
{
private readonly ITestService _testService;
public TestController(ITestService testService)
{
_testService = testService;
}
[HttpGet, Route("get-all")]
public List<Test> Get()
{
return _testService.GetTestList();
}
}
}
Run Code Online (Sandbox Code Playgroud)
我已经在BLL(单独的项目)中实现了测试服务:
namespace MyProject.Core
{
public class TestService : ITestService
{
private readonly ITestEngine _testEngine;
public TestService(ITestEngine testEngine)
{
_testEngine = testEngine;
} …Run Code Online (Sandbox Code Playgroud) 我退出jenkins image并docker hub尝试使用以下命令运行:
docker run jenkins
Run Code Online (Sandbox Code Playgroud)
或者
docker run -p 8080:8080 -p 50000:50000 jenkins
Run Code Online (Sandbox Code Playgroud)
然后我正在检查正在运行的 jenkins: docker inspect [container id],networks输出中的节点表示,ip address但是172.17.0.2当我在浏览器中输入时,172.17.0.2:8080它无法到达..有什么想法吗?
我必须模拟服务方法,该方法是在组件级别注入的,而不是在模块级别注入的。我的组件如下所示:
@Component({
selector: 'app-mycomponent',
template: '<some html content>',
...
providers: [MyService],
})
export class MyComponent implements OnInit {
constructor(private myService: MyService) {}
ngOnInit(): void {
this.myService.myMethod();
}
}
Run Code Online (Sandbox Code Playgroud)
和我的规格文件:
define('MyComponent', () => {
let component: MyComponent;
let fixture: ComponentFixture<MyComponent>;
let service: MyService;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [..some modules..],
providers: [
{ provide: MyService, useClass: MyServiceStub }
],
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(MyComponent);
component = fixture.componentInstance;
service = TestBed.get(MyService);
fixture.detectChanges();
});
it ('should call service method', () …Run Code Online (Sandbox Code Playgroud) 我安装了StyleCop NuGet包,现在我想更改几个设置StyleCop,但右键单击解决方案菜单不会出现StyleCop Settings阻塞..
有任何想法吗?
我的Angular 6应用程序和外部服务api每个请求最多返回 50 条记录。但在某些情况下我需要获取 100 条记录。
例如,以下请求将为我提供前 50 条记录:
www.example.com/records/?count=50
Run Code Online (Sandbox Code Playgroud)
接下来的 50 名:
www.example.com/records/?count=50&lastID=FAKEID
Run Code Online (Sandbox Code Playgroud)
是否有任何最佳实践可以在一种角度服务方法中发送 2 个 HTTP 请求,但同时返回两个响应数据?
c# ×4
angular ×2
.net ×1
.net-core ×1
asp.net ×1
asp.net-core ×1
docker ×1
http ×1
jenkins ×1
karma-runner ×1
mocking ×1
node.js ×1
nuget ×1
nvm ×1
service ×1
stylecop ×1
swagger-ui ×1
typescript ×1
ubuntu ×1
unit-testing ×1
webapi ×1