A URI scheme name 'pack' already has a registered custom parser

I am newborn to NUNIT test,facing error as 'A URI scheme name 'pack' already has a registered custom parser'.

[SetUp]
public void OnTestInitialize()
{
    UriParser.Register(new GenericUriParser(
    GenericUriParserOptions.GenericAuthority), "pack", -1);
    EncodeDecode = new EncodeDecodeSeNoSensorModes();
}
[TestCase(1,1,SSTAvail.no,3)]
[TestCase(0, 0, SSTAvail.no, 3)]
[TestCase(0, 1, SSTAvail.no, 0)]
[TestCase(0, 2, SSTAvail.no, 0)]
public void DecodeModeTest(int input1,int input2,SSTAvail Input3,int ExpectedResult)
{
    int OutputResult;

    //act 
    OutputResult = EncodeDecode.DecodeMode(input1,input2,Input3);

    // assert  
    NUnit.Framework.Assert.AreEqual(OutputResult, ExpectedResult);
}

If I run one test I am not facing issue. If run all test ended up this error

Jon Skeet
people
quotationmark

Well presumably OnTestInitialize is currently being called once per test, but you want UriParser.Register to be called once in total. That's the sort of thing that makes sense to do in a static initializer, which is guaranteed to be run exactly once per AppDomain.

On the other hand, if your EncodeDecodeSeNoSensorModes class is meant to be dealing with the pack URI scheme, perhaps that's the class that should have the static initializer... it's not really clear what your code is doing.

people

See more on this question at Stackoverflow