添加资源文件以在Rider中进行测试 [英] Adding resource file for testing in Rider

查看:79
本文介绍了添加资源文件以在Rider中进行测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开始使用Rider在Linux中使用C#进行开发.我创建了如下测试:

I have started to use rider for developing in Linux with C#. I have created my tests like:

namespace RAWConverter
{

    using NUnit.Framework;

    [TestFixture]
    public class SerializationHelperTest
    {

        [Test]
        public void SerializeEntry()
        {
            msRun msRun = new msRun();
            SerializationHelper.SerializationEntry(System.IO.Path.GetTempFileName(), msRun);
        }

        [Test]
        public void DeserializationEntry()
        {
            msRun msRun = SerializationHelper.DeserializationEntry(getFileNameFromResource(RAWConverter.Properties.));
            Console.WriteLine(msRun.endTime);
        }

        private string getFileNameFromResource(String fileName)
        {
            String strAppPath = Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName);
            String strFilePath = Path.Combine(strAppPath, "resources");
            return Path.Combine(strFilePath, fileName);
        }

    }
}

,我的项目中有一个名为资源的文件夹,其中包含该文件.但是,当我执行测试时,它会失败,因为此变量

and I have a folder in my project called resources that contains the file. However when I execute my tests it fail because this variable

System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName

位于/usr/bin

有什么想法吗?

推荐答案

bin文件夹是默认的输出目录,在此目录中,项目二进制文件将在构建项目时复制到该目录并从中执行.如果您要手动将资源文件夹及其内容复制到bin文件夹,则测试可以进行.

The bin folder is the default output directory where the project binaries are copied to and executed from when the project is built. If you were to manually copy the resources folder and its contents to the bin folder the test would work.

我对所讨论的IDE不熟悉,但是我建议检查是否存在一个设置,该设置允许在构建项目时将资源自动复制到输出目录.

I am not familiar with the IDE in question but I suggest checking if there is a setting that will allow for resources to be automatically copied to the output directories when the project is built.

在他们的社区中找到了评论

Found a comment in their community

我们将在几天内发布新的EAP版本,新构建的构建操作"和复制到输出目录"是下拉菜单.

We are about to publish new EAP build in couple of days, and in that new build "Build Action" and "Copy to output directory" are drop-downs.

目前,您可以在SolutionExplorer中的项目上按F4键,然后手动编辑包含".

For now you may press F4 on project in SolutionExplorer and edit Include manually.

这篇关于添加资源文件以在Rider中进行测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