Skip to content

Commit 5956947

Browse files
authored
Merge pull request #95 from arup-group/task/AdsecGH-1714
adsec-1714 fix for missing ACI codes
2 parents 6dfaadf + 45c4b05 commit 5956947

File tree

4 files changed

+84
-10
lines changed

4 files changed

+84
-10
lines changed

AdSecGH/AdSecGH.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ Copyright © Oasys 1985 - 2024</Description>
8181
<PackagePath>\</PackagePath>
8282
</None>
8383
</ItemGroup>
84+
<ItemGroup>
85+
<InternalsVisibleTo Include="AdSecGHTests" />
86+
</ItemGroup>
8487
<PropertyGroup Condition="$(Configuration) == 'Debug' AND $([MSBuild]::IsOSPlatform(Windows))">
8588
<StartProgram>C:\Program Files\Rhino 7\System\Rhino.exe</StartProgram>
8689
<StartArguments></StartArguments>

AdSecGH/Helpers/AdSecFile.cs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,16 @@
77
namespace AdSecGH.Helpers {
88
internal class AdSecFile {
99
internal static Dictionary<string, IDesignCode> Codes = new Dictionary<string, IDesignCode>() {
10-
{ "ACI318M_02", ACI318.Edition_2002.US },
11-
{ "ACI318M_05", ACI318.Edition_2005.US },
12-
{ "ACI318M_08", ACI318.Edition_2008.US },
13-
{ "ACI318M_11", ACI318.Edition_2011.US },
14-
{ "ACI318M_14", ACI318.Edition_2014.US },
10+
{ "ACI318M_02", ACI318.Edition_2002.Metric },
11+
{ "ACI318M_05", ACI318.Edition_2005.Metric },
12+
{ "ACI318M_08", ACI318.Edition_2008.Metric },
13+
{ "ACI318M_11", ACI318.Edition_2011.Metric },
14+
{ "ACI318M_14", ACI318.Edition_2014.Metric },
15+
{ "ACI318_02", ACI318.Edition_2002.US },
16+
{ "ACI318_05", ACI318.Edition_2005.US },
17+
{ "ACI318_08", ACI318.Edition_2008.US },
18+
{ "ACI318_11", ACI318.Edition_2011.US },
19+
{ "ACI318_14", ACI318.Edition_2014.US },
1520
{ "AASHTO_17", AASHTO.Edition_2017.US },
1621
{ "AASHTO_17M", AASHTO.Edition_2017.Metric },
1722
{ "AS3600_01", AS3600.Edition_2001 },
@@ -64,11 +69,16 @@ internal class AdSecFile {
6469

6570
internal static Dictionary<string, string> CodesStrings = new Dictionary<string, string>()
6671
{
67-
{ "ACI318M_02", "ACI318+Edition_2002+US" },
68-
{ "ACI318M_05", "ACI318+Edition_2005+US" },
69-
{ "ACI318M_08", "ACI318+Edition_2008+US" },
70-
{ "ACI318M_11", "ACI318+Edition_2011+US" },
71-
{ "ACI318M_14", "ACI318+Edition_2014+US" },
72+
{ "ACI318M_02", "ACI318+Edition_2002+Metric" },
73+
{ "ACI318M_05", "ACI318+Edition_2005+Metric" },
74+
{ "ACI318M_08", "ACI318+Edition_2008+Metric" },
75+
{ "ACI318M_11", "ACI318+Edition_2011+Metric" },
76+
{ "ACI318M_14", "ACI318+Edition_2014+Metric" },
77+
{ "ACI318_02", "ACI318+Edition_2002+US" },
78+
{ "ACI318_05", "ACI318+Edition_2005+US" },
79+
{ "ACI318_08", "ACI318+Edition_2008+US" },
80+
{ "ACI318_11", "ACI318+Edition_2011+US" },
81+
{ "ACI318_14", "ACI318+Edition_2014+US" },
7282
{ "AASHTO_17", "AASHTO+Edition_2017+US" },
7383
{ "AASHTO_17M", "AASHTO+Edition_2017+Metric" },
7484
{ "AS3600_01", "AS3600+Edition_2001" },

AdSecGHTests/AdSecGHTests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<Platforms>x64</Platforms>
66
</PropertyGroup>
77
<ItemGroup>
8+
<PackageReference Include="AdSec" Version="2.0.0.21" />
89
<PackageReference Include="Microsoft.Data.Sqlite" Version="7.0.3" />
910
<PackageReference Include="Rhino.Inside" Version="7.0.0" />
1011
<PackageReference Include="xunit" Version="2.7.0" />

AdSecGHTests/Helper/AdSecFileTest.cs

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
using System;
2+
using System.IO;
3+
using System.Linq;
4+
using System.Reflection;
5+
using AdSecGH;
6+
using AdSecGH.Helpers;
7+
using AdSecGH.Parameters;
8+
using Xunit;
9+
10+
namespace AdSecGHTests.Helper {
11+
[Collection("GrasshopperFixture collection")]
12+
public class AdSecFileTest {
13+
private string CreateSampleJson(string codeName, bool valid = true) {
14+
return valid ?
15+
"something before codes \n\n \"codes\": {\r\n \"concrete\": \"" + codeName
16+
+ "\"\n },\n \n something after" : " \"codes\": {\"concrete\": \"" + codeName;
17+
}
18+
19+
[Fact]
20+
public void GetDesignCode_ForExistingCodesInAdSecFile_Test() {
21+
//workaround for loading API dll
22+
AddReferencePriority.AdSecAPI
23+
= Assembly.LoadFile(Path.GetFullPath(Environment.CurrentDirectory + "//AdSec_API.dll"));
24+
25+
foreach (string key in AdSecFile.Codes.Keys) {
26+
string json = CreateSampleJson(key);
27+
AdSecDesignCode code = AdSecFile.GetDesignCode(json);
28+
29+
Assert.True(AdSecFile.Codes.ContainsValue(code.DesignCode));
30+
Assert.True(AdSecFile.CodesStrings.ContainsValue(code.DesignCodeName.Replace(" ", "+")));
31+
}
32+
}
33+
34+
[Fact]
35+
public void GetDesignCode_ForInvalidCode_Test() {
36+
//workaround for loading API dll
37+
AddReferencePriority.AdSecAPI
38+
= Assembly.LoadFile(Path.GetFullPath(Environment.CurrentDirectory + "//AdSec_API.dll"));
39+
40+
string json = CreateSampleJson("I'm invalid design code!");
41+
42+
AdSecDesignCode code = AdSecFile.GetDesignCode(json);
43+
44+
Assert.Null(code);
45+
}
46+
47+
[Fact]
48+
public void GetDesignCode_ForInvalidJson_Test() {
49+
//workaround for loading API dll
50+
AddReferencePriority.AdSecAPI
51+
= Assembly.LoadFile(Path.GetFullPath(Environment.CurrentDirectory + "//AdSec_API.dll"));
52+
53+
string json = CreateSampleJson(AdSecFile.Codes.Keys.FirstOrDefault(), false);
54+
55+
AdSecDesignCode code = AdSecFile.GetDesignCode(json);
56+
57+
Assert.Null(code);
58+
}
59+
}
60+
}

0 commit comments

Comments
 (0)