public void SetAttributeToOverrideAttribute() { OptimizelyUserContext user = new OptimizelyUserContext(Optimizely, UserID, null, ErrorHandlerMock.Object, LoggerMock.Object); Assert.AreEqual(user.GetOptimizely(), Optimizely); Assert.AreEqual(user.GetUserId(), UserID); user.SetAttribute("k1", "v1"); Assert.AreEqual(user.GetAttributes()["k1"], "v1"); user.SetAttribute("k1", true); Assert.AreEqual(user.GetAttributes()["k1"], true); }
public void SetAttributeOverride() { var attributes = new UserAttributes() { { "house", "GRYFFINDOR" } }; OptimizelyUserContext user = new OptimizelyUserContext(Optimizely, UserID, attributes, ErrorHandlerMock.Object, LoggerMock.Object); user.SetAttribute("k1", "v1"); user.SetAttribute("house", "v2"); var newAttributes = user.GetAttributes(); Assert.AreEqual(newAttributes["k1"], "v1"); Assert.AreEqual(newAttributes["house"], "v2"); }
public void SetAttributeNullValue() { var attributes = new UserAttributes() { { "k1", null } }; OptimizelyUserContext user = new OptimizelyUserContext(Optimizely, UserID, attributes, ErrorHandlerMock.Object, LoggerMock.Object); var newAttributes = user.GetAttributes(); Assert.AreEqual(newAttributes["k1"], null); user.SetAttribute("k1", true); newAttributes = user.GetAttributes(); Assert.AreEqual(newAttributes["k1"], true); user.SetAttribute("k1", null); newAttributes = user.GetAttributes(); Assert.AreEqual(newAttributes["k1"], null); }
public void SetAttribute() { var attributes = new UserAttributes() { { "house", "GRYFFINDOR" } }; OptimizelyUserContext user = new OptimizelyUserContext(Optimizely, UserID, attributes, ErrorHandlerMock.Object, LoggerMock.Object); user.SetAttribute("k1", "v1"); user.SetAttribute("k2", true); user.SetAttribute("k3", 100); user.SetAttribute("k4", 3.5); Assert.AreEqual(user.GetOptimizely(), Optimizely); Assert.AreEqual(user.GetUserId(), UserID); var newAttributes = user.GetAttributes(); Assert.AreEqual(newAttributes["house"], "GRYFFINDOR"); Assert.AreEqual(newAttributes["k1"], "v1"); Assert.AreEqual(newAttributes["k2"], true); Assert.AreEqual(newAttributes["k3"], 100); Assert.AreEqual(newAttributes["k4"], 3.5); }