예제 #1
0
        private void AsserProfileUser(UserProfileServiceModel profileUser)
        {
            var expectedUser = this.GetProfileUserData();

            Assert.NotNull(profileUser);

            Assert.Equal(expectedUser.Id, profileUser.Id);
            Assert.Equal(expectedUser.Name, profileUser.Name);
            Assert.Equal(expectedUser.Username, profileUser.Username);
            Assert.Equal(expectedUser.Email, profileUser.Email);
            Assert.Equal(expectedUser.Birthdate, profileUser.Birthdate);
        }
예제 #2
0
        public async Task GetProfileByUsernameAsync_WithUsernameAndPage_ShouldReturnValidViewModel()
        {
            // Arrange
            FitStoreDbContext database = this.Database;

            DatabaseHelper.SeedData(database);

            IUserService userService = new UserService(database, null);

            // Act
            UserProfileServiceModel result = await userService.GetProfileByUsernameAsync(username, page);

            // Assert
            result.Username.Should().Be(username);
            result.Orders.Count().Should().Be(2);
        }
예제 #3
0
        public async Task <IActionResult> Index(string id = null, string userName = null)
        {
            UserProfileServiceModel model = null;

            if (id == null)
            {
                if (this.User.Identity.IsAuthenticated)
                {
                    model = await this.userService.GetAsync(this.userManager.GetUserId(User));
                }
            }
            else
            {
                model = await this.userService.GetAsync(id);
            }

            return(model == null?this.RedirectToHome() : this.View(model));
        }
예제 #4
0
 public static Mock <IUserService> GetProfileAsync(this Mock <IUserService> mock, UserProfileServiceModel userData)
 {
     mock.Setup(u => u.GetProfileAsync(It.IsAny <string>()))
     .ReturnsAsync(userData)
     .Verifiable();
     return(mock);
 }