Пример #1
0
 //for tests
 public SettingsPresenter(IProfileScreen _profileS, IProfileScreenSettingsService _profileService)
 {
     _profileScreenService = _profileService;
     _profileScreen        = _profileS;
 }
        public MockedDummyProfileScreenSettingsService()
        {
            using (var mock = AutoMock.GetStrict())
            {
                mock.Mock <IProfileScreenSettingsService>().Setup(prs => prs.UpdateMail(It.IsAny <string>()))
                .Callback((string mail) =>
                {
                    if (error == true)
                    {
                        throw new Exception();
                    }
                    else
                    {
                        _userInfo.email = mail;
                    }
                }
                          );

                mock.Mock <IProfileScreenSettingsService>().Setup(prs => prs.UpdateAge(It.IsAny <int>()))
                .Callback((int age) =>
                {
                    if (error == true)
                    {
                        throw new Exception();
                    }
                    else
                    {
                        _userInfo.age = age;
                    }
                }
                          );


                mock.Mock <IProfileScreenSettingsService>().Setup(prs => prs.UpdateGender(It.IsAny <string>()))
                .Callback((string gender) =>
                {
                    if (error == true)
                    {
                        throw new Exception();
                    }
                    else
                    {
                        _userInfo.gender = gender;
                    }
                });


                mock.Mock <IProfileScreenSettingsService>().Setup(prs => prs.UpdatePassword(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()))
                .Callback((string old, string newPass, string repPass) =>
                {
                    if (error == true)
                    {
                        throw new Exception();
                    }
                    else
                    {
                        _user.password = newPass;
                    }
                });

                mock.Mock <IProfileScreenSettingsService>().Setup(prs => prs.UpdateUserName(It.IsAny <string>()))
                .Callback((string userName) =>
                {
                    if (error == true)
                    {
                        throw new Exception();
                    }
                    else
                    {
                        _user.userName = userName;
                    }
                });


                mock.Mock <IProfileScreenSettingsService>().Setup(prs => prs.UpdateFirstName(It.IsAny <string>()))
                .Callback((string firstName) =>
                {
                    if (error == true)
                    {
                        throw new Exception();
                    }
                    else
                    {
                        _userInfo.firstName = firstName;
                    }
                });


                mock.Mock <IProfileScreenSettingsService>().Setup(prs => prs.UpdateLastName(It.IsAny <string>()))
                .Callback((string lastName) =>
                {
                    if (error == true)
                    {
                        throw new Exception();
                    }
                    else
                    {
                        _userInfo.lastName = lastName;
                    }
                });

                _profileScreenSettingsService = mock.Create <IProfileScreenSettingsService>();
            }
        }
Пример #3
0
 public SettingsPresenter(IProfileScreen _profileS)
 {
     _profileScreenService = new ProfileScreenSettingsService();
     _profileScreen        = _profileS;
 }