Skip to content

Commit 674c7c9

Browse files
notification center property in optimizely class changed into public access modifier. (#40)
1 parent 97ac579 commit 674c7c9

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

OptimizelySDK.Tests/OptimizelyTest.cs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,13 +1547,15 @@ public void TestActivateListener(UserAttributes userAttributes)
15471547
DecisionServiceMock.Setup(ds => ds.GetVariation(experiment, TestUserId, userAttributes)).Returns(variation);
15481548
DecisionServiceMock.Setup(ds => ds.GetVariationForFeature(featureFlag, TestUserId, userAttributes)).Returns(variation);
15491549

1550+
var optly = Helper.CreatePrivateOptimizely();
1551+
var optStronglyTyped = optly.GetObject() as Optimizely;
1552+
1553+
15501554
// Adding notification listeners.
15511555
var notificationType = NotificationCenter.NotificationType.Activate;
1552-
NotificationCenter.AddNotification(notificationType, NotificationCallbackMock.Object.TestActivateCallback);
1553-
NotificationCenter.AddNotification(notificationType, NotificationCallbackMock.Object.TestAnotherActivateCallback);
1554-
1555-
var optly = Helper.CreatePrivateOptimizely();
1556-
optly.SetFieldOrProperty("NotificationCenter", NotificationCenter);
1556+
optStronglyTyped. NotificationCenter.AddNotification(notificationType, NotificationCallbackMock.Object.TestActivateCallback);
1557+
optStronglyTyped.NotificationCenter.AddNotification(notificationType, NotificationCallbackMock.Object.TestAnotherActivateCallback);
1558+
15571559
optly.SetFieldOrProperty("DecisionService", DecisionServiceMock.Object);
15581560
optly.SetFieldOrProperty("EventBuilder", EventBuilderMock.Object);
15591561

@@ -1613,6 +1615,9 @@ public void TestTrackListener(UserAttributes userAttributes, EventTags eventTags
16131615
var logEvent = new LogEvent("https://logx.optimizely.com/v1/events", OptimizelyHelper.SingleParameter,
16141616
"POST", new Dictionary<string, string> { });
16151617

1618+
var optly = Helper.CreatePrivateOptimizely();
1619+
var optStronglyTyped = optly.GetObject() as Optimizely;
1620+
16161621
// Mocking objects.
16171622
NotificationCallbackMock.Setup(nc => nc.TestTrackCallback(It.IsAny<string>(), It.IsAny<string>(),
16181623
It.IsAny<UserAttributes>(), It.IsAny<EventTags>(), It.IsAny<LogEvent>()));
@@ -1625,11 +1630,9 @@ public void TestTrackListener(UserAttributes userAttributes, EventTags eventTags
16251630

16261631
// Adding notification listeners.
16271632
var notificationType = NotificationCenter.NotificationType.Track;
1628-
NotificationCenter.AddNotification(notificationType, NotificationCallbackMock.Object.TestTrackCallback);
1629-
NotificationCenter.AddNotification(notificationType, NotificationCallbackMock.Object.TestAnotherTrackCallback);
1633+
optStronglyTyped.NotificationCenter.AddNotification(notificationType, NotificationCallbackMock.Object.TestTrackCallback);
1634+
optStronglyTyped.NotificationCenter.AddNotification(notificationType, NotificationCallbackMock.Object.TestAnotherTrackCallback);
16301635

1631-
var optly = Helper.CreatePrivateOptimizely();
1632-
optly.SetFieldOrProperty("NotificationCenter", NotificationCenter);
16331636
optly.SetFieldOrProperty("DecisionService", DecisionServiceMock.Object);
16341637
optly.SetFieldOrProperty("EventBuilder", EventBuilderMock.Object);
16351638

OptimizelySDK.Tests/UtilsTests/PrivateObject.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,10 @@ public object Invoke(string name, params object[] args)
3030
return instanceType.InvokeMember(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.NonPublic,
3131
Type.DefaultBinder, createdInstance, args);
3232
}
33+
34+
public object GetObject()
35+
{
36+
return createdInstance;
37+
}
3338
}
3439
}

OptimizelySDK/Optimizely.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class Optimizely
4545

4646
private DecisionService DecisionService;
4747

48-
private NotificationCenter NotificationCenter;
48+
public NotificationCenter NotificationCenter;
4949

5050
public bool IsValid { get; private set; }
5151

0 commit comments

Comments
 (0)