public void EditUsersPresenter_EditUser_ShouldThrowifUserIsNotLoad()
        {
            var view = new Mock <IEditUserView>();

            view.SetupAllProperties();
            var usersData = new Mock <IUsersData>();
            var user      = new AspNetUser()
            {
                Id = 1
            };

            usersData.Setup(u => u.UsersRepository.GetUserById(It.IsAny <int>())).Returns(user);

            var presenter = new EditUserPresenter(view.Object, usersData.Object);

            Assert.Throws <HttpException>(() => view.Raise(v => v.UserEdit += null, view.Object, new EditUserEventArgs(1)));
        }
        public void EditUsersPresenter_GetUser_ShouldLoadUserCorrectly()
        {
            var view = new Mock <IEditUserView>();

            view.SetupAllProperties();
            var usersData = new Mock <IUsersData>();
            var user      = new AspNetUser()
            {
                Id = 1
            };

            usersData.Setup(u => u.UsersRepository.GetUserById(It.IsAny <int>())).Returns(user);

            var presenter = new EditUserPresenter(view.Object, usersData.Object);

            view.Raise(v => v.GetUser += null, view.Object, new GetUserByIdEventArgs(1));

            Assert.AreEqual(user, view.Object.Model.User);
        }
        public void EditUsersPresenter_EditUser_ShouldEditRightUser()
        {
            var view = new Mock <IEditUserView>();

            view.SetupAllProperties();
            var usersData = new Mock <IUsersData>();
            var user      = new AspNetUser()
            {
                Id = 1
            };

            usersData.Setup(u => u.UsersRepository.GetUserById(It.IsAny <int>())).Returns(user);

            var presenter = new EditUserPresenter(view.Object, usersData.Object);

            view.Raise(v => v.GetUser  += null, view.Object, new GetUserByIdEventArgs(1));
            view.Raise(v => v.UserEdit += null, view.Object, new EditUserEventArgs(1));

            usersData.Verify(x => x.UsersRepository.UpdateUser(It.Is <AspNetUser>(u => u.Id == 1)));
        }
Example #4
0
 public EditUserForm()
 {
     InitializeComponent();
     this.Presenter = new EditUserPresenter(this);
 }