예제 #1
0
        public ProfileControllerTests()
        {
            validator = Substitute.For<IAccountValidator>();
            service = Substitute.For<IAccountService>();

            profileDelete = ObjectFactory.CreateProfileDeleteView();
            profileEdit = ObjectFactory.CreateProfileEditView();

            controller = Substitute.ForPartsOf<ProfileController>(validator, service);
            ReturnCurrentAccountId(controller, "Test");
        }
예제 #2
0
        public void ShouldAcceptNewProfile()
        {
            const string name = "test";

            var evnt = new EventHelper(() => { view.Confirm += null; });

            var profile = new Profile {Name = name};
            manager.Stub(x => x.ContainsProfile(name)).Repeat.Once().Return(false);
            manager.Stub(x => x.GetBrowsersNames()).Repeat.Once().Return(browsers);
            view.Stub(x => x.ShowError(new[] {""})).IgnoreArguments().Repeat.Never();
            mocks.ReplayAll();
            var controller = new ProfileController();
            controller.SetView(view);
            controller.SetManager(manager);
            controller.SetProfile(profile, true);
            evnt.Raise();
        }
예제 #3
0
        //BOT STARTING POINT
        public TarkovManager(StartupSettings config, EftApi api)
        {
            _config = config;

            //Create the Login Controller
            _loginController = new LoginController(_config, api);

            //Create the Profile Controller
            _profileController = new ProfileController();

            //Create the Market Controller
            _marketController = new MarketController(_profileController);

            //Create the Trader Controller
            _traderController = new TraderController();

            _botEndTime = DateTime.Now.AddHours(_hoursForBotToRestart);

            //Create a thread for a back-end task that the server will complete
            var botTask = new Task(StartTradingGrind);

            botTask.Start();
        }
        public void TestClickedDeleteEnteringIncorrectEmail()
        {
            //ARRANGE
            //mock out the session variables used in the ClickedDelete function in the ProfileController
            var mockControllerContext = new Mock <ControllerContext>();
            var mockSession           = new Mock <HttpSessionStateBase>();

            mockSession.SetupGet(s => s["userEmail"]).Returns("*****@*****.**");
            mockControllerContext.Setup(p => p.HttpContext.Session).Returns(mockSession.Object);

            var controller = new ProfileController();

            controller.ControllerContext = mockControllerContext.Object;

            string expected = "Incorrect email address entered. Please try again.";

            //ACT
            controller.ClickedDelete("incorrectEmail");
            string actual = controller.TempData["emailError"].ToString();

            //ASSERT
            Assert.AreEqual(expected, actual);
        }
        public void Users_ProfileController_Index_ShouldReturnCorrectUser()
        {
            // Arrange
            var data         = new Mock <IUowData>();
            var pagerFactory = new Mock <IPagerViewModelFactory>();

            data.Setup(d => d.Users.All()).Returns(UsersCollection().AsQueryable());

            ProfileController controller = new ProfileController(data.Object, pagerFactory.Object);

            var expected = new UserViewModel()
            {
                Id = "ea70a65b-12b4-4df3-8ee6-33b0554c47e7", Email = "*****@*****.**"
            };

            // Act
            var result      = controller.Index("ea70a65b-12b4-4df3-8ee6-33b0554c47e7") as ViewResult;
            var resultModel = result.Model as UserViewModel;

            // Assert
            Assert.That(expected, Has.Property("Id").EqualTo(resultModel.Id) &
                        Has.Property("Email").EqualTo(resultModel.Email));
        }
예제 #6
0
        private static void EnsureIdentitySourceProfilePropertyDefinitionExists(int portalId)
        {
            var def = ProfileController.GetPropertyDefinitionByName(portalId, "IdentitySource");

            if (def == null)
            {
                var dataTypes  = (new ListController()).GetListEntryInfoDictionary("DataType");
                var definition = new ProfilePropertyDefinition(portalId)
                {
                    DataType          = dataTypes["DataType:Text"].EntryID,
                    DefaultValue      = "Azure-B2C",
                    DefaultVisibility = UserVisibilityMode.AdminOnly,
                    PortalId          = portalId,
                    ModuleDefId       = Null.NullInteger,
                    PropertyCategory  = "Security",
                    PropertyName      = "IdentitySource",
                    Required          = false,
                    Visible           = false,
                    ViewOrder         = -1
                };
                ProfileController.AddPropertyDefinition(definition);
            }
        }
