-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: event system and impression data events (#113)
* event system callback configuration on unleash-instance * improve eventconfig callback * add impressionData field to featuretoggle * add impressionevent logic and tests * improvement: document new events feature * add more tests * add some serialization testing for impressiondata
- Loading branch information
Showing
16 changed files
with
448 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace Unleash.Internal | ||
{ | ||
public class EventCallbackConfig | ||
{ | ||
public Action<ImpressionEvent> ImpressionEvent { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace Unleash.Internal | ||
{ | ||
public class ImpressionEvent | ||
{ | ||
public string Type { get; set; } | ||
public string EventId { get; set; } | ||
public UnleashContext Context { get; set; } | ||
public bool Enabled { get; set; } | ||
public string FeatureName { get; set; } | ||
public string Variant { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"version": 2, | ||
"features": [ | ||
{ | ||
"name": "Tests only", | ||
"description": "Where name has test in it", | ||
"enabled": true, | ||
"impressionData": true, | ||
"strategies": [ | ||
{ | ||
"name": "default", | ||
"parameters": {}, | ||
"segments": [ 1 ] | ||
} | ||
] | ||
} | ||
], | ||
"segments": [ | ||
{ | ||
"id": 1, | ||
"constraints": [ | ||
{ | ||
"contextName": "name", | ||
"operator": "STR_CONTAINS", | ||
"value": "test" | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using FluentAssertions; | ||
using NUnit.Framework; | ||
using System; | ||
|
||
namespace Unleash.Tests | ||
{ | ||
public class DefaultUnleashTests | ||
{ | ||
[Test] | ||
public void ConfigureEvents_should_invoke_callback() | ||
{ | ||
// Arrange | ||
var settings = new UnleashSettings | ||
{ | ||
AppName = "testapp", | ||
}; | ||
|
||
var unleash = new DefaultUnleash(settings); | ||
var callbackCalled = false; | ||
|
||
// Act | ||
unleash.ConfigureEvents(cfg => | ||
{ | ||
callbackCalled = true; | ||
}); | ||
|
||
// Assert | ||
callbackCalled.Should().BeTrue(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.