我有一个类,它创建一个Image
from Byte[]
,以及一些其他逻辑,我正在尝试编写一个单元测试,断言Image
从我的类返回的实例与我Image
在单元测试中的假实例相同.
我找不到一个可靠的方法:
Image
\ Byte[]
\资源\ 东西.Byte[]
代表假的东西传递给我的班级.Image
从我的类返回是一样的我的假的东西.这是我到目前为止提出的代码:
Bitmap fakeBitmap = new Bitmap(1, 1);
Byte[] expectedBytes;
using (var ms = new MemoryStream())
{
fakeBitmap.Save(ms, ImageFormat.Png);
expectedBytes = ms.ToArray();
}
//This is where the call to class goes
Image actualImage;
using (var ms = new MemoryStream(expectedBytes))
actualImage = Image.FromStream(ms);
Byte[] actualBytes;
using (var ms = new MemoryStream())
{
actualImage.Save(ms, ImageFormat.Png);
actualBytes …
Run Code Online (Sandbox Code Playgroud) 我最近下载了VS2017并且已经尝试了一些新的C#7功能.然而,一个让我困惑的是因为它并不总是有效.
本地功能......
这些应该在MVC Web应用程序中工作吗?我已经创建了一个全新的WPF桌面应用程序并且它可以工作,但是当我创建一个全新的MVC Web应用程序时,以下代码不起作用(是的,我知道它没有意义).
public ActionResult Index()
{
void TestMethod(string message)
{
Console.WriteLine(message);
}
TestMethod("Why isn't this working?");
return View();
}
Run Code Online (Sandbox Code Playgroud)
IDE没有显示错误,但是当我编译它时,它会生成一个错误列表:
HomeController.cs(13,13,13,17): error CS1547: Keyword 'void' cannot be used in this context
HomeController.cs(13,28,13,43): error CS1528: Expected; or = (cannot specify constructor arguments in declaration)
HomeController.cs(13,28,13,29): error CS1003: Syntax error, '[' expected
HomeController.cs(13,29,13,35): error CS1525: Invalid expression term 'string'
HomeController.cs(13,36,13,43): error CS1026: ) expected
HomeController.cs(13,36,13,43): error CS1003: Syntax error, ',' expected
HomeController.cs(13,43,13,44): error CS1003: Syntax error, ']' expected
HomeController.cs(13,43,13,44): …
Run Code Online (Sandbox Code Playgroud) 我试图将字符串从C#传递给C DLL.从我读到的.NET应该为我做从字符串到char*的转换,但是我得到"错误CS1503:参数'1':无法从'字符串'转换为'字符*'"有人可以告诉我我在哪里出了什么问题?谢谢.
C#代码
[DllImport("Source.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
public static unsafe extern bool StreamReceiveInitialise(char* filepath);
const string test = "test";
// This method that will be called when the thread is started
public void Stream()
{
if (StreamReceiveInitialise(test))
{
}
}
Run Code Online (Sandbox Code Playgroud)
C DLL
extern "C"
{
__declspec(dllexport) bool __cdecl StreamReceiveInitialise(char* filepath);
}
Run Code Online (Sandbox Code Playgroud) 我创建了一个轻微定制的TFS构建过程模板以及适当的TFS构建定义.它在TFS构建服务器上构建良好.
有没有什么办法可以让开发人员重用相同的构建过程XAML和定义来在本地机器上进行完整构建?也许有一些实用程序可以使用TFS构建过程XAML文件运行?
我真的想避免为完整的本地重建维护一个单独的构建脚本副本.
我有一个带有Filter属性的ViewModel,它具有许多我用来过滤数据的属性
例:
class MyViewModel : IHasFilter
{
public MyData[] Data { get; set; }
public FilterViewModel Filter { get; set; }
}
class FilterViewModel
{
public String MessageFilter { get; set; }
//etc.
}
Run Code Online (Sandbox Code Playgroud)
这在使用我的视图时工作正常.我可以设置属性,Model.Filter
并将它们传递给Controller.我现在要做的是创建一个ActionLink
具有与上述格式一起使用的查询字符串.
我的View从上面生成的查询字符串如下所示:
http://localhost:51050/?Filter.MessageFilter=Stuff&Filter.OtherProp=MoreStuff
Run Code Online (Sandbox Code Playgroud)
我需要在网格中每行进入上面视图的不同视图中生成一个ActionLink.
我试过了:
Html.ActionLink(
item.Message,
"Index",
"Home",
new { Filter = new { MessageFilter = item.Message, }, },
null);
Run Code Online (Sandbox Code Playgroud)
我也尝试将routeValues
参数设置为:
new MyViewModel { Filter = new FilterViewModel { MessageFilter = item.Message, }, },
Run Code Online (Sandbox Code Playgroud)
但是这些不会像上面那样生成查询字符串.
我们计划搬到TFS.虽然我讨厌它,但我们必须出于各种原因这样做.
我们有开发,分期和现场分支.我们是否将每个分支的源移动到TFS作为单独的文件夹并稍后将其转换为分支?
是否有可能历史沿革?
有没有可以做到的工具或脚本?
我想问一下如何将配置文件包含在nuget包中。我有一个 aseembly,需要一个配置文件,为了使其易于使用,我希望在 nuget 包使用应用程序的构建过程中复制配置文件!
我不想通过构建前或构建后事件来完成此操作。
有机会这样做吗?
如何在VSO部署模板中设置ASPNETCORE_ENVIRONMENT变量?
我需要使用TFS API完成一些事情.其中,我必须阅读每个项目的sprint的资源规划信息,以显示在WPF UI中.
在本指南中标记,我现在有以下方法:
private TfsTeamService _teamService;
private ICommonStructureService4 _structureService;
TeamSettingsConfigurationService _teamSettingsConfigurationService;
public void GetUserIterationAssignments(IList<ProjectInfo> projects)
{
foreach (ProjectInfo project in projects)
{
Console.WriteLine(project.Name);
TeamFoundationTeam team = _teamService.QueryTeams(project.Uri).First();
IList<Guid> teamGuids = new List<Guid>() { team.Identity.TeamFoundationId };
TeamConfiguration config = _teamSettingsConfigurationService.GetTeamConfigurations(teamGuids).FirstOrDefault();
if (config != null)
{
foreach (string nodePath in config.TeamSettings.IterationPaths)
{
var projectNameIndex = nodePath.IndexOf("\\", 2);
var fullPath = nodePath.Insert(projectNameIndex, "\\Iteration");
var nodeInfo = _structureService.GetNodeFromPath(fullPath);
if (nodeInfo.StartDate != null &&
nodeInfo.FinishDate != null)
{
foreach (TeamFoundationIdentity member in …
Run Code Online (Sandbox Code Playgroud) tfs ×5
c# ×3
asp.net-mvc ×2
.net ×1
actionlink ×1
azure-devops ×1
build ×1
c ×1
c#-7.0 ×1
char ×1
deployment ×1
dll ×1
mercurial ×1
nuget ×1
nuspec ×1
string ×1
tfs-sdk ×1
tfs2012 ×1
tfsbuild ×1