我使用实体库代替实体框架来执行数据操作。
以下是我的示例BL方法,该方法用于更新人的文化。我不知道如何为这种方法编写单元测试。
public static Culture UpdatePersonCulture(Guid userId, Culture culture)
{
try
{
if (userId == Guid.Empty)
throw new exception("User id should not be empty");
DatabaseProviderFactory factory = new DatabaseProviderFactory();
Database database = factory.CreateDefault();
using (DbConnection dbConnection = database.CreateConnection())
{
if (dbConnection.State == ConnectionState.Closed)
dbConnection.Open();
DbCommand dbCommand = database.GetStoredProcCommand("usp_UpdatePersonCulture");
database.DiscoverParameters(dbCommand);
dbCommand.Parameters["@userId"].Value = userId;
dbCommand.Parameters["@cultureId"].Value = culture.Id;
DataSet dataSet = database.ExecuteDataSet(dbCommand);
return BLDataPopulation.PopulateCultures(dataSet.Tables[0]).FirstOrDefault();
}
}
catch (Exception exception)
{
throw BLLogger.Log(exception);
}
}
Run Code Online (Sandbox Code Playgroud) 我已经提到了以下问题,但没有帮助我解决问题。
在 Quartz.NET 中,有没有一种方法可以设置一个只允许一个 Job 实例运行的属性?
https://github.com/quartznet/quartznet/issues/469
对于 CronTrigger,在调度程序中使用了以下内容cs.WithMisfireHandlingInstructionDoNothing()。
在HelloJob
DisallowConcurrentExecution.
代码怎么了?
在 Execute 方法中,我已经设置了断点。根据我的代码,execute 方法将在每个 10 秒内执行。
打到第一个断点后,又等了31秒。然后我删除了断点并执行了代码,根据我的期望,应该只执行一次以进行另一次尝试。
但是 execute 方法在另外 10 秒内执行了 3 次(3*10 秒)。
如何解决这个问题?
调度程序代码。
ISchedulerFactory schedFact = new StdSchedulerFactory();
IScheduler sched = schedFact.GetScheduler();
sched.Start();
// define the job and tie it to our HelloJob class
IJobDetail job = JobBuilder.Create<HelloJob>()
.WithIdentity("myJob", "group1")
.Build();
// Trigger the job to run now, and then every 40 seconds
ITrigger trigger = trigger = TriggerBuilder.Create()
.WithIdentity("trigger3", …Run Code Online (Sandbox Code Playgroud) 我是 Angular 5 的新手。
我已经为外部 JS 库创建了指令。
但是在同一个指令中,我将值绑定到属性。
我试图起诉ngAfterViewInit以检测是否所有值都绑定到该属性,然后调用 jQuery 插件。
但是我只找到了组件的生命周期钩子。我可以在指令中使用那些吗?这是一个不错的选择吗?
<div *ngFor="let item of easypiechartOptions"
[option]="item"
appEasyPieChart
[attr.data-percent]="item.percent">
</div>
Run Code Online (Sandbox Code Playgroud)
如果我不使用ngAfterViewInit,那么当我调用 jQuery 插件时,这些值不会被绑定。
如果我使用它,当我调用 jQuery 插件时,属性值就准备好了。
我正在使用HttpContext.Current.Server.MapPath()我的方法来获取文档.
要为此方法编写单元测试,
我该怎么做:
我怎么嘲笑这个?
我经历做一个单元测试只对Current.Server.Mappath()不Path.Combine()
我正在使用Visual Studio Premium 2012.
在单元测试中,它仅显示未覆盖的块数,但它不显示我未覆盖的块.
在visual studio 2010中,它显示了未覆盖的块数以及我没有用不同颜色覆盖的块.
如何知道我没有覆盖哪个区块?如何使用VS premium 2012来了解我没有覆盖哪个块?
for(i=0; i<5; i++)
{
method1();
}
sub method1()
{
// here do something
}
Run Code Online (Sandbox Code Playgroud)
这里我在for循环中调用了method1子程序.在这里,我希望在不等待先前调用的结果的情况下调用(并行)此method1子例程.怎么做 ?除了线程之外还有其他方法吗?
c# ×3
unit-testing ×3
angular5 ×1
asp.net ×1
directive ×1
javascript ×1
jquery ×1
perl ×1
quartz.net ×1