chore: deploy initial code base
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Strata.RxNorm.Biz.Test.Unit.Extensions
|
||||
{
|
||||
[ExcludeFromCodeCoverage]
|
||||
public static class ResourceExtensions
|
||||
{
|
||||
|
||||
public static IEnumerable<string> LoadRxnNorm(this Assembly assembly, string fileName)
|
||||
{
|
||||
var path = assembly.resourceName(fileName);
|
||||
return assembly.ReadAllResourceLines(path);
|
||||
}
|
||||
|
||||
public static string resourceName(this Assembly assembly, string fileName)
|
||||
=> assembly.GetManifestResourceNames().Single(str => str.EndsWith(fileName));
|
||||
|
||||
public static string[] ReadAllResourceLines(this Assembly assembly, string resourceName)
|
||||
{
|
||||
using Stream stream = assembly.GetManifestResourceStream(resourceName);
|
||||
using StreamReader reader = new StreamReader(stream);
|
||||
return EnumerateLines(reader).ToArray();
|
||||
}
|
||||
|
||||
public static IEnumerable<string> EnumerateLines(TextReader reader)
|
||||
{
|
||||
string line;
|
||||
|
||||
while ((line = reader.ReadLine()) != null)
|
||||
{
|
||||
yield return line;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using Strata.RxNorm.Biz.RxNorm;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Strata.RxNorm.Biz.Test.Unit.Extensions
|
||||
{
|
||||
[ExcludeFromCodeCoverage]
|
||||
public static class RxnAttributeExtension
|
||||
{
|
||||
|
||||
public static IEnumerable<RxnAttribute> LoadRxnAttributes(this string fileName)
|
||||
{
|
||||
var assembly = Assembly.GetExecutingAssembly();
|
||||
var lines = assembly.LoadRxnNorm(fileName);
|
||||
return lines.Select(l => l.AttributeCtor()).ToList();
|
||||
}
|
||||
|
||||
public static RxnAttribute AttributeCtor(this string line, string separator = "|")
|
||||
{
|
||||
var data = line.Split(separator).ToArray();
|
||||
var r = new RxnAttribute();
|
||||
r.Rxcui = data[0];
|
||||
r.Lui = data[1];
|
||||
r.Sui = data[2];
|
||||
r.Rxaui = data[3];
|
||||
r.Stype = data[4];
|
||||
r.Code = data[5];
|
||||
r.Atui = data[6];
|
||||
r.Satui = data[7];
|
||||
r.Atn = data[8];
|
||||
r.Sab = data[9];
|
||||
r.Atv = data[10];
|
||||
r.Suppress = data[11];
|
||||
r.Cvf = data[12];
|
||||
return r;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
using Strata.RxNorm.Biz.RxNorm;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Strata.RxNorm.Biz.Test.Unit.Extensions
|
||||
{
|
||||
[ExcludeFromCodeCoverage]
|
||||
public static class RxnConceptExtension
|
||||
{
|
||||
public static IEnumerable<RxnConcept> LoadRxnConcepts(this string fileName)
|
||||
{
|
||||
var assembly = Assembly.GetExecutingAssembly();
|
||||
var lines = assembly.LoadRxnNorm(fileName);
|
||||
return lines.Select(l => l.ConceptCtor()).ToList();
|
||||
}
|
||||
|
||||
public static RxnConcept ConceptCtor(this string line, string separator = "|")
|
||||
{
|
||||
var data = line.Split(separator).ToArray();
|
||||
var r = new RxnConcept();
|
||||
r.Rxcui = data[0];
|
||||
r.Lat = data[1];
|
||||
r.Ts = data[2];
|
||||
r.Lui = data[3];
|
||||
r.Stt = data[4];
|
||||
r.Sui = data[5];
|
||||
r.IsPref = data[6];
|
||||
r.Rxaui = data[7];
|
||||
r.Saui = data[8];
|
||||
r.Scui = data[9];
|
||||
r.Sdui = data[10];
|
||||
r.Sab = data[11];
|
||||
r.Tty = data[12];
|
||||
r.Code = data[13];
|
||||
r.Str = data[14];
|
||||
r.Srl = data[15];
|
||||
r.Suppress = data[16];
|
||||
r.Cvf = data[17];
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using Strata.RxNorm.Biz.RxNorm;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Strata.RxNorm.Biz.Test.Unit.Extensions
|
||||
{
|
||||
[ExcludeFromCodeCoverage]
|
||||
public static class RxnRelationExtension
|
||||
{
|
||||
public static IEnumerable<RxnRelation> LoadRxnRelations(this string fileName)
|
||||
{
|
||||
var assembly = Assembly.GetExecutingAssembly();
|
||||
var lines = assembly.LoadRxnNorm(fileName);
|
||||
return lines.Select(l => l.RelationCtor()).Where(r => !string.IsNullOrEmpty(r.Rxcui1)).ToList();
|
||||
}
|
||||
|
||||
public static RxnRelation RelationCtor(this string line, string separator = "|")
|
||||
{
|
||||
var data = line.Split(separator).ToArray();
|
||||
var r = new RxnRelation();
|
||||
r.Rxcui1 = data[0];
|
||||
r.Rxaui1 = data[1];
|
||||
r.SType1 = data[2];
|
||||
r.Rel = data[3];
|
||||
r.Rxcui2 = data[4];
|
||||
r.Rxaui2 = data[5];
|
||||
r.SType2 = data[6];
|
||||
r.Rela = data[7];
|
||||
r.Rui = data[8];
|
||||
r.Srui = data[9];
|
||||
r.Sab = data[10];
|
||||
r.Sl = data[11];
|
||||
r.Rg = data[12];
|
||||
r.Dir = data[13];
|
||||
r.Suppress = data[14];
|
||||
r.Cvf = data[15];
|
||||
return r;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.RegularExpressions;
|
||||
using VerifyTests;
|
||||
|
||||
namespace Strata.RxNorm.Biz.Test.Unit.Extensions
|
||||
{
|
||||
[ExcludeFromCodeCoverage]
|
||||
public static class TestExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// The test name
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <returns>
|
||||
/// The name of the test split by camel case for a max length of 200 characters.
|
||||
/// </returns>
|
||||
public static string TestName(this TestContext context, string suffix = "")
|
||||
{
|
||||
var testName = context.Test.Name.Replace("\"", "_");
|
||||
testName = suffix == string.Empty
|
||||
? $"{testName}".SplitCamelCase()
|
||||
: $"{testName} - {suffix}".SplitCamelCase();
|
||||
testName = testName[..Math.Min(200, testName.Length)];
|
||||
return testName;
|
||||
}
|
||||
|
||||
public static string SplitCamelCase(this string input)
|
||||
{
|
||||
if (string.IsNullOrEmpty(input)) { return input; }
|
||||
|
||||
const string pattern = "([a-z](?=[A-Z])|[A-Z](?=[A-Z][a-r + t-z])|[A-Z](?=[A-Z][s][a-z]))";
|
||||
|
||||
if (input.StartsWith("FY", StringComparison.Ordinal))
|
||||
{ // hack for FY2012, etc
|
||||
return "FY " + Regex.Replace(input.Remove(0, 2), pattern, "$1 ");
|
||||
}
|
||||
input = Regex.Replace(input, @"\{|\}|:|,|\)|\(", "", RegexOptions.Singleline | RegexOptions.IgnoreCase);
|
||||
return Regex.Replace(input, pattern, "$1 ");
|
||||
}
|
||||
|
||||
public static VerifySettings TestSettings()
|
||||
{
|
||||
var settings = new VerifySettings();
|
||||
settings.UseDirectory("Snapshots");
|
||||
settings.ScrubInlineGuids();
|
||||
return settings;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user