예제 #7
0
        private void UpdateUserAlbumProfileSetting(bool enableUserAlbum)
        {
            HelperFunctions.BeginTransaction();

            try
            {
                foreach (IUserAccount user in UserController.GetAllUsers())
                {
                    IUserProfile profile = ProfileController.GetProfile(user.UserName);

                    profile.GetGalleryProfile(GalleryId).EnableUserAlbum = enableUserAlbum;

                    ProfileController.SaveProfile(profile);
                }
                HelperFunctions.CommitTransaction();
                HelperFunctions.PurgeCache();
            }
            catch
            {
                HelperFunctions.RollbackTransaction();
                throw;
            }
        }
예제 #8
0
        public void Get_gets_all_profiles_then_returns_list_view()
        {
            #region Arrange
            using (Mock.Record())
            {
                Expect.Call(ProfileService.GetAllProfiles()).Return(ProfileList);
            }

            #endregion

            #region Act
            ViewResult view;
            using (Mock.Playback())
            {
                view = (ViewResult)ProfileController.List();
            }
            #endregion

            #region Assert
            Assert.IsEmpty(view.ViewName);
            Assert.That(view.ViewData.Model, Is.EqualTo(ProfileList));
            #endregion
        }
예제 #9
0
        public void TestNewLog_ShouldCallUserServiceGetUserById(string userId)
        {
            // Arrange
            var mockedProvider = new Mock <IAuthenticationProvider>();

            mockedProvider.Setup(p => p.CurrentUserId).Returns(userId);

            var user = new User();

            var mockedService = new Mock <IUserService>();

            mockedService.Setup(s => s.GetUserById(It.IsAny <string>())).Returns(user);

            var mockedFactory = new Mock <IViewModelFactory>();

            var controller = new ProfileController(mockedProvider.Object, mockedService.Object, mockedFactory.Object);

            // Act
            controller.NewLog();

            // Assert
            mockedService.Verify(s => s.GetUserById(userId));
        }
예제 #10
0
        public void EditPost_WithInvalidModel_Return_EditViewAgain()
        {
            // Arrange
            var mediatorMock = new Mock <IMediator>();
            var identityMock = new Mock <IIdentityService>();
            var mapperMock   = new Mock <IMapper>();

            var controller = new ProfileController(identityMock.Object,
                                                   mediatorMock.Object,
                                                   mapperMock.Object);

            controller.ModelState.AddModelError("FirstName", "FirstNameRequired");
            var model = new ProfileViewModel {
            };

            // Act
            var result = controller.Edit(model).GetAwaiter().GetResult();

            // Assert
            var viewResult = Assert.IsType <ViewResult>(result);

            Assert.IsAssignableFrom <ProfileViewModel>(viewResult.ViewData.Model);
        }
예제 #11
0
        public void Post_sets_profile_as_inactive_then_redirects_to_list_view()
        {
            #region Arrange
            using (Mock.Record())
            {
                Expect.Call(ProfileService.SetAsInactive(1)).Return(true);
            }

            #endregion

            #region Act

            RedirectToRouteResult redirect;
            using (Mock.Playback())
            {
                redirect = (RedirectToRouteResult)ProfileController.Delete(1);
            }
            #endregion

            #region Assert
            redirect.AssertActionRedirect().ToAction("List");
            #endregion
        }
        public void ShowOneandShowAllReturnsIActionResult()
        {
            DbContextOptions <FunemploymentDbContext> options = new DbContextOptionsBuilder <FunemploymentDbContext>()
                                                                .UseInMemoryDatabase("ShowAllReturns")
                                                                .Options;

            using (FunemploymentDbContext context = new FunemploymentDbContext(options))
            {
                Player player = new Player();
                player.Username = "******";
                player.Location = "testLocation";
                player.About    = "testAbout";

                ProfileController pc = new ProfileController(context, Configuration);

                var x = pc.ShowAll();
                var y = pc.ShowOne(player.ID);


                Assert.IsAssignableFrom <IActionResult>(x);
                Assert.IsAssignableFrom <IActionResult>(y);
            }
        }
