当前位置: 首页>>代码示例>>C#>>正文


C# UserRepository.CreateUser方法代码示例

本文整理汇总了C#中UserRepository.CreateUser方法的典型用法代码示例。如果您正苦于以下问题:C# UserRepository.CreateUser方法的具体用法?C# UserRepository.CreateUser怎么用?C# UserRepository.CreateUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserRepository的用法示例。


在下文中一共展示了UserRepository.CreateUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Delete_ShouldDelete

        public void Delete_ShouldDelete()
        {
            //arange
            PlaceRepository placeRep = new PlaceRepository(Properties.Resources.ConnectionString);
            MeetingRepository meetRep = new MeetingRepository(Properties.Resources.ConnectionString);
            UserRepository userRep = new UserRepository(Properties.Resources.ConnectionString);
            InvitationRepository inviteRep = new InvitationRepository(Properties.Resources.ConnectionString);
            Meeting meeting = TestDataHelper.GenerateMeeting();

            //act
            userRep.CreateUser(meeting.Owner);
            placeRep.CreatePlace(meeting.Place);
            meetRep.CreateMeeting(meeting);
            foreach (User user in meeting.InvitedPeople.Values)
            {
                userRep.CreateUser(user);
                inviteRep.Create(CreateInvitation(meeting, user));
            }

            Meeting resultMeeting = meetRep.GetMeeting(meeting.Id);
            if (resultMeeting != null) TestDataHelper.PrintMeetingInfo(resultMeeting);
            else Console.WriteLine("Meeting not exist");

            meetRep.DeleteMeeting(resultMeeting);
            resultMeeting = meetRep.GetMeeting(meeting.Id);

            //assert
            if (resultMeeting != null) TestDataHelper.PrintMeetingInfo(resultMeeting);
            else Console.WriteLine("Meeting deleted");
            Assert.IsNull(resultMeeting);
        }
开发者ID:Bot32,项目名称:MeetGenerator,代码行数:31,代码来源:MeetingRepositoryTest.cs

示例2: CreateInvitation_ShouldCreate

        public void CreateInvitation_ShouldCreate()
        {
            //arange
            PlaceRepository placeRep = new PlaceRepository(Properties.Resources.ConnectionString);
            MeetingRepository meetRep = new MeetingRepository(Properties.Resources.ConnectionString);
            UserRepository userRep = new UserRepository(Properties.Resources.ConnectionString);
            InvitationRepository inviteRep = new InvitationRepository(Properties.Resources.ConnectionString);
            Meeting meeting = TestDataHelper.GenerateMeeting();

            //act
            userRep.CreateUser(meeting.Owner);
            placeRep.CreatePlace(meeting.Place);
            meetRep.CreateMeeting(meeting);

            foreach (User user in meeting.InvitedPeople.Values)
            {
                userRep.CreateUser(user);
                inviteRep.Create(CreateInvitation(meeting, user));
            }

            Meeting resultMeeting = meetRep.GetMeeting(meeting.Id);

            //assert
            TestDataHelper.PrintMeetingInfo(meeting);
            TestDataHelper.PrintMeetingInfo(resultMeeting);
            Assert.IsTrue(TestDataHelper.CompareInvitedUsersLists
                (meeting.InvitedPeople.Values, resultMeeting.InvitedPeople.Values));
        }
开发者ID:Bot32,项目名称:MeetGenerator,代码行数:28,代码来源:InvitationRepositoryTest.cs

示例3: ShouldReturnUserById

        public void ShouldReturnUserById()
        {
            const string accountName = "super_user";
            var repo = new UserRepository();
            repo.CreateUser("user_name1", "password", "name1", "address", "phone");
            repo.CreateUser(accountName, "password", "name2", "address", "phone");

            var bankUser = repo.GetUserById(1);

            Assert.AreEqual(accountName,bankUser.AccountName);
        }
开发者ID:VLysiuk,项目名称:FitnesseDemo,代码行数:11,代码来源:UserRepositoryTest.cs

示例4: IndexPost

 public ActionResult IndexPost(string username)
 {
     var userRepository = new UserRepository();
     var userID = userRepository.CreateUser(username);
     Session.Add("UserID", userID);
     return RedirectToAction("Trivia", "Trivia");
 }
开发者ID:narph,项目名称:seinfeld-trivia,代码行数:7,代码来源:HomeController.cs

