为什么人们总是使用enum值0, 1, 2, 4, 8
而不是0, 1, 2, 3, 4
?
这与位操作等有关吗?
我真的很感激有关如何正确使用它的小样本片段:)
[Flags]
public enum Permissions
{
None = 0,
Read = 1,
Write = 2,
Delete = 4
}
Run Code Online (Sandbox Code Playgroud) 我正在使用带有哈希定位策略的角度2.
该组件加载了该路由:
"departments/:id/employees"
Run Code Online (Sandbox Code Playgroud)
到目前为止很好.
在我成功批量保存多个已编辑的表行后,我想通过以下方式重新加载当前路由URL:
this.router.navigate([`departments/${this.id}/employees`]);
Run Code Online (Sandbox Code Playgroud)
但没有任何反应,为什么?
我想测试方法中的自定义逻辑CreateMap
.我不是要测试的映射是否都存在某些类型.
我该怎么做或者我需要知道的课程是什么.我很感激每一个提示文件.自动映射单元测试似乎非常罕见......
public class UnitProfile : Profile
{
protected override void Configure()
{
// Here I create my maps with custom logic that needs to be tested
CreateMap<Unit, UnitTreeViewModel>()
.ForMember(dest => dest.IsFolder, o => o.MapFrom(src => src.UnitTypeState == UnitType.Folder ? true : false));
CreateMap<CreateUnitViewModel, Unit>()
.ForMember(dest => dest.UnitTypeState, o => o.MapFrom(src => (UnitType)Enum.ToObject(typeof(UnitType), src.SelectedFolderTypeId)));
}
}
Run Code Online (Sandbox Code Playgroud) 有关功能和含义的区别是什么
TaskCompletionSource + SetResult vs Task + FromResult
在SendAsync方法?
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
if (request.RequestUri.Scheme != Uri.UriSchemeHttps)
{
var response = new HttpResponseMessage(HttpStatusCode.Forbidden) {ReasonPhrase = "HTTPS Required"};
var taskCompletionSource = new TaskCompletionSource<HttpResponseMessage>();
taskCompletionSource.SetResult(response);
return taskCompletionSource.Task;
}
return base.SendAsync(request, cancellationToken);
}
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
if (!request.RequestUri.Scheme.Equals(Uri.UriSchemeHttps, StringComparison.OrdinalIgnoreCase))
{
HttpResponseMessage reply = request.CreateErrorResponse(HttpStatusCode.BadRequest, "HTTPS is required for security reason.");
return Task.FromResult(reply);
}
return base.SendAsync(request, cancellationToken);
}
Run Code Online (Sandbox Code Playgroud) c# task-parallel-library async-await asp.net-web-api taskcompletionsource
我在webstorm IDE中需要更改哪些内容在我执行时识别引导类:
<a class="btn btn-primary" />
Run Code Online (Sandbox Code Playgroud)
目前我总是通过查看bootstrap css文件来重新检查类名.那不太好......
我在这里创建了一个plunker:http://plnkr.co/edit/zGqouwzxguef13lx48iP?p = preview
当我在日视图中单击ui-grid的单元格时,没有任何反应.我所期望的是执行测试功能并显示带有文本'test'的警报,但事实并非如此.
这里出了什么问题?
这是ui-grid 3.0最新版本的html单元模板:
HTML
<div ng-click="test()" ng-switch="row.entity[row.grid.columns.indexOf(col)].isPeriod">
<div ng-switch-when="true">
<tabset>
<tab>
<tab-heading>
<i class="glyphicon glyphicon-book"></i>
</tab-heading>period id:
{{ row.entity[row.grid.columns.indexOf(col)].id}}
</tab>
<tab select="alertMe()">
<tab-heading>
<i class="glyphicon glyphicon-bell"></i>
</tab-heading>
{{row.entity[row.grid.columns.indexOf(col)].content}}
</tab>
</tabset> <!-- PeriodTemplate -->
</div>
<div ng-switch-when="false">
<div>Hello empty template</div>
</div> <!-- EmptyPeriodTemplate -->
</div>
Run Code Online (Sandbox Code Playgroud)
控制器:
'use strict';
angular.module('projectplanner').controller('DateplannerDayController', function ($scope, $state) {
var columnHeaderDates = ['col1','col2','col3','col4','col5','col6','col7']
$scope.columns = createColumnHeaders(columnHeaderDates);
var data = [{isPeriod: true, id: 10, rowNumber: 1},{isPeriod: false, id: 11, rowNumber: 2}]
$scope.test …
Run Code Online (Sandbox Code Playgroud) 当我尝试将DBNull.Value插入可空的 varbinary(max)字段时,我得到此异常:
Implicit conversion from data type nvarchar to varbinary(max) is not allowed. Use the CONVERT function to run this query.
Run Code Online (Sandbox Code Playgroud)
那是我的代码:
insertCMD.Parameters.AddWithValue("@ErrorScreenshot", SqlDbType.VarBinary).Value = DBNull.Value;
Run Code Online (Sandbox Code Playgroud)
我知道在SO上存在重复的问题,但我不像其他人那样使用任何字符串.
我错了什么?
更新:
using (var insertCMD = new SqlCommand("INSERT INTO TestplanTeststep (TeststepId,TestplanId,CreatedAt,ErrorText,ErrorScreenshot,TestState) VALUES (@TeststepId, @TestplanId,@CreatedAt,@ErrorText,@ErrorScreenshot,@TestState)", con))
{
var p1 = insertCMD.Parameters.Add("@TeststepId", SqlDbType.Int);
var p2 = insertCMD.Parameters.Add("@CreatedAt", SqlDbType.DateTime);
insertCMD.Parameters.AddWithValue("@TestplanId", testplan.Id);
insertCMD.Parameters.AddWithValue("@ErrorText", (object) DBNull.Value);
insertCMD.Parameters.AddWithValue("@ErrorScreenshot", (object) DBNull.Value);
insertCMD.Parameters.AddWithValue("@TestState", (int)Teststep.TeststepTestState.Untested);
foreach (Teststep step in teststeps)
{
p1.Value = step.Id;
p2.Value = step.CreatedAt;
insertCMD.ExecuteNonQuery();
}
}
Run Code Online (Sandbox Code Playgroud) 自从我将webstorm IDE升级到v8.0.4后,输入/返回和tab键在代码编辑器中无效.
可能有任何设置我以某种方式改变,这些键不起作用?
我刚刚发现这个奇怪的行为只在主index.html文件中而不是在我的部分html文件中??? !!!
为什么toggleDropdown函数中传递的$ event对象未定义?
这是来自以下网站的原始代码:http://plnkr.co/edit/koNsQycAAiEmI8jBApS2?p = preview
除了原始代码没有定义button-tag中的toggleDropdown函数.我这样做是因为原始代码没有打开我的计算机上的下拉列表.
我使用angularjs 1.3.2和angularjs-bootstrap 0.11.2
'use strict';
angular.module('auth').controller('AccountController', function ($scope) {
$scope.status = {
isopen: false
};
$scope.toggleDropdown = function($event) {
$event.preventDefault();
$event.stopPropagation();
$scope.status.isopen = !$scope.status.isopen;
};
});
<!-- Single button -->
<div class="btn-group" dropdown is-open="status.isopen">
<button ng-click="toggleDropdown()" type="button" class="btn btn-primary dropdown-toggle" dropdown-toggle ng-disabled="disabled">
Button dropdown <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li class="divider"></li>
<li><a href="#">Separated link</a></li>
</ul>
</div>
Run Code Online (Sandbox Code Playgroud) 我想集成测试我的存储库.
我想在每个集成测试方法之前设置和插入测试数据.然后我想执行我的存储库逻辑然后我想断言逻辑通过从数据库返回正确的数据来工作.
我不想模拟和单元测试DbSet ;-)只是真正的集成测试.
我的问题是关于数据库的整个设置和清除测试数据.
我使用代码第一种方法生成TestDatabase和ProdDatabase.在ProdDatabase中,我将真实数据播种,然后在UI中播放,并检查正确的行为.TestDatabase仅用于集成测试.
两个数据库都是从ONE上下文创建的.
当我更改实体的任何属性并运行集成测试时,也会调用来自我的DbContext的覆盖的Seed方法.但我不希望我的TestDatabase.
如何才能将Seed调用分开仅针对我的ProdDatabase?我的TestDatabase每次测试都会生成自己的"种子"/设置数据?
angularjs ×2
c# ×2
webstorm ×2
angular ×1
async-await ×1
automapper ×1
dbnull ×1
enums ×1
flags ×1
insert ×1
permissions ×1
sql ×1
unit-testing ×1
varbinarymax ×1