public void RegisterExistingUser()
        {
            //Prepare
            Mock <LoginStatusChangedEvent> loginStatusChangedEvent = new Mock <LoginStatusChangedEvent>();

            loginStatusChangedEvent.Setup(x => x.Publish(It.IsAny <IUserService>())).Verifiable();

            Mock <IEventAggregator> eventAggregator = new Mock <IEventAggregator>();

            eventAggregator.Setup(x => x.GetEvent <LoginStatusChangedEvent>()).Returns(loginStatusChangedEvent.Object);

            string user = "******";

            char[]       pass     = "******".ToCharArray();
            SecureString password = new SecureString();

            foreach (char c in pass)
            {
                password.AppendChar(c);
            }

            //Act
            IUserService    target = new BattlenetService(eventAggregator.Object);
            UserQueryResult result = target.Register(user, password);

            //Verify
            Assert.IsNull(target.CurrentUser);
            Assert.IsFalse(target.IsLoggedIn);
            Assert.IsFalse(result.Success);
            loginStatusChangedEvent.Verify(x => x.Publish(It.IsAny <IUserService>()), Times.Never);
        }
        public void RegisterAndLoginNewUser()
        {
            //Prepare
            Mock <LoginStatusChangedEvent> loginStatusChangedEvent = new Mock <LoginStatusChangedEvent>();

            loginStatusChangedEvent.Setup(x => x.Publish(It.IsAny <IUserService>())).Verifiable();

            Mock <IEventAggregator> eventAggregator = new Mock <IEventAggregator>();

            eventAggregator.Setup(x => x.GetEvent <LoginStatusChangedEvent>()).Returns(loginStatusChangedEvent.Object);

            string user = "******";

            char[]       pass     = "******".ToCharArray();
            SecureString password = new SecureString();

            foreach (char c in pass)
            {
                password.AppendChar(c);
            }

            //Act
            IUserService    target = new BattlenetService(eventAggregator.Object);
            UserQueryResult result = target.Register(user, password);

            target.Login(user, password);

            //Verify
            Assert.AreEqual(user, target.CurrentUser.Username);
            Assert.IsTrue(target.IsLoggedIn);
            Assert.AreEqual(OnlineStatuses.Online, target.OnlineStatus);
            Assert.IsTrue(result.Success);
            loginStatusChangedEvent.Verify(x => x.Publish(It.IsAny <IUserService>()), Times.Exactly(2));
        }