示例5: Delete_ShouldDeleteUser

        public void Delete_ShouldDeleteUser()
        {
            //arrange
            var userRepository = new UserRepository(Properties.Resources.ConnectionString);
            User user = TestDataHelper.GenerateUser();

            //act
            userRepository.CreateUser(user);
            User userBeforeDelete = userRepository.GetUser(user.Id);
            if (userBeforeDelete == null)
            {
                Console.WriteLine("User not exist!");
            }
            else
            {
                Console.WriteLine("User exist.");
            }
            userRepository.DeleteUser(user.Id);

            //assert
            User userAfterDelete = userRepository.GetUser(user.Id);

            if (userAfterDelete == null)
            {
                Console.WriteLine("User deleted.");
            }
            else
            {
                Console.WriteLine("User not deleted!");
            }

            Assert.IsTrue(!(userBeforeDelete == null) & (userAfterDelete == null));
        }
开发者ID:Bot32,项目名称:MeetGenerator,代码行数:33,代码来源:UserRepositoryTest.cs

示例6: ShouldReturnNullWhenUserDoesntExists

        public void ShouldReturnNullWhenUserDoesntExists()
        {
            var repo = new UserRepository();
            repo.CreateUser("some_name", "password", "name", "address", "phone");

            var user = repo.GetUserByName("other_name");

            Assert.IsNull(user);
        }
开发者ID:VLysiuk,项目名称:FitnesseDemo,代码行数:9,代码来源:UserRepositoryTest.cs

示例7: ShouldCreateNewUserAndReturnHisId

        public void ShouldCreateNewUserAndReturnHisId()
        {
            var repo = new UserRepository();
            int userId = repo.CreateUser("user_name", "password", "name", "address", "phone");
            var user = repo.GetUserById(userId);

            Assert.IsNotNull(user);
            Assert.AreEqual("user_name",user.AccountName);
        }
开发者ID:VLysiuk,项目名称:FitnesseDemo,代码行数:9,代码来源:UserRepositoryTest.cs

示例8: ShouldReturnUserByAccountName

        public void ShouldReturnUserByAccountName()
        {
            const string accountName = "user_name";
            var repo = new UserRepository();
            repo.CreateUser(accountName, "password", "name", "address", "phone");

            var user = repo.GetUserByName(accountName);

            Assert.IsNotNull(user);
            Assert.AreEqual(accountName,user.AccountName);
        }
开发者ID:VLysiuk,项目名称:FitnesseDemo,代码行数:11,代码来源:UserRepositoryTest.cs

示例9: Get_ByEmail_ShouldReturnUser

        public void Get_ByEmail_ShouldReturnUser()
        {
            //arrange
            var userRepository = new UserRepository(Properties.Resources.ConnectionString);
            User user = TestDataHelper.GenerateUser();

            //act
            userRepository.CreateUser(user);
            var resultUser = userRepository.GetUser(user.Email);

            //asserts
            TestDataHelper.PrintUserInfo(resultUser);
            Assert.IsTrue(TestDataHelper.CompareUsers(user, resultUser));
        }
开发者ID:Bot32,项目名称:MeetGenerator,代码行数:14,代码来源:UserRepositoryTest.cs

示例10: DeleteInvitation_ShouldDelete

        public void DeleteInvitation_ShouldDelete()
        {
            //arange
            PlaceRepository placeRep = new PlaceRepository(Properties.Resources.ConnectionString);
            MeetingRepository meetRep = new MeetingRepository(Properties.Resources.ConnectionString);
            UserRepository userRep = new UserRepository(Properties.Resources.ConnectionString);
            InvitationRepository inviteRep = new InvitationRepository(Properties.Resources.ConnectionString);

            Meeting meeting = TestDataHelper.GenerateMeeting();
            User invitedUser = TestDataHelper.GenerateUser();

            meeting.InvitedPeople.Clear();

            //act
            userRep.CreateUser(meeting.Owner);
            placeRep.CreatePlace(meeting.Place);
            meetRep.CreateMeeting(meeting);

            userRep.CreateUser(invitedUser);
            inviteRep.Create(CreateInvitation(meeting, invitedUser));

            Meeting resultMeeting = meetRep.GetMeeting(meeting.Id);

            bool inviteResult = resultMeeting.InvitedPeople.Count == 1;
            TestDataHelper.PrintMeetingInfo(resultMeeting);

            inviteRep.Delete(CreateInvitation(resultMeeting, invitedUser));

            resultMeeting = meetRep.GetMeeting(meeting.Id);

            bool deleteResult = resultMeeting.InvitedPeople.Count == 0;

            //assert
            TestDataHelper.PrintMeetingInfo(resultMeeting);
            Assert.IsTrue(inviteResult & deleteResult);
        }
开发者ID:Bot32,项目名称:MeetGenerator,代码行数:36,代码来源:InvitationRepositoryTest.cs

示例11: Create_ShouldCreateUser

        public void Create_ShouldCreateUser()
        {
            //arrange
            var userRepository = new UserRepository(Properties.Resources.ConnectionString);
            User user = TestDataHelper.GenerateUser();
            user.FirstName = "TestUser";

            //act
            userRepository.CreateUser(user);

            //asserts
            var resultUser = userRepository.GetUser(user.Id);
            TestDataHelper.PrintUserInfo(resultUser);
            Assert.IsTrue(TestDataHelper.CompareUsers(user, resultUser));
        }
