Jasonnn
Jasonnn
CC#
Created by Jasonnn on 9/9/2024 in #help
✅ Nullable<int> and xUnit
I'm writing unit tests for a method that has int? as a return type. When I do: Assert.Equal(null, parser.GetNumber(myArguments)); xUnit tells me xUnit2003: Do not use Assert. Equal() to check for null value. Use Assert.Null instead. When I do Assert.Null(parser.GetNumber(myArguments)); It tells me xUnit2002: Do not use Assert.Null() on value type 'int'. Remove this assert. What is happening? What should I do?
9 replies
CC#
Created by Jasonnn on 9/9/2024 in #help
✅ Reading/Writing in Excel with C#
It seems there are plenty of options to read/write .xlsx files (EPPlus, OpenXML, ClosedXML, ...)? Are there some that are "more official" / "better" and that I really should use? Or are they all more or less the same?
43 replies
CC#
Created by Jasonnn on 8/30/2024 in #help
merge into pattern
No description
63 replies
CC#
Created by Jasonnn on 8/3/2024 in #help
Relative paths with assemblies calling each other
I have parent_dir/HaploDeep/models/some_files.onnx, parent_dir/HaploDeep/HaploDeep.cs and parent_dir/HaploDeep.Tests/Tests.cs In HaploDeep.cs I want to open models/files.onnx so I do
private readonly string[] _modelPaths =
[
@"models\model_1.onnx",
@"models\model_2.onnx",
@"models\model_3.onnx",
@"models\model_4.onnx",
@"models\model_5.onnx"
];
// Load them by using the array _modelPaths
private readonly string[] _modelPaths =
[
@"models\model_1.onnx",
@"models\model_2.onnx",
@"models\model_3.onnx",
@"models\model_4.onnx",
@"models\model_5.onnx"
];
// Load them by using the array _modelPaths
but when I call the unit tests it says System.IO.IOException: Model file models\model_1.onnx does not exists. I tried to do that:
string basePath = AppDomain.CurrentDomain.BaseDirectory;
_modelPaths = [
Path.Combine(basePath, @"models\model_1.onnx"),
Path.Combine(basePath, @"models\model_2.onnx"),
Path.Combine(basePath, @"models\model_3.onnx"),
Path.Combine(basePath, @"models\model_4.onnx"),
Path.Combine(basePath, @"models\model_5.onnx")
];
// Load them by using the array _modelPaths
string basePath = AppDomain.CurrentDomain.BaseDirectory;
_modelPaths = [
Path.Combine(basePath, @"models\model_1.onnx"),
Path.Combine(basePath, @"models\model_2.onnx"),
Path.Combine(basePath, @"models\model_3.onnx"),
Path.Combine(basePath, @"models\model_4.onnx"),
Path.Combine(basePath, @"models\model_5.onnx")
];
// Load them by using the array _modelPaths

in HaploDeep.cs But then when running my unit tests I have the same, it thinks the relative paths are relative to HaploDeep.Tests path: System.IO.IOException: Model file C:\...\HaploDeep.Tests\bin\Debug\net8.0\models\model_1.onnx does not exi... I've been using Python for years and if a path was relative in library 1, when library 2 would use library 1, the paths would be relative to library 1; not to library 2. And here I'm really confused. Would really appreciate some help, I've been banging my head on this for the past hour
16 replies