예제 #13
0
        public void SetUp()
        {
            this.mockedMappingService  = new Mock <IMappingService>();
            this.mockedPlacesService   = new Mock <IPlaceService>();
            this.mockedArticlesService = new Mock <IArticleService>();
            this.mockedPictureService  = new Mock <IPictureService>();
            this.mockedUserService     = new Mock <IUserService>();
            this.mockedCountryService  = new Mock <ICountryService>();
            this.mockedCacheProvider   = new Mock <ICacheProvider>();
            this.mockedUserProvider    = new Mock <IUserProvider>();
            this.mockedFileProvider    = new Mock <IFileProvider>();

            this.controller = new ProfileController(
                mockedMappingService.Object,
                mockedPlacesService.Object,
                mockedCountryService.Object,
                mockedArticlesService.Object,
                mockedPictureService.Object,
                mockedUserService.Object,
                mockedCacheProvider.Object,
                mockedUserProvider.Object,
                mockedFileProvider.Object);
        }
예제 #14
0
        public void ProfilePage_ShouldReturnNotNullViewResult()
        {
            // Arrange
            var userId         = "12345";
            var order          = new Order();
            var orderVm        = new OrderViewModel();
            var previousOrders = new List <Order>();

            this.identityProviderMock.Setup(i => i.GetUserId()).Returns(userId);
            this.orderServiceMock.Setup(o => o.GetOrderInBasket(userId)).Returns(order);
            this.mappingServiceMock.Setup(m => m.Map <Order, OrderViewModel>(order));
            this.orderServiceMock.Setup(o => o.PreviousOrders(userId)).Returns(previousOrders);

            var model = new ProfilePageViewModel();

            var profileController = new ProfileController(this.orderServiceMock.Object, this.mappingServiceMock.Object, this.imageProviderMock.Object, this.identityProviderMock.Object);

            // Act
            var viewResult = profileController.ProfilePage(model) as ViewResult;

            // Assert
            Assert.IsNotNull(viewResult);
        }
예제 #15
0
        private void ConfigureControllers(Application application)
        {
            Type localClass = application.GetType();

            deviceController = new DeviceController();

            Debug.WriteLine("## AppName: " + deviceController.AppName);
            Debug.WriteLine("## Version: " + deviceController.Version);

            foreach (object attribute in localClass.GetCustomAttributes(true))
            {
                if (attribute is MposConfig)
                {
                    MposConfig appConfig = (MposConfig)attribute;
                    Debug.WriteLine(appConfig);

                    if (appConfig.DeviceDetails)
                    {
                        deviceController.CollectDeviceConfig();
                    }
                    if (appConfig.LocationCollect)
                    {
                        deviceController.CollectLocation();
                    }

                    if (appConfig.EndpointSecondary == null && !appConfig.DiscoveryCloudlet)
                    {
                        throw new NetworkException("You must define an internet server IP or allow the service discovery!");
                    }

                    profileController  = new ProfileController(appConfig.Profile);
                    endpointController = new EndpointController(appConfig.EndpointSecondary, appConfig.DecisionMakerActive, appConfig.DiscoveryCloudlet);

                    break;
                }
            }
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// cmdUpdate_Click runs when the Update Button is clicked
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// -----------------------------------------------------------------------------
        private void cmdUpdate_Click(object sender, EventArgs e)
        {
            if (IsUserOrAdmin == false && UserId == Null.NullInteger)
            {
                return;
            }

            if (IsValid)
            {
                if (User.UserID == PortalSettings.AdministratorId)
                {
                    //Clear the Portal Cache
                    DataCache.ClearPortalCache(UserPortalID, true);
                }

                //Update DisplayName to conform to Format
                UpdateDisplayName();

                if (PortalSettings.Registration.RequireUniqueDisplayName)
                {
                    var usersWithSameDisplayName = (List <UserInfo>)MembershipProvider.Instance().GetUsersBasicSearch(PortalId, 0, 2, "DisplayName", true, "DisplayName", User.DisplayName);
                    if (usersWithSameDisplayName.Any(user => user.UserID != User.UserID))
                    {
                        AddModuleMessage("DisplayNameNotUnique", ModuleMessage.ModuleMessageType.RedError, true);
                        return;
                    }
                }

                var properties = (ProfilePropertyDefinitionCollection)ProfileProperties.DataSource;

                //Update User's profile
                User = ProfileController.UpdateUserProfile(User, properties);

                OnProfileUpdated(EventArgs.Empty);
                OnProfileUpdateCompleted(EventArgs.Empty);
            }
        }
예제 #17
0
        /// <summary>
        /// Gets the Profile properties for the User
        /// </summary>
        /// <param name="portalId">The Id of the portal.</param>
        /// <param name="objProfile">The profile.</param>
        /// <history>
        ///     [cnurse]	03/29/2006	Created
        /// </history>
        private void GetProfileProperties(int portalId, IDataReader dr, UserProfile objProfile)
        {
            int definitionId;
            ProfilePropertyDefinition           profProperty;
            ProfilePropertyDefinitionCollection properties;

            properties = ProfileController.GetPropertyDefinitionsByPortal(portalId);

            //Iterate through the Profile properties
            try
            {
                while (dr.Read())
                {
                    definitionId = Convert.ToInt32(dr["PropertyDefinitionId"]);
                    profProperty = properties.GetById(definitionId);
                    if (profProperty != null)
                    {
                        profProperty.PropertyValue = Convert.ToString(dr["PropertyValue"]);
                        profProperty.Visibility    = (UserVisibilityMode)dr["Visibility"];
                    }
                }
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                }
            }

            //Add the properties to the profile
            foreach (ProfilePropertyDefinition tempLoopVar_profProperty in properties)
            {
                profProperty = tempLoopVar_profProperty;
                objProfile.ProfileProperties.Add(profProperty);
            }
        }
