2

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

is in /usr/bin

Any ideas?

2
  • 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 copy the resources folder and its contents to the bin folder the test would work.
    – Nkosi
    Commented May 18, 2017 at 17:45
  • Thanks, @Nkosi for your quick response. Well, I know that the bin folder is where the execution is happening by default. The test will also work if I point to a direct path like: /home/user/resources. I'm more interested to know in the exact way of defining and access to a resource folder withing a C# .Net project.
    – ypriverol
    Commented May 18, 2017 at 21:30

1 Answer 1

0

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.

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

Editing file properties - Copy to output directory

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.

properrrties

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

2
  • 2
    The IDE is the one from JetBrain for C# Rider
    – ypriverol
    Commented May 18, 2017 at 21:33
  • 1
    I gathered as much, which is why I did some checking on how to get the folder deployed with the binaries when the project is built. If you check the support forum you may be able to get some more help. I believe it is related to the build action of the required resources in the project
    – Nkosi
    Commented May 18, 2017 at 21:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.