我正在学习一些Web Api基础知识,我想返回并传递一个对象Ok(object).像这样的东西:
[HttpGet]
public IHttpActionResult Get()
{
var someString = "";
return Ok(someString);
}
Run Code Online (Sandbox Code Playgroud)
现在我想测试这个方法并断言来自这个Get()方法的返回字符串是否与预期相同.我猜猜看会是这样的:
[TestMethod]
public void TestGet()
{
IHttpActionResult result = controller.Get();
Assert.AreEqual("", result.??);
}
Run Code Online (Sandbox Code Playgroud)
我看到了这个问题,但最好的答案是解释如何验证HttpStatusCode,而不是传递的对象.
我正在为准备好的代码编写单元测试,并且我收到一个意外的AssertFailedException试图运行其中一个测试.他是这样的:
[TestMethod]
public void TestPositionGetter()
{
testPlayer.Position = new int[] { 1, 3 };
int[] expectedPosition = testPlayer.Position;
Assert.AreEqual(expectedPosition, testPlayer.Position);
}
Run Code Online (Sandbox Code Playgroud)
这是我正在尝试测试的Player类中的Position属性:
public int[] Position
{
get
{
return new int[] { this.PositionX, this.PositionY };
}
set
{
this.PositionX = value[0];
this.PositionY = value[1];
}
}
Run Code Online (Sandbox Code Playgroud)
调试测试,在局部变量窗口中,player.Position和expectedPosition看起来相似,但测试仍然失败.我担心这个问题来自参考文献.
我正在关注Google I/O大会,就在他们宣布Android Studio 0.8可供下载前一周.在此之前我使用0.6并且我正在开发一个应用程序.现在我的Ubuntu上有0.6和0.8.我添加了SDK for Android Watch and TV和所有Material Design内容的所有更新.今天当我在0.8版本中打开我的项目时,经过一些事情的更新后,我收到了一个错误
Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 8 cannot be smaller than version L declared in library com.android.support:appcompat-v7:21.0.0-rc1
Run Code Online (Sandbox Code Playgroud)
如果有人知道这是什么 - 请分享.我试图从GitHub中的存储库中取出我的项目,但没有任何结果.谢谢.
我正在开发一个Android应用程序,我想添加一个自定义字体.我看了一下史诗资产文件夹,然后她的位置在像一些主题此.我检查了我的src文件夹 - 它不在那里.我检查了项目树中的几乎每个目录,但我仍然找不到她.这是我的目录树的图片.顺便说一句,在我之前的项目中,在Android 0.6上我曾经添加了自定义字体,但我不记得该文件夹位于何处,现在,在Android Studio 0.8上我甚至找不到我的文件夹.

我有个问题.我想实现一个插入排序,但在不同类型的数组 - int,string和double,但我不知道如何在方法中获得不同类型的参数.这是一些代码:
private static string InsertionSort(int[] array)
{
Stopwatch stopwatch = new Stopwatch();
int index, i, j;
stopwatch.Start();
for (i = 1; i < array.Length; i++)
{
index = array[i];
j = i;
while ((j > 0) && (array[j - 1] > index))
{
array[j] = array[j - 1];
j = j - 1;
}
array[j] = index;
}
stopwatch.Stop();
return stopwatch.Elapsed.ToString();
}
Run Code Online (Sandbox Code Playgroud)
我尝试使用InsertionSort(dynamic []数组)但它仍然不起作用.
我正在做一个简单的例子,根据输入键我在控制台上写了不同的消息.问题是每次我读到一个键时,下一个Console.WriteLine()结果都会在开始时连接一个'a'符号?这是一个例子:
ConsoleKeyInfo keyInfor = Console.ReadKey();
if (keyInfor.Key == ConsoleKey.UpArrow)
{
Console.WriteLine("Up arrow");
}
Run Code Online (Sandbox Code Playgroud)
单击向上箭头时的预期结果:"向上箭头"
实际结果:"aUp arrow"
我正在将Android Studio与GitHub存储库结合使用.所以我刚刚推动了整个项目,但我提到我只能推送我的src文件夹.有什么理由我不能推送我的构建和src文件夹或只是我做错了什么?当我尝试提交它们时,我收到一条消息,告诉我没有检测到更改,但是当我进入我的存储库时,没有这样的文件夹.
我想为我的项目编写单元测试,我想知道是否有任何方法可以检查是否在特定目录中创建了任何文件,如果是,则由多少行组成?再次感谢!这是该项目的一些代码。
c# ×5
android ×3
unit-testing ×2
git ×1
github ×1
methods ×1
selection ×1
selenium ×1
selenium-ide ×1
sorting ×1