예제 #18
0
        public void ReturnDefaultView()
        {
            // Arrange
            var mockedAccountService = new Mock <IAccountService>();
            var mockedUserService    = new Mock <IUserService>();
            var user = new CustomUser()
            {
                Id = 2
            };

            mockedUserService.Setup(x => x.GetById(It.IsAny <int>())).Returns(user);

            var mockedFriendService    = new Mock <IFriendService>();
            var mockedViewModelService = new Mock <IViewModelService>();
            var model = new ProfileViewModel()
            {
                Friends = new List <ProfileFriendViewModel>()
            };

            mockedViewModelService.Setup(x => x.GetMappedProfile(It.IsAny <CustomUser>())).Returns(model);

            var profileController = new ProfileController(
                mockedAccountService.Object,
                mockedUserService.Object,
                mockedFriendService.Object,
                mockedViewModelService.Object);
            int id = 4;

            // Act & Assert
            profileController
            .WithCallTo(x => x.Index(id))
            .ShouldRenderDefaultView()
            .WithModel <ProfileViewModel>(x =>
            {
                Assert.AreEqual(model, x);
            });
        }
예제 #19
0
파일: Users.ascx.cs 프로젝트: ds-rod/dnnIJT
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            try
            {
                if (!Page.IsPostBack)
                {
                    ClientAPI.RegisterKeyCapture(txtSearch, cmdSearch, 13);
                    //Load the Search Combo
                    ddlSearchType.Items.Add(AddSearchItem("Username"));
                    ddlSearchType.Items.Add(AddSearchItem("Email"));
                    ddlSearchType.Items.Add(AddSearchItem("DisplayName"));
                    var           controller    = new ListController();
                    ListEntryInfo imageDataType = controller.GetListEntryInfo("DataType", "Image");
                    ProfilePropertyDefinitionCollection profileProperties = ProfileController.GetPropertyDefinitionsByPortal(PortalId, false, false);
                    foreach (ProfilePropertyDefinition definition in profileProperties)
                    {
                        if (imageDataType != null && definition.DataType != imageDataType.EntryID)
                        {
                            ddlSearchType.Items.Add(AddSearchItem(definition.PropertyName));
                        }
                    }

                    //Sent controls to current Filter
                    if ((!String.IsNullOrEmpty(Filter) && Filter.ToUpper() != "NONE") && !String.IsNullOrEmpty(FilterProperty))
                    {
                        txtSearch.Text = Filter;
                        ddlSearchType.SelectedValue = FilterProperty;
                    }
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
예제 #20
0
        public void TestDetails_ShouldCallViewModelFactoryCreateUserProfileCorrectly(string username)
        {
            // Arrange
            var user = new User();

            var mockedProvider = new Mock <IAuthenticationProvider>();

            var mockedService = new Mock <IUserService>();

            mockedService.Setup(s => s.GetUserByUsername(It.IsAny <string>())).Returns(user);

            var mockedFactory = new Mock <IViewModelFactory>();

            mockedFactory.Setup(f => f.CreateUserProfileViewModel(It.IsAny <User>(), It.IsAny <bool>()))
            .Returns((User u, bool canEdit) => new UserProfileViewModel(user, canEdit));

            var controller = new ProfileController(mockedProvider.Object, mockedService.Object, mockedFactory.Object);

            // Act
            controller.Details(username);

            // Assert
            mockedFactory.Verify(f => f.CreateUserProfileViewModel(user, It.IsAny <bool>()), Times.Once);
        }
예제 #21
0
        public HttpResponseMessage CurrentUserProfile(Entity.User user)
        {
            // POST /api/users/currentuserprofile
            try
            {
                if ((!string.IsNullOrWhiteSpace(Utils.UserName) || !string.IsNullOrWhiteSpace(user.UserName)) && !Utils.UserName.Equals(user.UserName, StringComparison.OrdinalIgnoreCase))
                {
                    throw new GallerySecurityException("Cannot save profile because specified username does not match currently logged on username.");
                }

                ProfileController.SaveProfile(user);

                return(new HttpResponseMessage(HttpStatusCode.OK)
                {
                    Content = new StringContent($"Profile updated for user {user.UserName}...")
                });
            }
            catch (GallerySecurityException ex)
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Forbidden)
                {
                    Content      = Utils.GetExStringContent(ex),
                    ReasonPhrase = "Server Error"
                });
            }
            catch (Exception ex)
            {
                AppEventController.LogError(ex);

                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError)
                {
                    Content      = Utils.GetExStringContent(ex),
                    ReasonPhrase = "Server Error"
                });
            }
        }
        public void ProcessProfileDataTest()
        {
            Profile profile = new Profile();

            profile.UsernameField = user.Username;
            profile.NameField     = user.Name;
            profile.SurnameField  = user.Surname;
            profile.EmailField    = user.ContactInfo.Email;
            profile.AddressField  = user.ContactInfo.Address;
            profile.PhoneField    = user.ContactInfo.PhoneNumber;
            profile.DeleteButton  = "Save";

            var mockCurrentSession = new Mock <ICurrentSession>();

            mockCurrentSession.Setup(x => x.SetUsername(user.Username)).Returns(true);
            ProfileController profileController = new ProfileController(mockCurrentSession.Object);
            var result = profileController.ProcessProfileData(profile) as ViewResult;

            Assert.AreEqual("Views/Profile/ProfileView.cshtml", result.ViewName);

            profile.DeleteButton = "Delete";
            result = profileController.ProcessProfileData(profile) as ViewResult;
            Assert.AreEqual("Views/Home/Index.cshtml", result.ViewName);
        }
