public IActionResult Get() { var userId = TokenManager.ExtractUserId(User.Claims); var user = _userRepository.Get(userId); var fileSize = _videFileRepository.TotalFileSizeForUser(userId); var userSettingsResponse = UserSettingsResponse.MapFromObject(user, fileSize); return(Ok(userSettingsResponse)); }
public async Task CreateUserSettingsTest() { var service = new Mock <ISettingsService>(); var request = new UserProfileRequest { Email = "alex@", FirstName = "alex", Language = LanguageName.Fr, LastName = "softeq", PhoneNumber = "123" }; var response = new UserSettingsResponse { UserId = UserId, Settings = new List <NotificationSettingModel> { new NotificationSettingModel { Type = NotificationType.Push, Event = NotificationEvent.ArticleCreated, Enabled = true } } }; UserProfileRequest req = null; service.Setup(x => x.CreateUserSettingsAsync(It.Is <UserProfileRequest>(sr => sr == request && sr.UserId == UserId))) .Callback <UserProfileRequest>(r => req = r) .ReturnsAsync(response) .Verifiable(); var controller = new SettingsController(_logger, service.Object).WithUser(); var result = await controller.CreateUserSettingsAsync(request); service.Verify(); Assert.NotNull(req); Assert.Equal(UserId, req.UserId); var res = Assert.IsType <CreatedAtRouteResult>(result); Assert.Equal(response, res.Value); Assert.IsType <UserSettingsResponse>(res.Value); }