|
| 1 | + |
| 2 | +// -------------------------------------------------------------------------------------------------------------------- |
| 3 | +// <copyright company="Aspose" file="ViewsTests.cs"> |
| 4 | +// Copyright (c) 2024 Aspose.Tasks for Cloud |
| 5 | +// </copyright> |
| 6 | +// <summary> |
| 7 | +// Permission is hereby granted, free of charge, to any person obtaining a copy |
| 8 | +// of this software and associated documentation files (the "Software"), to deal |
| 9 | +// in the Software without restriction, including without limitation the rights |
| 10 | +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 11 | +// copies of the Software, and to permit persons to whom the Software is |
| 12 | +// furnished to do so, subject to the following conditions: |
| 13 | +// |
| 14 | +// The above copyright notice and this permission notice shall be included in all |
| 15 | +// copies or substantial portions of the Software. |
| 16 | +// |
| 17 | +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 20 | +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 21 | +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 22 | +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 23 | +// SOFTWARE. |
| 24 | +// </summary> |
| 25 | +// -------------------------------------------------------------------------------------------------------------------- |
| 26 | + |
| 27 | +using Aspose.Tasks.Cloud.Sdk.Model; |
| 28 | +using Aspose.Tasks.Cloud.Sdk.Model.Requests; |
| 29 | +using Aspose.Tasks.Cloud.Sdk.Tests.Base; |
| 30 | +using NUnit.Framework; |
| 31 | +using System.Net; |
| 32 | +using Task = System.Threading.Tasks.Task; |
| 33 | + |
| 34 | +namespace Aspose.Tasks.Cloud.Sdk.Tests.ViewsTests |
| 35 | +{ |
| 36 | + [TestFixture] |
| 37 | + internal sealed class ViewsTests : BaseTestContext |
| 38 | + { |
| 39 | + [Test] |
| 40 | + public async Task TestGetViews() |
| 41 | + { |
| 42 | + var remoteName = await UploadFileToStorageAsync("Home move plan.mpp"); |
| 43 | + var response = await TasksApi.GetViewsAsync(new GetViewsRequest() |
| 44 | + { |
| 45 | + Name = remoteName, |
| 46 | + Folder = this.DataFolder |
| 47 | + }); |
| 48 | + |
| 49 | + Assert.AreEqual((int)HttpStatusCode.OK, response.Code); |
| 50 | + Assert.IsNotNull(response.Views); |
| 51 | + var views = response.Views; |
| 52 | + |
| 53 | + Assert.IsNotNull(views); |
| 54 | + var ganttChartView = views[0]; |
| 55 | + Assert.IsNotNull(ganttChartView); |
| 56 | + Assert.AreEqual(true, ganttChartView.ShowInMenu); |
| 57 | + Assert.AreEqual(ItemType.TaskItem, ganttChartView.Type); |
| 58 | + Assert.AreEqual(ViewScreen.Gantt, ganttChartView.Screen); |
| 59 | + Assert.AreEqual("&Gantt Chart", ganttChartView.Name); |
| 60 | + Assert.AreEqual(1, ganttChartView.Uid); |
| 61 | + } |
| 62 | + |
| 63 | + [Test] |
| 64 | + public async Task TestGetAllTableTextStyles() |
| 65 | + { |
| 66 | + var remoteName = await UploadFileToStorageAsync("NewProductDev.mpp"); |
| 67 | + var response = await TasksApi.GetAllTableTextStylesAsync(new GetAllTableTextStylesRequest() |
| 68 | + { |
| 69 | + Name = remoteName, |
| 70 | + ViewUid = 2, |
| 71 | + Folder = this.DataFolder |
| 72 | + }); |
| 73 | + |
| 74 | + Assert.AreEqual((int)HttpStatusCode.OK, response.Code); |
| 75 | + |
| 76 | + Assert.AreEqual(8, response.Items.Length); |
| 77 | + } |
| 78 | + |
| 79 | + [Test] |
| 80 | + public async Task TestGetTableTextStyle() |
| 81 | + { |
| 82 | + var remoteName = await UploadFileToStorageAsync("NewProductDev.mpp"); |
| 83 | + var response = await TasksApi.GetTableTextStyleAsync(new GetTableTextStyleRequest() |
| 84 | + { |
| 85 | + Name = remoteName, |
| 86 | + ViewUid = 2, |
| 87 | + RowUid = 29, |
| 88 | + Folder = this.DataFolder |
| 89 | + }); |
| 90 | + |
| 91 | + Assert.AreEqual((int)HttpStatusCode.OK, response.Code); |
| 92 | + |
| 93 | + var tableTextStyle = response.TableTextStyle; |
| 94 | + Assert.IsNotNull(tableTextStyle); |
| 95 | + Assert.AreEqual(29, tableTextStyle.RowUid); |
| 96 | + Assert.AreEqual(Field.Undefined, tableTextStyle.Field); |
| 97 | + Assert.AreEqual(TextItemType.Allocated, tableTextStyle.ItemType); |
| 98 | + Assert.AreEqual(Colors.Transparent, tableTextStyle.Color); |
| 99 | + Assert.AreEqual(BackgroundPattern.Hollow, tableTextStyle.BackgroundPattern); |
| 100 | + Assert.AreEqual(Colors.Transparent, tableTextStyle.BackgroundColor); |
| 101 | + } |
| 102 | + |
| 103 | + [Test] |
| 104 | + public async Task TestCreateTableTextStyle() |
| 105 | + { |
| 106 | + var remoteName = await UploadFileToStorageAsync("Home move plan.mpp"); |
| 107 | + var newTableTextStyle = new TableTextStyle |
| 108 | + { |
| 109 | + RowUid = 3, |
| 110 | + Field = Field.TaskName, |
| 111 | + ItemType = TextItemType.Allocated, |
| 112 | + Color = Colors.Red, |
| 113 | + BackgroundPattern = BackgroundPattern.Hollow, |
| 114 | + BackgroundColor = Colors.GreenYellow, |
| 115 | + }; |
| 116 | + var createResponse = await TasksApi.CreateTableTextStyleAsync(new CreateTableTextStyleRequest() |
| 117 | + { |
| 118 | + Name = remoteName, |
| 119 | + ViewUid = 1, |
| 120 | + Folder = this.DataFolder, |
| 121 | + TableTextStyle = newTableTextStyle |
| 122 | + }); |
| 123 | + |
| 124 | + Assert.AreEqual((int)HttpStatusCode.Created, createResponse.Code); |
| 125 | + |
| 126 | + var getResponse = await TasksApi.GetTableTextStyleAsync(new GetTableTextStyleRequest() |
| 127 | + { |
| 128 | + Name = remoteName, |
| 129 | + ViewUid = 1, |
| 130 | + RowUid = 3, |
| 131 | + Folder = this.DataFolder |
| 132 | + }); |
| 133 | + |
| 134 | + var receivedTableTextStyle = getResponse.TableTextStyle; |
| 135 | + Assert.IsNotNull(receivedTableTextStyle); |
| 136 | + Assert.AreEqual(newTableTextStyle.RowUid, receivedTableTextStyle.RowUid); |
| 137 | + Assert.AreEqual(newTableTextStyle.Field, receivedTableTextStyle.Field); |
| 138 | + Assert.AreEqual(newTableTextStyle.ItemType, receivedTableTextStyle.ItemType); |
| 139 | + Assert.AreEqual(newTableTextStyle.Color, receivedTableTextStyle.Color); |
| 140 | + Assert.AreEqual(newTableTextStyle.BackgroundPattern, receivedTableTextStyle.BackgroundPattern); |
| 141 | + Assert.AreEqual(newTableTextStyle.BackgroundColor, receivedTableTextStyle.BackgroundColor); |
| 142 | + } |
| 143 | + |
| 144 | + [Test] |
| 145 | + public async Task TestUpdateTableTextStyle() |
| 146 | + { |
| 147 | + var remoteName = await UploadFileToStorageAsync("NewProductDev.mpp"); |
| 148 | + var getRequest = new GetTableTextStyleRequest() |
| 149 | + { |
| 150 | + Name = remoteName, |
| 151 | + ViewUid = 2, |
| 152 | + RowUid = 29, |
| 153 | + Folder = this.DataFolder |
| 154 | + }; |
| 155 | + var getResponse = await TasksApi.GetTableTextStyleAsync(getRequest); |
| 156 | + Assert.AreEqual(Colors.Transparent, getResponse.TableTextStyle.Color); |
| 157 | + Assert.AreEqual(Colors.Transparent, getResponse.TableTextStyle.BackgroundColor); |
| 158 | + |
| 159 | + getResponse.TableTextStyle.Color = Colors.OrangeRed; |
| 160 | + getResponse.TableTextStyle.BackgroundColor = Colors.DodgerBlue; |
| 161 | + |
| 162 | + var updateResponse = await TasksApi.UpdateTableTextStyleAsync(new UpdateTableTextStyleRequest() |
| 163 | + { |
| 164 | + Name = remoteName, |
| 165 | + ViewUid = 2, |
| 166 | + Folder = this.DataFolder, |
| 167 | + TableTextStyle = getResponse.TableTextStyle |
| 168 | + }); |
| 169 | + Assert.AreEqual((int)HttpStatusCode.OK, updateResponse.Code); |
| 170 | + |
| 171 | + getResponse = await TasksApi.GetTableTextStyleAsync(getRequest); |
| 172 | + Assert.AreEqual(Colors.OrangeRed, getResponse.TableTextStyle.Color); |
| 173 | + Assert.AreEqual(Colors.DodgerBlue, getResponse.TableTextStyle.BackgroundColor); |
| 174 | + } |
| 175 | + |
| 176 | + [Test] |
| 177 | + public async Task TestDeleteTableTextStyle() |
| 178 | + { |
| 179 | + var remoteName = await UploadFileToStorageAsync("NewProductDev.mpp"); |
| 180 | + var getResponse = await TasksApi.GetAllTableTextStylesAsync(new GetAllTableTextStylesRequest() |
| 181 | + { |
| 182 | + Name = remoteName, |
| 183 | + ViewUid = 2, |
| 184 | + Folder = this.DataFolder |
| 185 | + }); |
| 186 | + Assert.AreEqual(8, getResponse.Items.Length); |
| 187 | + |
| 188 | + var deleteResponse = await TasksApi.DeleteTableTextStyleAsync(new DeleteTableTextStyleRequest() |
| 189 | + { |
| 190 | + Name = remoteName, |
| 191 | + ViewUid = 2, |
| 192 | + RowUid = 29, |
| 193 | + Folder = this.DataFolder, |
| 194 | + }); |
| 195 | + Assert.AreEqual((int)HttpStatusCode.OK, deleteResponse.Code); |
| 196 | + |
| 197 | + getResponse = await TasksApi.GetAllTableTextStylesAsync(new GetAllTableTextStylesRequest() |
| 198 | + { |
| 199 | + Name = remoteName, |
| 200 | + ViewUid = 2, |
| 201 | + Folder = this.DataFolder |
| 202 | + }); |
| 203 | + Assert.AreEqual(7, getResponse.Items.Length); |
| 204 | + } |
| 205 | + } |
| 206 | +} |
0 commit comments