|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.Linq; |
| 4 | +using System.Text; |
| 5 | +using System.Threading.Tasks; |
| 6 | +using static API.Test.AuthentificationTests; |
| 7 | +using SixLabors.ImageSharp; |
| 8 | +using WebUntisAPI.Client.Models; |
| 9 | + |
| 10 | +namespace API.Test; |
| 11 | + |
| 12 | +[TestFixture] |
| 13 | +internal class ProfileTests |
| 14 | +{ |
| 15 | + [Test] |
| 16 | + public void GetRecipientProfileImgTest() |
| 17 | + { |
| 18 | + Client.LoginAsync(s_Server, s_LoginName, s_UserName, s_Password).Wait(); |
| 19 | + |
| 20 | + Task<Image> imgRender = Client.GetMessagePersonProfileImageAsync(new() { DisplayName = "Test Person" }); |
| 21 | + imgRender.Wait(); |
| 22 | + imgRender.Result.SaveAsPng("RenderImg.png"); |
| 23 | + |
| 24 | + Task<Image> imgDownload = Client.GetMessagePersonProfileImageAsync(new() { ImageUrl = new("https://foundations.projectpythia.org/_images/GitHub-logo.png") }); // A Random non square GitHub image i found |
| 25 | + imgDownload.Wait(); |
| 26 | + imgDownload.Result.SaveAsPng("DownloadImg.png"); |
| 27 | + } |
| 28 | + |
| 29 | + [Test] |
| 30 | + public void GetSupportedLanguages() |
| 31 | + { |
| 32 | + Client.LoginAsync(s_Server, s_LoginName, s_UserName, s_Password).Wait(); |
| 33 | + |
| 34 | + Task<Dictionary<string, string>> languages = Client.GetAvailableLanguagesAsync(); |
| 35 | + languages.Wait(); |
| 36 | + |
| 37 | + if (languages.Result.Count > 0) |
| 38 | + Assert.Pass(); |
| 39 | + else |
| 40 | + Assert.Fail(); |
| 41 | + } |
| 42 | + |
| 43 | + [Test] |
| 44 | + public void GetAccountConfiguration() |
| 45 | + { |
| 46 | + Client.LoginAsync(s_Server, s_LoginName, s_UserName, s_Password).Wait(); |
| 47 | + |
| 48 | + Task<AccountConfig> accountConfig = Client.GetAccountConfigAsync(); |
| 49 | + accountConfig.Wait(); |
| 50 | + |
| 51 | + if (accountConfig.Result is not null) |
| 52 | + Assert.Pass(); |
| 53 | + else |
| 54 | + Assert.Fail(); |
| 55 | + } |
| 56 | + |
| 57 | + [Test] |
| 58 | + public void GetGenerallyInformation() |
| 59 | + { |
| 60 | + Client.LoginAsync(s_Server, s_LoginName, s_UserName, s_Password).Wait(); |
| 61 | + |
| 62 | + Task<GeneralAccount> account = Client.GetGenerallyAccountInformationAsync(); |
| 63 | + account.Wait(); |
| 64 | + |
| 65 | + if (account.Result is not null) |
| 66 | + Assert.Pass(); |
| 67 | + else |
| 68 | + Assert.Fail(); |
| 69 | + } |
| 70 | + |
| 71 | + [Test] |
| 72 | + public void GetContactDetails() |
| 73 | + { |
| 74 | + Client.LoginAsync(s_Server, s_LoginName, s_UserName, s_Password).Wait(); |
| 75 | + |
| 76 | + Task<(ContactDetails? contact, bool read, bool write)> contact = Client.GetContactDetailsAsync(); |
| 77 | + contact.Wait(); |
| 78 | + |
| 79 | + if (contact.Result.read) |
| 80 | + Assert.Pass(); |
| 81 | + else |
| 82 | + Assert.Fail(); |
| 83 | + } |
| 84 | + |
| 85 | + [Test] |
| 86 | + public void GetOwnProfileImage() |
| 87 | + { |
| 88 | + Client.LoginAsync(s_Server, s_LoginName, s_UserName, s_Password).Wait(); |
| 89 | + |
| 90 | + Task<(Image? image, bool read, bool write)> image = Client.GetOwnProfileImageAsync(); |
| 91 | + image.Wait(); |
| 92 | + |
| 93 | + image.Result.image.SaveAsPngAsync("ProfileImg.png"); |
| 94 | + } |
| 95 | +} |
0 commit comments