Esempio n. 1
0
        public void Get_NonExisting_User()
        {
            var userMock = new Mock <IUserRepository>();

            userMock.Setup(m => m.GetById(It.IsAny <int>())).Returns(() => null);

            IGetUser target = new GetUser(userMock.Object);

            Exception ex = Assert.Throws <ArgumentNullException>(() => target.Invoke(1));

            Assert.True(ex.Message.Contains("Cannot find user with id=1"));
        }
Esempio n. 2
0
        public void Get_User()
        {
            var userMock = new Mock <IUserRepository>();

            userMock.Setup(m => m.GetById(It.IsAny <int>())).Returns(new User
            {
                Id    = 1,
                Login = "******"
            });
            IGetUser target = new GetUser(userMock.Object);

            var result = target.Invoke(1);

            Assert.NotNull(result);
            Assert.True(result.Id == 1);
            Assert.True(result.Login == "user1");
        }
Esempio n. 3
0
 public void UserPhone()
 {
     Firebase.FirebaseFirestore.Collection($"users").Document(CurrentUser.UId).Get().AddOnCompleteListener(
         new OnCompleteEventHandleListener((obj) =>
     {
         if (obj.IsSuccessful)
         {
             var snapshot = (DocumentSnapshot)(obj.Result);
             GetUser.Invoke(this, new UserEventArgs
             {
                 EventType = EventType.User,
                 User      = new User
                 {
                     UId      = snapshot.GetString("uid"),
                     Email    = snapshot.GetString("email"),
                     Fullname = snapshot.GetString("fullname"),
                     Phone    = snapshot.GetString("phone"),
                 }
             });
         }
     }));
 }