예제 #23
0
        public async Task FetchProfileAsync_ShouldBeOkObjectResult()
        {
            // Arrange
            var user = new User
            {
                Profile = new UserProfile("FirstName", "LastName", Gender.Male)
            };

            TestMock.UserService.Setup(userManager => userManager.GetUserAsync(It.IsAny <ClaimsPrincipal>())).ReturnsAsync(user).Verifiable();

            TestMock.UserService.Setup(userManager => userManager.GetProfileAsync(It.IsAny <User>())).ReturnsAsync(user.Profile).Verifiable();

            var controller = new ProfileController(TestMock.UserService.Object, TestMapper);

            // Act
            var result = await controller.FetchProfileAsync();

            // Assert
            result.Should().BeOfType <OkObjectResult>();

            TestMock.UserService.Verify(userManager => userManager.GetUserAsync(It.IsAny <ClaimsPrincipal>()), Times.Once);

            TestMock.UserService.Verify(userManager => userManager.GetProfileAsync(It.IsAny <User>()), Times.Once);
        }
예제 #24
0
        private void BindRepeater()
        {
            DataSet   ds = new DataSet();
            DataTable dt = ds.Tables.Add("Properties");

            dt.Columns.Add("Property", typeof(string));
            dt.Columns.Add("Mapping", typeof(string));

            Dictionary <string, string>         properties = new Dictionary <string, string>();
            ProfilePropertyDefinitionCollection props      = ProfileController.GetPropertyDefinitionsByPortal(PortalId);

            foreach (ProfilePropertyDefinition def in props)
            {
                if (def.PropertyName == "FirstName" || def.PropertyName == "LastName")
                {
                }
                else
                {
                    string  setting = Null.NullString;
                    DataRow row     = ds.Tables[0].NewRow();
                    row[0] = def.PropertyName + ":";
                    if (PortalController.Instance.GetPortalSettings(PortalId).TryGetValue(usrPREFIX + def.PropertyName, out setting))
                    {
                        row[1] = setting;
                    }
                    else
                    {
                        row[1] = "";
                    }
                    ds.Tables[0].Rows.Add(row);
                }
            }

            repeaterProps.DataSource = ds;
            repeaterProps.DataBind();
        }
        public void SetUp()
        {
            _personServiceMock          = new Mock <crds_angular.Services.Interfaces.IPersonService>();
            _serveServiceMock           = new Mock <IServeService>();
            _donorService               = new Mock <IDonorService>();
            _impersonationService       = new Mock <IUserImpersonationService>();
            _authenticationService      = new Mock <IAuthenticationRepository>();
            _userService                = new Mock <IUserRepository>();
            _contactRelationshipService = new Mock <IContactRelationshipRepository>();
            _config = new Mock <IConfigurationWrapper>();

            _config.Setup(mocked => mocked.GetConfigValue("AdminGetProfileRoles")).Returns("123,456");

            _fixture = new ProfileController(_personServiceMock.Object, _serveServiceMock.Object, _impersonationService.Object, _donorService.Object, _authenticationService.Object, _userService.Object, _contactRelationshipService.Object, _config.Object, new Mock <IUserImpersonationService>().Object);
            _authenticationServiceMock = new Mock <IAuthenticationRepository>();

            _authType        = "auth_type";
            _authToken       = "auth_token";
            _fixture.Request = new HttpRequestMessage();
            _fixture.Request.Headers.Authorization = new AuthenticationHeaderValue(_authType, _authToken);
            _fixture.RequestContext = new HttpRequestContext();

            _authenticationServiceMock.Setup(mocked => mocked.GetContactId(_authType + " " + _authToken)).Returns(myContactId);
        }
