Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adsec-1714 fix for missing ACI codes #95

Merged
merged 5 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions AdSecGH/AdSecGH.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ Copyright © Oasys 1985 - 2024</Description>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>
<ItemGroup>
DominikaLos marked this conversation as resolved.
Show resolved Hide resolved
<InternalsVisibleTo Include="AdSecGHTests" />
</ItemGroup>
<PropertyGroup Condition="$(Configuration) == 'Debug' AND $([MSBuild]::IsOSPlatform(Windows))">
<StartProgram>C:\Program Files\Rhino 7\System\Rhino.exe</StartProgram>
<StartArguments></StartArguments>
Expand Down
30 changes: 20 additions & 10 deletions AdSecGH/Helpers/AdSecFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@
namespace AdSecGH.Helpers {
internal class AdSecFile {
internal static Dictionary<string, IDesignCode> Codes = new Dictionary<string, IDesignCode>() {
{ "ACI318M_02", ACI318.Edition_2002.US },
{ "ACI318M_05", ACI318.Edition_2005.US },
{ "ACI318M_08", ACI318.Edition_2008.US },
{ "ACI318M_11", ACI318.Edition_2011.US },
{ "ACI318M_14", ACI318.Edition_2014.US },
{ "ACI318M_02", ACI318.Edition_2002.Metric },
{ "ACI318M_05", ACI318.Edition_2005.Metric },
{ "ACI318M_08", ACI318.Edition_2008.Metric },
{ "ACI318M_11", ACI318.Edition_2011.Metric },
{ "ACI318M_14", ACI318.Edition_2014.Metric },
{ "ACI318_02", ACI318.Edition_2002.US },
{ "ACI318_05", ACI318.Edition_2005.US },
{ "ACI318_08", ACI318.Edition_2008.US },
{ "ACI318_11", ACI318.Edition_2011.US },
{ "ACI318_14", ACI318.Edition_2014.US },
{ "AASHTO_17", AASHTO.Edition_2017.US },
{ "AASHTO_17M", AASHTO.Edition_2017.Metric },
{ "AS3600_01", AS3600.Edition_2001 },
Expand Down Expand Up @@ -64,11 +69,16 @@ internal class AdSecFile {

internal static Dictionary<string, string> CodesStrings = new Dictionary<string, string>()
{
{ "ACI318M_02", "ACI318+Edition_2002+US" },
{ "ACI318M_05", "ACI318+Edition_2005+US" },
{ "ACI318M_08", "ACI318+Edition_2008+US" },
{ "ACI318M_11", "ACI318+Edition_2011+US" },
{ "ACI318M_14", "ACI318+Edition_2014+US" },
{ "ACI318M_02", "ACI318+Edition_2002+Metric" },
{ "ACI318M_05", "ACI318+Edition_2005+Metric" },
{ "ACI318M_08", "ACI318+Edition_2008+Metric" },
{ "ACI318M_11", "ACI318+Edition_2011+Metric" },
{ "ACI318M_14", "ACI318+Edition_2014+Metric" },
{ "ACI318_02", "ACI318+Edition_2002+US" },
{ "ACI318_05", "ACI318+Edition_2005+US" },
{ "ACI318_08", "ACI318+Edition_2008+US" },
{ "ACI318_11", "ACI318+Edition_2011+US" },
{ "ACI318_14", "ACI318+Edition_2014+US" },
{ "AASHTO_17", "AASHTO+Edition_2017+US" },
{ "AASHTO_17M", "AASHTO+Edition_2017+Metric" },
{ "AS3600_01", "AS3600+Edition_2001" },
Expand Down
1 change: 1 addition & 0 deletions AdSecGHTests/AdSecGHTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<Platforms>x64</Platforms>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AdSec" Version="2.0.0.21" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="7.0.3" />
<PackageReference Include="Rhino.Inside" Version="7.0.0" />
<PackageReference Include="xunit" Version="2.7.0" />
Expand Down
60 changes: 60 additions & 0 deletions AdSecGHTests/Helper/AdSecFileTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using AdSecGH;
using AdSecGH.Helpers;
using AdSecGH.Parameters;
using Xunit;

namespace AdSecGHTests.Helper {
[Collection("GrasshopperFixture collection")]
public class AdSecFileTest {
private string CreateSampleJson(string codeName, bool valid = true) {
return valid ?
"something before codes \n\n \"codes\": {\r\n \"concrete\": \"" + codeName
+ "\"\n },\n \n something after" : " \"codes\": {\"concrete\": \"" + codeName;
}

[Fact]
public void GetDesignCode_ForExistingCodesInAdSecFile_Test() {
//workaround for loading API dll
AddReferencePriority.AdSecAPI
= Assembly.LoadFile(Path.GetFullPath(Environment.CurrentDirectory + "//AdSec_API.dll"));

foreach (string key in AdSecFile.Codes.Keys) {
string json = CreateSampleJson(key);
AdSecDesignCode code = AdSecFile.GetDesignCode(json);

Assert.True(AdSecFile.Codes.ContainsValue(code.DesignCode));
Assert.True(AdSecFile.CodesStrings.ContainsValue(code.DesignCodeName.Replace(" ", "+")));
}
}

[Fact]
public void GetDesignCode_ForInvalidCode_Test() {
//workaround for loading API dll
AddReferencePriority.AdSecAPI
= Assembly.LoadFile(Path.GetFullPath(Environment.CurrentDirectory + "//AdSec_API.dll"));

string json = CreateSampleJson("I'm invalid design code!");

AdSecDesignCode code = AdSecFile.GetDesignCode(json);

Assert.Null(code);
}

[Fact]
public void GetDesignCode_ForInvalidJson_Test() {
//workaround for loading API dll
AddReferencePriority.AdSecAPI
= Assembly.LoadFile(Path.GetFullPath(Environment.CurrentDirectory + "//AdSec_API.dll"));

string json = CreateSampleJson(AdSecFile.Codes.Keys.FirstOrDefault(), false);

AdSecDesignCode code = AdSecFile.GetDesignCode(json);

Assert.Null(code);
}
}
}
Loading