Пример #1
0
 private EditUserProfileFormModel GetEditUserForm(RegularUserProfileServiceModel user)
 {
     return(new EditUserProfileFormModel()
     {
         Username = user.Username,
         Email = user.Email
     });
 }
Пример #2
0
        public async Task ProfileShouldRedirectToHomeWhenUserDoesNotExist()
        {
            //Arrange
            RegularUserProfileServiceModel user = null;
            var controller = new UsersController(this.userService.Object, null, this.fixture.UserManagerMockInstance.Object, null, null);

            this.userService.Setup(u => u.GetRegularUserProfileDetailsAsync(It.IsAny <string>()))
            .ReturnsAsync(user);

            this.PrepareTempData();

            controller.TempData = this.tempData.Object;

            //Act
            var result = await controller.Profile(UserId);

            //Assert
            this.AssertRedirectToHome(result);
            this.customMessage.Should().Be(string.Format(WebConstants.Message.NonExistingEntity, WebConstants.Entity.User, UserId));
        }
Пример #3
0
        public async Task ProfileShouldReturnViewWithUserInfoWithCorrectData()
        {
            //Arrange
            var controller = new UsersController(this.userService.Object, null, this.fixture.UserManagerMockInstance.Object, null, null);

            this.userService.Setup(u => u.GetRegularUserProfileDetailsAsync(It.IsAny <string>()))
            .ReturnsAsync(this.GetUserProfile());

            //Act
            var result = await controller.Profile(UserId);

            //Assert
            result.Should().BeOfType <ViewResult>();
            RegularUserProfileServiceModel model = result.As <ViewResult>().Model.As <RegularUserProfileServiceModel>();

            model.Email.Should().Be(UserEmail);
            model.FirstName.Should().Be(UserFirstName);
            model.LastName.Should().Be(UserLastName);
            model.Id.Should().Be(UserId);
            model.Username.Should().Be(UserUsername);
        }