예제 #26
0
        public async Task IndexShouldReturnCorrectViewModel()
        {
            var mockService     = new Mock <IProfileService>();
            var mockUserManager = new Mock <UserManager <ApplicationUser> >(
                new Mock <IUserStore <ApplicationUser> >().Object,
                new Mock <IOptions <IdentityOptions> >().Object,
                new Mock <IPasswordHasher <ApplicationUser> >().Object,
                new IUserValidator <ApplicationUser> [0],
                new IPasswordValidator <ApplicationUser> [0],
                new Mock <ILookupNormalizer>().Object,
                new Mock <IdentityErrorDescriber>().Object,
                new Mock <IServiceProvider>().Object,
                new Mock <ILogger <UserManager <ApplicationUser> > >().Object);

            var roleStore       = new Mock <IRoleStore <ApplicationRole> >();
            var roleManagerMock =
                new Mock <RoleManager <ApplicationRole> >(roleStore.Object, null, null, null, null);

            var controller =
                new ProfileController(mockUserManager.Object, roleManagerMock.Object, mockService.Object);
            var result = await controller.Index("indieza", ProfileTab.Activities, 0);

            Assert.IsType <NotFoundResult>(result);
        }
예제 #27
0
        public void ReturnPartialView_WithSameModel_WhenNoErrors()
        {
            // Arrange
            var mockedAccountService   = new Mock <IAccountService>();
            var mockedUserService      = new Mock <IUserService>();
            var mockedFriendService    = new Mock <IFriendService>();
            var mockedViewModelService = new Mock <IViewModelService>();
            var updatedModel           = new ProfilePersonalnfo();

            mockedViewModelService.Setup(x => x.GetMappedProfilePersonalInfo(It.IsAny <CustomUser>())).Returns(updatedModel);

            var profileController = new ProfileController(
                mockedAccountService.Object,
                mockedUserService.Object,
                mockedFriendService.Object,
                mockedViewModelService.Object);
            var model = new ProfilePersonalnfo();

            // Act & Assert
            profileController
            .WithCallTo(x => x.Edit(model))
            .ShouldRenderPartialView("_ProfilePersonalInfoPartial")
            .WithModel(updatedModel);
        }
