Example #1
0
 public void IdentifySendsIdentifyEvent()
 {
     using (LdClient client = MakeClient(user))
     {
         User user1 = User.WithKey("userkey1");
         client.Identify(user1, TimeSpan.FromSeconds(1));
         Assert.Collection(eventProcessor.Events,
                           e => CheckIdentifyEvent(e, user), // there's always an initial identify event
                           e => CheckIdentifyEvent(e, user1));
     }
 }
Example #2
0
        public void IdentifyDoesNotSendAliasEventIfNewUserIsAnonymousOrOldUserIsNot(
            bool oldAnon, bool newAnon)
        {
            User oldUser = User.Builder("old-key").Anonymous(oldAnon).Build();
            User newUser = User.Builder("new-key").Anonymous(newAnon).Build();

            using (LdClient client = MakeClient(oldUser))
            {
                client.Identify(newUser, TimeSpan.FromSeconds(1));

                Assert.Collection(eventProcessor.Events,
                                  e => CheckIdentifyEvent(e, oldUser),
                                  e => CheckIdentifyEvent(e, newUser));
            }
        }
Example #3
0
        public void IdentifyDoesNotSendAliasEventIfOptedOUt()
        {
            User oldUser = User.Builder("anon-key").Anonymous(true).Build();
            User newUser = User.WithKey("real-key");

            var config = BasicConfig()
                         .Events(_factory)
                         .AutoAliasingOptOut(true)
                         .Build();

            using (LdClient client = TestUtil.CreateClient(config, oldUser))
            {
                User actualOldUser = client.User; // so we can get any automatic properties that the client added
                client.Identify(newUser, TimeSpan.FromSeconds(1));

                Assert.Collection(eventProcessor.Events,
                                  e => CheckIdentifyEvent(e, actualOldUser),
                                  e => CheckIdentifyEvent(e, newUser));
            }
        }
Example #4
0
        public void IdentifySendsAliasEventFromAnonUserToNonAnonUserIfNotOptedOut()
        {
            User oldUser = User.Builder("anon-key").Anonymous(true).Build();
            User newUser = User.WithKey("real-key");

            using (LdClient client = MakeClient(oldUser))
            {
                User actualOldUser = client.User; // so we can get any automatic properties that the client added
                client.Identify(newUser, TimeSpan.FromSeconds(1));

                Assert.Collection(eventProcessor.Events,
                                  e => CheckIdentifyEvent(e, actualOldUser),
                                  e => CheckIdentifyEvent(e, newUser),
                                  e => {
                    AliasEvent ae = Assert.IsType <AliasEvent>(e);
                    Assert.Equal(newUser, ae.User);
                    Assert.Equal(actualOldUser, ae.PreviousUser);
                    Assert.NotEqual(0, ae.Timestamp.Value);
                });
            }
        }