예제 #1
0
 private static void UpdateProfile()
 {
     var updateProfileHandler =
         new UpdateProfileHandler()
         .SetData("09013120129", "a123789", "موجو دین", "m123456");
     var response = updateProfileHandler.Process();
 }
예제 #2
0
        public async Task Given_A_Non_Existing_UserId__When_Calling_Update_Profile_Usecase__Throws_Profile_Not_Found_Exception()
        {
            // Arrange
            var request = new UpdateProfile(this.userId, "Bio", "Image", "DisplayName");
            var handler = new UpdateProfileHandler(this.unitOfWork);

            // Act + Assert
            Assert.That(async() => await handler.Handle(request, CancellationToken.None), Throws.InstanceOf <ProfileNotFoundException>());
        }
        public void Setup()
        {
            var dbContext = new DbContextOptionsBuilder <FollowContext>()
                            .UseInMemoryDatabase("KwetterFollowDatabase")
                            .Options;

            _context = new FollowContext(dbContext);

            _updateProfileHandler = new UpdateProfileHandler(_context);
        }
 public static Boolean UpdateProfileValidation(string email, string name, string gender, string oldEmail)
 {
     if (email == String.Empty || name == String.Empty || gender == String.Empty)
     {
         return(false);
     }
     else if (email == oldEmail)
     {
         return(true);
     }
     else if (UpdateProfileHandler.CheckIfEmailExistHandler(email) > 0)
     {
         return(false);
     }
     return(true);
 }
예제 #5
0
 public static Response DoUpdateProfile(String ID, String Nama, String Email, String Gender)
 {
     if (Nama == "")
     {
         return(new Response(false, "Name Cannot Empty"));
     }
     if (Email == "")
     {
         return(new Response(false, "Email Cannot Empty"));
     }
     if (Gender == "")
     {
         return(new Response(false, "Gender Cannot Empty"));
     }
     return(UpdateProfileHandler.DoUpdateProfile(ID, Nama, Email, Gender));
 }
예제 #6
0
        public async Task Given_An_Existing_Profile__When_Calling_UpdateProfile_Usecase__Returns_Updated_Profile()
        {
            // Arrange
            var profile = await this.CreateTestProfile();

            var request = new UpdateProfile(this.userId, "Bio", "Image", "DisplayName");
            var handler = new UpdateProfileHandler(this.unitOfWork);

            // Act
            var updatedProfile = await handler.Handle(request, CancellationToken.None);

            // Assert
            Assert.AreEqual(profile.Username, updatedProfile.Username);
            Assert.AreEqual(request.Bio, updatedProfile.Bio);
            Assert.AreEqual(request.ImageUrl, updatedProfile.ImageUrl);
            Assert.AreEqual(request.DisplayName, updatedProfile.DisplayName);
        }
        public static bool validateUpdate(int userID, string name, string email, string gender, out string errorMsg)
        {
            User usr = UpdateProfileHandler.SearchByEmail(email);

            errorMsg = "";
            if (usr != null)
            {
                errorMsg = "Email already exists!";
                return(false);
            }
            else if (email == "")
            {
                errorMsg = "Data must be filled!";
                return(false);
            }
            else if (!email.EndsWith(".com") || !email.EndsWith(".net"))
            {
                errorMsg = "Email must be end with .com or .net";
                return(false);
            }
            else if (!email.Contains("@"))
            {
                errorMsg = "Email must be contain '@' ";
                return(false);
            }
            else if (name == "")
            {
                errorMsg = "Data must be filled!";
                return(false);
            }
            else if (gender == "")
            {
                errorMsg = "Gender must be chosen";
                return(false);
            }
            else
            {
                UpdateProfileHandler.updateProfile(userID, name, email, gender);
                return(true);
            }
        }
예제 #8
0
 public static Response DoChangePassword(String ID, String OldPassword, String NewPassword, String ConfirmPassword)
 {
     if (OldPassword == "")
     {
         return(new Response(false, "Old Password Cannot Empty"));
     }
     if (NewPassword == "")
     {
         return(new Response(false, "New Password Cannot Empty"));
     }
     if (ConfirmPassword == "")
     {
         return(new Response(false, "Confirm Password Cannot Empty"));
     }
     if (ConfirmPassword != NewPassword)
     {
         return(new Response(false, "Confirm Password Must Be Same With New Password"));
     }
     if (OldPassword == NewPassword)
     {
         return(new Response(false, "New Password Cannot Be The Same With Old Password"));
     }
     return(UpdateProfileHandler.DoChangePassword(ID, OldPassword, NewPassword));
 }
 public static void UpdateUserDataController(string email, string name, string gender, int id)
 {
     UpdateProfileHandler.UpdateUserDataHandler(email, name, gender, id);
 }
예제 #10
0
 public void Setup()
 {
     Init();
     _updateProfileHandler = new UpdateProfileHandler(Context);
 }