예제 #28
0
        private bool SaveFile(bool aSaveAs = false)
        {
            try
            {
                if (this.mTransactionOLV.Items.Count <= 0)
                {
                    MessageBox.Show("Nothing to save!");
                    return(false);
                }

                if (String.IsNullOrEmpty(this.Profile.Filename) || aSaveAs)
                {
                    DialogResult nResult = this.mSaveFileDialog.ShowDialog();
                    if (nResult == DialogResult.OK)
                    {
                        this.Profile.Filename = this.mSaveFileDialog.FileName;
                    }
                    else
                    {
                        return(false);
                    }
                }

                ProfileController.getInstance().SaveRecords(this.RecordModel);
                ProfileController.getInstance().SaveCodes(this.CodeModel);
                ProfileController.getInstance().Save(this.Profile.Filename);
                RegistryController.Add(this.Profile.Filename);
                this.mStatusLabel.Text = "Saved";

                return(true);
            }
            catch (IOException)
            {
                return(false);
            }
        }
예제 #29
0
        public ProfilViewModel()
        {
            _signInController       = SignInController.GetInstance();
            _controller             = new ProfileController();
            FirstDetailsVisibility  = Visibility.Visible;
            SecondDetailsVisibility = Visibility.Collapsed;
            User   user  = _signInController.ConnectedUser;
            string genre = _controller.GetGenreName(user.GenreId);
            string place = _controller.GetPlaceName(user.PlaceId);

            if (user != null)
            {
                FirstDetails = new ObservableCollection <GetParamViewModel>
                {
                    new GetParamViewModel("First Name: ", isLabel: true, givvenParam: user.FirstName),
                    new GetParamViewModel("Last Name: ", isLabel: true, givvenParam: user.LastName),
                    new GetParamViewModel("Email: ", isLabel: true, givvenParam: user.Email),
                    new GetParamViewModel("Birth day-day: ", isLabel: true, givvenParam: user.Day.ToString()),
                    new GetParamViewModel("Birth day-month: ", isLabel: true, givvenParam: user.Month.ToString()),
                    new GetParamViewModel("Birth day-year: ", isLabel: true, givvenParam: user.Year.ToString()),
                    new GetParamViewModel("Genre: ", isLabel: true, givvenParam: genre, getParamOptions: _controller.GetTopGenresNames),
                    new GetParamViewModel("Place: ", isLabel: true, givvenParam: place, getParamOptions: _controller.GetTopPlacesNames)
                };
                ArtistsCollection = new ObservableCollection <GetParamViewModel>();
                foreach (var artistId in user.Artists)
                {
                    string artist = _controller.GetArtistName(artistId);
                    ArtistsCollection.Add(new GetParamViewModel("Artist Name: ", isLabel: true, getParamOptions: _controller.GetTopArtistsNames, givvenParam: artist));
                }
                SongsCollection = new ObservableCollection <GetParamViewModel>();
                foreach (var song in user.Songs)
                {
                    SongsCollection.Add(new GetParamViewModel("Song Name: ", isLabel: true, getParamOptions: _controller.GetTopSongsNames, givvenParam: song));
                }
            }
        }
