diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1808d43..d635173 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,12 +5,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
-## [Unreleased]
+## [0.1.1]
+
+- Handle null namespace property.
+
+## [0.1.0]
- Added a CHANGELOG.md based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Added standard rules for markdown files in .editorconfig
- Ensured that all files have a consistent line-ending (based on what they already have)
-- Added `IGrowthbook` interface
+- Added `IGrowthBook` interface
## [0.0.6] - 2022-06-07
diff --git a/GrowthBook/GrowthBook.csproj b/GrowthBook/GrowthBook.csproj
index fc7e28f..33307ad 100644
--- a/GrowthBook/GrowthBook.csproj
+++ b/GrowthBook/GrowthBook.csproj
@@ -1,4 +1,4 @@
-
+
netstandard2.0
@@ -11,7 +11,7 @@
https://github.com/growthbook/growthbook-csharp.git
git
GrowthBook,A/B test,feature toggle
- 0.0.7
+ 0.1.1
@@ -25,4 +25,4 @@
-
+
\ No newline at end of file
diff --git a/GrowthBook/IGrowthbook.cs b/GrowthBook/IGrowthBook.cs
similarity index 97%
rename from GrowthBook/IGrowthbook.cs
rename to GrowthBook/IGrowthBook.cs
index 37677c8..e934631 100644
--- a/GrowthBook/IGrowthbook.cs
+++ b/GrowthBook/IGrowthBook.cs
@@ -38,10 +38,10 @@ public interface IGrowthbook
IDictionary GetAllResults();
///
- /// Subscribes to a GrowthBook instance to be alerted every time growthbook.run is called.
+ /// Subscribes to a GrowthBook instance to be alerted every time GrowthBook.run is called.
/// This is different from the tracking callback since it also fires when a user is not included in an experiment.
///
- /// The callback to trigger when growthbook.run is called.
+ /// The callback to trigger when GrowthBook.run is called.
/// An action callback that can be used to unsubscribe.
Action Subscribe(Action callback);
diff --git a/GrowthBook/NamespaceTupleConverter.cs b/GrowthBook/NamespaceTupleConverter.cs
index e5e84e6..98cda60 100644
--- a/GrowthBook/NamespaceTupleConverter.cs
+++ b/GrowthBook/NamespaceTupleConverter.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
@@ -22,7 +22,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
{
return new Namespace((JArray)token);
}
- return new JsonSerializer().Deserialize(reader, objectType);
+ return null;
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
diff --git a/Test/GrowthBook.Tests.csproj b/Test/GrowthBook.Tests.csproj
index 8e15197..ea910a8 100644
--- a/Test/GrowthBook.Tests.csproj
+++ b/Test/GrowthBook.Tests.csproj
@@ -1,80 +1,41 @@
-
-
-
-
+
+
- Debug
- AnyCPU
- {649FDBB7-2442-4DF5-B493-401D2ECF527D}
- Library
- Properties
- Test
- Test
- v4.7.2
- 512
- {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- 15.0
- $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
- $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages
- False
- UnitTest
-
-
-
-
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
+ net6
+ latest
+
+
+
+
+
+
+
+
+
+
-
- ..\packages\MSTest.TestFramework.2.1.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll
-
-
- ..\packages\MSTest.TestFramework.2.1.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll
-
-
- ..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll
-
-
-
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
-
-
-
+
+
-
- {eb2e6969-d39e-4093-b267-826226de50dc}
- GrowthBook
-
+
-
-
-
-
- This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
-
-
-
-
-
-
\ No newline at end of file
+
+
diff --git a/Test/GrowthBookTests.cs b/Test/GrowthBookTests.cs
index 2d735d7..ceac6ff 100644
--- a/Test/GrowthBookTests.cs
+++ b/Test/GrowthBookTests.cs
@@ -1,10 +1,12 @@
-using System;
+using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using GrowthBook;
+using Growthbook.Tests.Json;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json.Linq;
+using Test;
namespace Growthbook.Tests
{
@@ -22,8 +24,8 @@ public static void TestFixtureSetup(TestContext context)
throw new ArgumentNullException(nameof(context));
}
- testCases = JObject.Parse(File.ReadAllText("../../standard-cases.json"));
- customCases = JObject.Parse(File.ReadAllText("../../custom-cases.json"));
+ testCases = JObject.Parse(JsonTestHelpers.GetTestJson("standard-cases"));
+ customCases = JObject.Parse(JsonTestHelpers.GetTestJson("custom-cases"));
}
public static string GetTestNames(MethodInfo methodInfo, object[] values)
diff --git a/Test/Json/FeatureDictionary.json b/Test/Json/FeatureDictionary.json
new file mode 100644
index 0000000..8d74382
--- /dev/null
+++ b/Test/Json/FeatureDictionary.json
@@ -0,0 +1,39 @@
+{
+ "backend_test1": {
+ "DefaultValue": [],
+ "Rules": []
+ },
+ "backend_test2": {
+ "DefaultValue": [],
+ "Rules": []
+ },
+ "backend_test3": {
+ "DefaultValue": [],
+ "Rules": [
+ {
+ "Condition": {
+ "tenantName": []
+ },
+ "Coverage": 1,
+ "Force": [],
+ "Variations": null,
+ "Key": null,
+ "Weights": null,
+ "Namespace": null,
+ "HashAttribute": "id"
+ },
+ {
+ "Condition": {
+ "tenantName": []
+ },
+ "Coverage": 1,
+ "Force": [],
+ "Variations": null,
+ "Key": null,
+ "Weights": null,
+ "Namespace": null,
+ "HashAttribute": "id"
+ }
+ ]
+ }
+}
diff --git a/Test/Json/GrowthBookContext.NoFeatures.json b/Test/Json/GrowthBookContext.NoFeatures.json
new file mode 100644
index 0000000..848830b
--- /dev/null
+++ b/Test/Json/GrowthBookContext.NoFeatures.json
@@ -0,0 +1,11 @@
+{
+ "EnvironmentName": "Dev",
+ "Enabled": true,
+ "Attributes": {},
+ "Url": null,
+ "Features": {
+ },
+ "ForcedVariations": {},
+ "QaMode": false,
+ "TrackingCallback": null
+}
\ No newline at end of file
diff --git a/Test/Json/GrowthBookContext.json b/Test/Json/GrowthBookContext.json
new file mode 100644
index 0000000..0469023
--- /dev/null
+++ b/Test/Json/GrowthBookContext.json
@@ -0,0 +1,48 @@
+{
+ "EnvironmentName": "Dev",
+ "Enabled": true,
+ "Attributes": {},
+ "Url": null,
+ "Features": {
+ "backend_test1": {
+ "DefaultValue": [],
+ "Rules": []
+ },
+ "backend_test2": {
+ "DefaultValue": [],
+ "Rules": []
+ },
+ "backend_test3": {
+ "DefaultValue": [],
+ "Rules": [
+ {
+ "Condition": {
+ "tenantName": []
+ },
+ "Coverage": 1,
+ "Force": [],
+ "Variations": null,
+ "Key": null,
+ "Weights": null,
+ "Namespace": null,
+ "HashAttribute": "id"
+ },
+ {
+ "Condition": {
+ "tenantName": []
+ },
+ "Coverage": 1,
+ "Force": [],
+ "Variations": null,
+ "Key": null,
+ "Weights": null,
+ "Namespace": null,
+ "HashAttribute": "id"
+ }
+ ]
+ }
+ },
+ "ForcedVariations": {},
+ "QaMode": false,
+ "TrackingCallback": null
+}
diff --git a/Test/Json/JsonTestHelpers.cs b/Test/Json/JsonTestHelpers.cs
new file mode 100644
index 0000000..769e086
--- /dev/null
+++ b/Test/Json/JsonTestHelpers.cs
@@ -0,0 +1,33 @@
+using System;
+using System.IO;
+using System.Reflection;
+
+namespace Growthbook.Tests.Json;
+
+public static class JsonTestHelpers
+{
+ public static string GetTestJson(string jsonName)
+ {
+ return GetTestJson(
+ Assembly.GetExecutingAssembly(),
+ $"{typeof(JsonTestHelpers).Namespace}/{jsonName}.json");
+ }
+
+ ///
+ /// Returns the contents of the embedded resource as a string.
+ ///
+ public static string GetTestJson(Assembly assembly, string resourceName)
+ {
+ using Stream stream = assembly.GetManifestResourceStream(resourceName.Replace('/', '.'));
+
+ if (stream == null)
+ {
+ throw new InvalidOperationException($"The resource {resourceName} is not available - make sure that it has Build Action set to Embedded Resource");
+ }
+
+ using StreamReader reader = new StreamReader(stream);
+
+ var json = reader.ReadToEnd();
+ return json;
+ }
+}
diff --git a/Test/Json/SingleFeatureDictionary.WithNameSpace..json b/Test/Json/SingleFeatureDictionary.WithNameSpace..json
new file mode 100644
index 0000000..abcfbef
--- /dev/null
+++ b/Test/Json/SingleFeatureDictionary.WithNameSpace..json
@@ -0,0 +1,19 @@
+{
+ "backend_test3": {
+ "DefaultValue": [],
+ "Rules": [
+ {
+ "Condition": {
+ "tenantName": []
+ },
+ "Coverage": 1,
+ "Force": [],
+ "Variations": null,
+ "Key": null,
+ "Weights": null,
+ "Namespace": null,
+ "HashAttribute": "id"
+ }
+ ]
+ }
+}
diff --git a/Test/custom-cases.json b/Test/Json/custom-cases.json
similarity index 100%
rename from Test/custom-cases.json
rename to Test/Json/custom-cases.json
diff --git a/Test/standard-cases.json b/Test/Json/standard-cases.json
similarity index 100%
rename from Test/standard-cases.json
rename to Test/Json/standard-cases.json
diff --git a/Test/NamespaceTupleConverterTests.cs b/Test/NamespaceTupleConverterTests.cs
new file mode 100644
index 0000000..51a0713
--- /dev/null
+++ b/Test/NamespaceTupleConverterTests.cs
@@ -0,0 +1,45 @@
+using System.Collections.Generic;
+using GrowthBook;
+using Growthbook.Tests.Json;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Newtonsoft.Json;
+
+namespace Test
+{
+ [TestClass]
+ public class NamespaceTupleConverterTests
+ {
+ [TestMethod]
+ public void CreateFromJson_NoFeatures_ShouldSucceed()
+ {
+ string json = JsonTestHelpers.GetTestJson("GrowthBookContext.NoFeatures");
+
+ var gb = JsonConvert.DeserializeObject(json);
+ }
+
+ [TestMethod]
+ public void CreateFromJson_WithFeatures_ShouldSucceed()
+ {
+ string json = JsonTestHelpers.GetTestJson("GrowthBookContext");
+
+ var gb = JsonConvert.DeserializeObject(json);
+ }
+
+ [TestMethod]
+ public void CreateFeaturesFromJson_WithFeatures_ShouldSucceed()
+ {
+ string json = JsonTestHelpers.GetTestJson("FeatureDictionary");
+
+ var gb = JsonConvert.DeserializeObject>(json);
+ }
+
+ [TestMethod]
+ public void CreateFeaturesFromJson_OneFeatureWithNameSpace_ShouldSucceed()
+ {
+ string json = JsonTestHelpers.GetTestJson("SingleFeatureDictionary.WithNameSpace.");
+
+ var gb = JsonConvert.DeserializeObject>(json);
+ }
+
+ }
+}
diff --git a/Test/Properties/AssemblyInfo.cs b/Test/Properties/AssemblyInfo.cs
deleted file mode 100644
index b5b22e2..0000000
--- a/Test/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System.Reflection;
-using System.Runtime.InteropServices;
-
-[assembly: AssemblyTitle("Test")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("Test")]
-[assembly: AssemblyCopyright("Copyright © 2022")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-[assembly: ComVisible(false)]
-
-[assembly: Guid("649fdbb7-2442-4df5-b493-401d2ecf527d")]
-
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Test/Utilities.cs b/Test/Utilities.cs
index c97c3e7..7d8b508 100644
--- a/Test/Utilities.cs
+++ b/Test/Utilities.cs
@@ -1,11 +1,13 @@
-using System;
+using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using GrowthBook;
+using Growthbook.Tests.Json;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json.Linq;
+using Test;
namespace Growthbook.Tests
{
@@ -22,7 +24,7 @@ public static void TestFixtureSetup(TestContext context)
throw new ArgumentNullException(nameof(context));
}
- testCases = JObject.Parse(File.ReadAllText("../../standard-cases.json"));
+ testCases = JObject.Parse(JsonTestHelpers.GetTestJson("standard-cases"));
}
public static string GetTestNames(MethodInfo methodInfo, object[] values)