Beispiel #1
0
 //public Dictionary<string, string> SocialLinks { get; set; }
 public object Clone()
 {
     User user = new User();
     user.Id = Id;
     user.FirstName = FirstName;
     user.LastName = LastName;
     user.Email = Email;
     return user;
 }
Beispiel #2
0
        public static SqlCommand Build_CreateUserCommand(User user)
        {
            SqlCommand command = new SqlCommand();

            Log("create user");

            command.CommandText = "insert into [dbo].[User] (Id, FirstName, LastName, Email) values (@Id, @FirstName, @LastName, @Email)";
            command.Parameters.AddWithValue("@id", user.Id);
            command.Parameters.AddWithValue("@firstname", user.FirstName);
            command.Parameters.AddWithValue("@lastname", user.LastName);
            command.Parameters.AddWithValue("@email", user.Email);

            Log("create user", command);

            return command;
        }
Beispiel #3
0
 public static void PrintUserInfo(User user)
 {
     Console.WriteLine("Id = " + user.Id);
     Console.WriteLine("FirstName = " + user.FirstName);
     Console.WriteLine("LastName = " + user.LastName);
     Console.WriteLine("Email = " + user.Email);
 }
Beispiel #4
0
        public static IUserRepository GetIUserRepositoryMock(User getUserResult)
        {
            var mock = new Mock<IUserRepository>();

            mock.Setup(userRepository => userRepository.GetUser(It.IsAny<Guid>())).Returns(getUserResult);
            mock.Setup(userRepository => userRepository.GetUser(It.IsAny<string>())).Returns(getUserResult);

            return mock.Object;
        }
Beispiel #5
0
        public static User GenerateUser()
        {
            User user = new User
            {
                Id = Guid.NewGuid(),
                Email = "test" + Index + "@test.com",
                FirstName = "name",
                LastName = "lastname"
            };

            return user;
        }
Beispiel #6
0
 public static Invitation CreateInvitation(Meeting meeting, User user)
 {
     return new Invitation
     {
         MeetingID = meeting.Id,
         UserID = user.Id
     };
 }
Beispiel #7
0
 public static bool CompareUsers(User first, User second)
 {
     return first.Id.Equals(second.Id) &
            first.Email.Equals(second.Email) &
            first.FirstName.Equals(second.FirstName) &
            first.LastName.Equals(second.LastName);
 }
        public void Update_ShouldUpdateUser()
        {
            //arrange
            var userRepository = new UserRepository(Properties.Resources.ConnectionString);
            var firstUser = TestDataHelper.GenerateUser();

            var secondUser = new User
            {
                Id = firstUser.Id,
                Email = "second" + (DateTime.Now.Millisecond * new Random().Next(10000)) + "@test.com",
                FirstName = "secondUserFirstName",
                LastName = "secondUserLastName"
            };

            //act
            userRepository.CreateUser(firstUser);
            userRepository.UpdateUser(secondUser);

            //asserts
            var resultUser = userRepository.GetUser(firstUser.Id);
            TestDataHelper.PrintUserInfo(firstUser);
            TestDataHelper.PrintUserInfo(secondUser);
            TestDataHelper.PrintUserInfo(resultUser);
            Assert.IsTrue(TestDataHelper.CompareUsers(resultUser, secondUser));
        }
Beispiel #9
0
        public static SqlCommand Build_UpdateUserCommand(User user)
        {
            SqlCommand command = new SqlCommand();

            Log("update user");

            command.CommandText = "update [dbo].[User] " +
                "SET FirstName = @FirstName, LastName = @LastName, Email = @Email " +
                "where id = @id";
            command.Parameters.AddWithValue("@id", user.Id);
            command.Parameters.AddWithValue("@firstname", user.FirstName);
            command.Parameters.AddWithValue("@lastname", user.LastName);
            command.Parameters.AddWithValue("@email", user.Email);

            Log("update user", command);

            return command;
        }
 public Task<HttpResponseMessage> Update(User user)
 {
     return _crudHandler.Update(_controller, user);
 }
Beispiel #11
0
 void SetStartData()
 {
     _user = new User
     {
         FirstName = "Vasilyi",
         LastName = "Pupkin",
         Email = "*****@*****.**"
     };
     _place = new Place
     {
         Address = "Puschkeen st., Kolotuschin h. #1",
         Description = "It is kolutushkin house."
     };
     _meeting = new Meeting
     {
         Title = "Party",
         Description = "party description",
         Owner = new User(),
         Date = new DateTime(2016, 1, 1),
         Place = new Place(),
         InvitedPeople = new Dictionary<Guid, User>()
     };
 }