예제 #30
0
        public void EditAddressModelStateIsInvalid_POST()
        {
            GenericIdentity mockIdentity = new GenericIdentity("User");

            mockIdentity.AddClaim(new Claim("UserId", "1"));
            var principal = new GenericPrincipal(mockIdentity, null);

            AddressViewModel address = new AddressViewModel {
                ID = 1, PostAddress1 = "P O Box2361", State = "gaborone"
            };
            UserDetailViewModel userDetail = new UserDetailViewModel {
                ID = 1, FirstName = "Pearl", Address = address
            };

            var controller = new ProfileController(mockUserService.Object,
                                                   mockAddressService.Object, mockUserDetailService.Object, mapper);

            var mockHttpContext = new Mock <HttpContext>();

            mockHttpContext.Setup(m => m.User).Returns(principal);



            controller.ControllerContext.HttpContext      = new DefaultHttpContext();
            controller.ControllerContext.HttpContext.User = principal;

            controller.ModelState.AddModelError("State", "State is required");

            var result = controller.EditAddress(userDetail) as PartialViewResult;
            var model  = result.Model as UserDetailViewModel;

            Assert.Equal("Pearl", model.FirstName);
            Assert.Equal("P O Box2361", model.Address.PostAddress1);
            Assert.Equal("gaborone", model.Address.State);
            Assert.Equal(200, controller.HttpContext.Response.StatusCode);
        }
예제 #31
0
        private void SaveSettings()
        {
            this.wwDataBinder.Unbind(this);

            if (wwDataBinder.BindingErrors.Count > 0)
            {
                ClientMessage = new ClientMessageOptions
                {
                    Title   = Resources.GalleryServer.Validation_Summary_Text,
                    Message = wwDataBinder.BindingErrors.ToString(),
                    Style   = MessageStyle.Error
                };

                return;
            }

            UserController.SaveUser(this.CurrentUser);

            bool originalEnableUserAlbumSetting = ProfileController.GetProfileForGallery(GalleryId).EnableUserAlbum;

            SaveProfile(this.CurrentProfile);

            SaveSettingsCompleted(originalEnableUserAlbumSetting);
        }
예제 #32
0
 public ProfileControllerTest()
 {
     _sut = new ProfileController(_userRepository, _um, _profileValidator);
 }
        public void Initialize()
        {
            this.unitOfWorkMock = new MeetyChatDataMock();

            this.controller = new ProfileController(this.unitOfWorkMock, UserIdProviderMock.GetUserIdProvider().Object);
            this.serializer = new JavaScriptSerializer();
            this.SetupController();
        }
예제 #34
0
 protected void Awake()
 {
     profileController = this;
 }
예제 #35
0
 public void ShouldAttachToAllEvents()
 {
     view = mocks.StrictMock<IProfileView>();
     EventHelper.EventIsAttached(() => { view.Confirm += null; });
     EventHelper.EventIsAttached(() => { view.SelectProfileIcon += null; });
     mocks.ReplayAll();
     var controller = new ProfileController();
     controller.SetView(view);
 }
예제 #36
0
 public void ShouldAttachToLoadModel()
 {
     manager = mocks.StrictMock<IDataManager>();
     EventHelper.EventIsAttached(() => { manager.DataLoaded += null; });
     manager.Stub(x => x.IsIFLoaded()).Return(false);
     mocks.ReplayAll();
     var controller = new ProfileController();
     controller.SetManager(manager);
 }
예제 #37
0
        public void ShouldMergeInterfacesFromProfileAndModel()
        {
            var allNames = new[] {"if1","if2","if3"};
            var evnt = new EventHelper(() => { manager.DataLoaded += null;  });
            var ifs = new List<NetworkInterfaceSettings> { new NetworkInterfaceSettings { Name = allNames[0] }, new NetworkInterfaceSettings { Name = allNames[2] } };

            var profile = new Profile();
            profile.Connections = new ProfileNetworkSettingsList { new ProfileNetworkSettings { Settings = new NetworkInterfaceSettings { Name = allNames[1] } },
                                                                    new ProfileNetworkSettings { Settings = new NetworkInterfaceSettings { Name = allNames[2] } }};
            manager.Stub(x => x.IsIFLoaded()).Return(false);
            manager.Stub(x => x.GetNetworkInterfaceSettings()).Return(ifs);
            manager.Stub(x => x.GetBrowsersNames()).Repeat.Once().Return(browsers);

            mocks.ReplayAll();
            var controller = new ProfileController();
            controller.SetView(view);
            controller.SetManager(manager);
            controller.SetProfile(profile, false);
            evnt.Raise();

            Assert.AreEqual(3,profile.Connections.GetNetworkInterfaceNames().Count);
        }