开发者ID:Bot32,项目名称:MeetGenerator,代码行数:15,代码来源:UserRepositoryTest.cs

示例12: Create_ShouldCreate

        public void Create_ShouldCreate()
        {
            //arange
            PlaceRepository placeRep = new PlaceRepository(Properties.Resources.ConnectionString);
            MeetingRepository meetRep = new MeetingRepository(Properties.Resources.ConnectionString);
            UserRepository userRep = new UserRepository(Properties.Resources.ConnectionString);
            Meeting meeting = TestDataHelper.GenerateMeeting();

            //act
            userRep.CreateUser(meeting.Owner);
            placeRep.CreatePlace(meeting.Place);
            meetRep.CreateMeeting(meeting);
            Meeting resultMeeting = meetRep.GetMeeting(meeting.Id);

            //assert
            TestDataHelper.PrintMeetingInfo(meeting);
            TestDataHelper.PrintMeetingInfo(resultMeeting);
            Assert.IsTrue(TestDataHelper.CompareMeetings(meeting, resultMeeting));
        }
开发者ID:Bot32,项目名称:MeetGenerator,代码行数:19,代码来源:MeetingRepositoryTest.cs

示例13: ShouldThrowExceptionWhenDuplicateAccountName

 public void ShouldThrowExceptionWhenDuplicateAccountName()
 {
     var repo = new UserRepository();
     repo.CreateUser("some_name", "password", "name", "address", "phone");
     repo.CreateUser("some_name", "123", "Mark", "address", "phone");
 }
开发者ID:VLysiuk,项目名称:FitnesseDemo,代码行数:6,代码来源:UserRepositoryTest.cs

示例14: Update_ShouldUpdate

        public void Update_ShouldUpdate()
        {
            //arange
            PlaceRepository placeRep = new PlaceRepository(Properties.Resources.ConnectionString);
            MeetingRepository meetRep = new MeetingRepository(Properties.Resources.ConnectionString);
            UserRepository userRep = new UserRepository(Properties.Resources.ConnectionString);
            Meeting firstMeeting = TestDataHelper.GenerateMeeting();
            Meeting secondMeeting = TestDataHelper.GenerateMeeting();
            secondMeeting.Id = firstMeeting.Id;
            secondMeeting.Owner = firstMeeting.Owner;
            secondMeeting.Place = firstMeeting.Place;
            secondMeeting.Title = "secondMeeting";
            secondMeeting.Description = "second descr";

            //act
            placeRep.CreatePlace(firstMeeting.Place);
            userRep.CreateUser(firstMeeting.Owner);
            meetRep.CreateMeeting(firstMeeting);

            meetRep.UpdateMeetingInfo(secondMeeting);
            Meeting resultMeeting = meetRep.GetMeeting(firstMeeting.Id);

            //assert
            TestDataHelper.PrintMeetingInfo(firstMeeting);
            TestDataHelper.PrintMeetingInfo(secondMeeting);
            TestDataHelper.PrintMeetingInfo(resultMeeting);
            Assert.IsTrue(TestDataHelper.CompareMeetings(secondMeeting, resultMeeting));
        }
开发者ID:Bot32,项目名称:MeetGenerator,代码行数:28,代码来源:MeetingRepositoryTest.cs

示例15: GetAllMeetingsCreatedByUser_ShouldReturnMeetings

        public void GetAllMeetingsCreatedByUser_ShouldReturnMeetings()
        {
            //arange
            PlaceRepository placeRep = new PlaceRepository(Properties.Resources.ConnectionString);
            MeetingRepository meetRep = new MeetingRepository(Properties.Resources.ConnectionString);
            UserRepository userRep = new UserRepository(Properties.Resources.ConnectionString);
            User user = TestDataHelper.GenerateUser();
            List<Meeting> meetingList = new List<Meeting>();

            for (int i = 0; i == 5; i++)
            {
                Meeting meeting = TestDataHelper.GenerateMeeting();
                meeting.Owner = user;
                meetingList.Add(meeting);
            }

            //act
            userRep.CreateUser(user);
            foreach(Meeting meeting in meetingList)
            {
                placeRep.CreatePlace(meeting.Place);
                meetRep.CreateMeeting(meeting);
            }
            List<Meeting> resultMeetingList = meetRep.GetAllMeetingsCreatedByUser(user.Id);

            //assert
            Assert.IsTrue(TestDataHelper.CompareMeetingsLists(meetingList, resultMeetingList));
        }
开发者ID:Bot32,项目名称:MeetGenerator,代码行数:28,代码来源:MeetingRepositoryTest.cs


注:本文中的UserRepository.CreateUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。