我是Moq框架的新手,我有一个测试方法,但我收到以下错误.我找不到我错过的地方.
有人可以告诉我如何更正以下错误?
Moq.dll中出现"Moq.MockException"类型的异常,但未在用户代码中处理
其他信息:IResponseMessage.ReadContentAsString()调用失败,模拟行为Strict.
模拟上的所有调用都必须具有相应的设置.
Execp.cs
public Execp(IResponseMessage msg)
{
this.StatusCode = msg.StatusCode;//*getting exception here while running **method 1***
this.ReadContentAsString = msg.ReadContentAsString();//*getting exception here while running **method 2***
}
Run Code Online (Sandbox Code Playgroud)
我的测试方法
方法1
[TestMethod()]
public void TestFail()
{
int employeeId = 0;
DataModel.Employee.Get.Employee employee= new DataModel.Employee.Get.Employee();
string url = string.Format("api/1/somename/{0}", employeeId);
restClient
.Setup(x => x.Get(url))
.Returns(responseMessage.Object);
responseMessage.SetupGet(x => x.IsSuccessStatusCode).Returns(false);
var client = new account(clientFactory.Object, serverUri, moqLogged.Object);
var result = client.GetEmployee(employeeId);
Assert.AreEqual(result, null);
client.Dispose();
moqFactory.VerifyAll();
}
Run Code Online (Sandbox Code Playgroud)
方法2
[TestMethod()]
public void TestBadRequest()
{
var …Run Code Online (Sandbox Code Playgroud) 在我的场景中,我有 3 个或更多多页 tiff 图像,我需要将它们合并为单个 tiff 图像。
下面是我试过的代码。它合并为单个 tiff 图像,但仅包含所有 tiff 图像的第一页。
private static void MergeTiff(string[] sourceFiles)
{
string[] sa = sourceFiles;
//get the codec for tiff files
ImageCodecInfo info = null;
foreach (ImageCodecInfo ice in ImageCodecInfo.GetImageEncoders())
if (ice.MimeType == "image/tiff")
info = ice;
//use the save encoder
Encoder enc = Encoder.SaveFlag;
EncoderParameters ep = new EncoderParameters(1);
ep.Param[0] = new EncoderParameter(enc, (long)EncoderValue.MultiFrame);
Bitmap pages = null;
int frame = 0;
foreach (string s in sa)
{
if (frame == 0) …Run Code Online (Sandbox Code Playgroud) 我为数据表搜索框添加了一个select(下拉列表),用于按列搜索,并尝试将其添加到搜索框,如下所示->
var table = $('#example').DataTable({
dom: '<l<"toolbar">f>rtip',
language: {
search: "_INPUT_", //To remove Search Label
searchPlaceholder: "Search..."
}
})
$("div.toolbar").html(select);
Run Code Online (Sandbox Code Playgroud)
的CSS
.toolbar {
float: right;
}
Run Code Online (Sandbox Code Playgroud)
它实际上在小提琴上起作用-> https://jsfiddle.net/32v2qpj1/5/
令人惊讶的是,当我在.aspx页面上实现相同的长度和过滤器位置时,如下图所示。每当我使用dom时,Bootstrap行和col网格都将丢失。它为长度和搜索添加了2个单独的行,并且在页脚处添加了相同的行。我尝试通过https://datatables.net/reference/option/dom中的示例检查我的代码是否错误。使用DOM时只是重新定位!
我不知道为什么只添加dom时会重新定位。我想知道是否还有其他方法可以将选择控件添加到搜索框中?
我正在实现 jQuery 服务器端数据表。我有 1 个日期列和 2 个日期时间列。所有 3 个都以错误的格式显示在数据表上。
收货日期:/Date(1373947200000)/ (Date)
创建日期:/Date(1374845903000)/ (Datetime)
更新日期:/Date(1374845903000)/ (Datetime)
如何以正确的格式显示?
.cshtml
<table id="disparityForm" class="ui celled table" style="width:100%">
<thead>
<tr>
<th>Status</th>
<th>Received Date</th>
<th>Member ID</th>
<th>First Name</th>
<th>Last Name</th>
<th>Created User</th>
<th>Created Date</th>
<th>Updated User</th>
<th>Updated Date</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Status</th>
<th>Received Date</th>
<th>Member ID</th>
<th>First Name</th>
<th>Last Name</th>
<th>Created User</th>
<th>Created Date</th>
<th>Updated User</th>
<th>Updated Date</th>
</tr>
</tfoot>
</table>
<link href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.3.0/semantic.min.css" rel="stylesheet" />
<link href="~/Content/DataTables/media/css/dataTables.semanticui.min.css" rel="stylesheet" />
@section scripts{
<script src="~/Scripts/DataTables/media/js/jquery.dataTables.min.js"></script>
<script src="~/Scripts/DataTables/media/js/dataTables.semanticui.min.js"></script> …Run Code Online (Sandbox Code Playgroud)我正在为我的网格视图使用 datatables.net。在搜索框中,它正在从所有列中搜索。但我想要像下面这样的场景。
我有 5 列,可以说 - 姓名、年龄、号码、地址、性别。我希望下拉列表中的所有这些选项以及当用户选择名称并在搜索框中输入文本时的下拉列表中,它只会在名称列中搜索。同样明智的是,如果用户从下拉列表中选择年龄,他只能在年龄列上进行搜索。
我看过很多例子,它们与我需要的不同。
datatables ×3
jquery ×3
c# ×2
.net ×1
asp.net-mvc ×1
css ×1
datatable ×1
drawing ×1
javascript ×1
moq ×1
tiff ×1
unit-testing ×1