コード例 #1
0
        public MockedDummyProfileScreenSettingsRepo()
        {
            using (var mock = AutoMock.GetStrict())
            {
                mock.Mock <IProfileSettingsRepository>().Setup(ip => ip.ChangeAge(It.IsAny <int>(), It.IsAny <int>()))
                .Callback((int user, int age) => this._userInfo.age = age);

                mock.Mock <IProfileSettingsRepository>().Setup(ip => ip.ChangeFirstName(It.IsAny <int>(), It.IsAny <string>()))
                .Callback((int user, string frname) => this._userInfo.firstName = frname);

                mock.Mock <IProfileSettingsRepository>().Setup(ip => ip.ChangeLastName(It.IsAny <int>(), It.IsAny <string>()))
                .Callback((int user, string lsname) => this._userInfo.firstName = lsname);

                mock.Mock <IProfileSettingsRepository>().Setup(ip => ip.ChangeGender(It.IsAny <int>(), It.IsAny <string>()))
                .Callback((int user, string gender) => this._userInfo.gender = gender);

                mock.Mock <IProfileSettingsRepository>().Setup(ip => ip.ChangeMail(It.IsAny <int>(), It.IsAny <string>()))
                .Callback((int user, string mail) => this._userInfo.email = mail);

                mock.Mock <IProfileSettingsRepository>().Setup(ip => ip.ChangePassword(It.IsAny <int>(), It.IsAny <string>()))
                .Callback((int user, string pass) => this._user.password = pass);


                mock.Mock <IProfileSettingsRepository>().Setup(ip => ip.ChangeUserName(It.IsAny <int>(), It.IsAny <string>()))
                .Callback((int user, string username) => this._user.userName = username);

                mock.Mock <IProfileSettingsRepository>().Setup(ip => ip.GetDataForThisUser(It.IsAny <int>())).Returns(this._userInfo);

                mock.Mock <IProfileSettingsRepository>().Setup(ip => ip.GetListOfEMails()).Returns(this.emails);

                mock.Mock <IProfileSettingsRepository>().Setup(ip => ip.GetListOfUserNames()).Returns(this.usernames);

                mock.Mock <IProfileSettingsRepository>().Setup(ip => ip.GetUserFromDB(It.IsAny <int>())).Returns(this._user);

                _profileScreenSettingsRepository = mock.Create <IProfileSettingsRepository>();
            }
        }
コード例 #2
0
 //for tests
 public ProfileScreenSettingsService(IProfileSettingsRepository _profileSettings)
 {
     _profileScreeenSettings = _profileSettings;
     CurrentUser             = _profileScreeenSettings.GetUserFromDB(Properties.Settings.Default.id);
     CurrentUserInfo         = _profileScreeenSettings.GetDataForThisUser(Properties.Settings.Default.id);
 }