ISNCSCI 分类计算机算法入门,用于 C# .Net 的 NuGet 程序库

本指南解释如何在 Visual Studio 开发的 C# .NET 应用程序中调用 ISNCSCI 计算机算法。您可以在 此处 下载本指南使用的源代码。

先决条件:

指南:

  1. Visual Studio 中创建一个新的项目。
    Figure 1
  2. 项目类型选择 Class Library
    Figure 2
  3. 在 Solution Explorer 面板上,右键点击 References 并选择 Add Reference…
    Figure 3
  4. Assemblies 选项下,寻找程序库 Microsoft.VisualStudio.QualityTools.UnitTestFramework ,并将其添加至程序。
    Figure 4
  5. 再次右键点击 References,选择 Manage NuGet Packages…
    Figure 5
  6. nugget.org 选项下,寻找 RHI ISNCSCI Algorithm。点击 Install 按钮将其添加至程序。
    Figure 6
  7. 请务必阅读许可协议,点击 I Accept 将组件添加到您的程序。
    Figure 7
  8. 目前我们已经创建了一个程序库,并且已经导入 Microsoft Unit Test FrameworkRHI ISNCSCI Algorithm 程序库,以便生成测试等级用于调用计算机算法。将 AlgorithmTests 等级添加至程序。
    Figure 8
  9. unit testing libraryRHI ISNCSCI Algorithm library 为基准。然后添加测试方式 GetTotalsForNeurologyForm。您的等级应该显示为下列图像之一:
    Figure 9
  10. 添加下方的代码至测试方式。测试中使用的原始值与 开源软件包 中所包含的 ISNCSCI NT Case 2 相符
    Figure 10
    
        // Arrange
        var neurologyForm = new NeurologyForm()
        {
            AnalContraction = BinaryObservation.No,
            AnalSensation = BinaryObservation.Yes
        };
    
        neurologyForm.UpdateLevelAt("C2", "2", "2", "2", "2", "0", "0");
        neurologyForm.UpdateLevelAt("C3", "2", "2", "2", "2", "0", "0");
        neurologyForm.UpdateLevelAt("C4", "2", "2", "2", "2", "0", "0");
        neurologyForm.UpdateLevelAt("C5", "2", "2", "2", "2", "5", "5");
        neurologyForm.UpdateLevelAt("C6", "1", "1", "1", "0", "1", "1");
        neurologyForm.UpdateLevelAt("C7", "1", "0", "1", "0", "0", "0");
        neurologyForm.UpdateLevelAt("C8", "1", "0", "1", "0", "0", "0");
        neurologyForm.UpdateLevelAt("T1", "1", "0", "1", "0", "0", "0");
        neurologyForm.UpdateLevelAt("T2", "NT", "NT", "NT", "NT", "0", "0");
        neurologyForm.UpdateLevelAt("T3", "NT", "NT", "NT", "NT", "0", "0");
        neurologyForm.UpdateLevelAt("T4", "NT", "NT", "NT", "NT", "0", "0");
        neurologyForm.UpdateLevelAt("T5", "NT", "NT", "NT", "NT", "0", "0");
        neurologyForm.UpdateLevelAt("T6", "NT", "NT", "NT", "NT", "0", "0");
        neurologyForm.UpdateLevelAt("T7", "NT", "NT", "NT", "NT", "0", "0");
        neurologyForm.UpdateLevelAt("T8", "NT", "NT", "NT", "NT", "0", "0");
        neurologyForm.UpdateLevelAt("T9", "NT", "NT", "NT", "NT", "0", "0");
        neurologyForm.UpdateLevelAt("T10", "NT", "NT", "NT", "NT", "0", "0");
        neurologyForm.UpdateLevelAt("T11", "NT", "NT", "NT", "NT", "0", "0");
        neurologyForm.UpdateLevelAt("T12", "NT", "NT", "NT", "NT", "0", "0");
        neurologyForm.UpdateLevelAt("L1", "NT", "NT", "NT", "NT", "0", "0");
        neurologyForm.UpdateLevelAt("L2", "NT", "NT", "NT", "NT", "NT", "NT");
        neurologyForm.UpdateLevelAt("L3", "NT", "NT", "NT", "NT", "NT", "NT");
        neurologyForm.UpdateLevelAt("L4", "NT", "NT", "NT", "NT", "NT", "NT");
        neurologyForm.UpdateLevelAt("L5", "NT", "NT", "NT", "NT", "NT", "NT");
        neurologyForm.UpdateLevelAt("S1", "NT", "NT", "NT", "NT", "NT", "NT");
        neurologyForm.UpdateLevelAt("S2", "NT", "NT", "NT", "NT", "0", "0");
        neurologyForm.UpdateLevelAt("S3", "NT", "NT", "NT", "NT", "0", "0");
        neurologyForm.UpdateLevelAt("S4_5", "NT", "NT", "NT", "NT", "0", "0");
    
        // Act
        var summary = Algorithm.GetTotalsSummaryFor(neurologyForm);
    
        // Assert
        Assert.AreEqual("B,C,D", summary.AsiaImpairmentScale);
        Assert.AreEqual("I", summary.Completeness);
        Assert.AreEqual("UTD", summary.LeftLowerMotorTotal);
        Assert.AreEqual("C5", summary.LeftMotor);
        Assert.AreEqual("UTD", summary.LeftMotorTotal);
        Assert.AreEqual("NA", summary.LeftMotorZpp);
        Assert.AreEqual("UTD", summary.LeftPrickTotal);
        Assert.AreEqual("C5", summary.LeftSensory);
        Assert.AreEqual("NA", summary.LeftSensoryZpp);
        Assert.AreEqual("UTD", summary.LeftTouchTotal);
        Assert.AreEqual("6", summary.LeftUpperMotorTotal);
        Assert.AreEqual("UTD", summary.LowerMotorTotal);
        Assert.AreEqual("C5", summary.NeurologicalLevelOfInjury);
        Assert.AreEqual("UTD", summary.PrickTotal);
        Assert.AreEqual("UTD", summary.RightLowerMotorTotal);
        Assert.AreEqual("C5", summary.RightMotor);
        Assert.AreEqual("UTD", summary.RightMotorTotal);
        Assert.AreEqual("NA", summary.RightMotorZpp);
        Assert.AreEqual("UTD", summary.RightPrickTotal);
        Assert.AreEqual("C5", summary.RightSensory);
        Assert.AreEqual("NA", summary.RightSensoryZpp);
        Assert.AreEqual("UTD", summary.RightTouchTotal);
        Assert.AreEqual("6", summary.RightUpperMotorTotal);
        Assert.AreEqual("UTD", summary.TouchTotal);
        Assert.AreEqual("12", summary.UpperMotorTotal);
                    
  11. 右键点击 GetTotalsFormNeurologyForm 方式顶端的 TestMethod 装饰器,并选择 Run Tests 以试用我们的编码。
    Figure 11