Skip to content

Commit d8a3e05

Browse files
Merge pull request #309 from TransactionProcessing/codacy/high_fixes
Codacy/high fixes
2 parents 3bc68d4 + 57821dc commit d8a3e05

15 files changed

Lines changed: 154 additions & 130 deletions

File tree

EstateManagementUI.BusinessLogic/Clients/ApiClient.cs

Lines changed: 77 additions & 78 deletions
Large diffs are not rendered by default.

EstateManagementUI.BusinessLogic/PermissionService/Constants/ApplicationSections.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace EstateManagementUI.BusinessLogic.PermissionService.Constants;
44

55
[ExcludeFromCodeCoverage]
6-
public class ApplicationSections
6+
public record ApplicationSections
77
{
88
public static readonly string Dashboard = "Dashboard";
99
public static readonly string Estate = "Estate";

EstateManagementUI.BusinessLogic/PermissionService/Constants/DashboardFunctions.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
namespace EstateManagementUI.BusinessLogic.PermissionService.Constants;
44

55
[ExcludeFromCodeCoverage]
6-
public class DashboardFunctions
6+
public record DashboardFunctions
77
{
8-
98
public static readonly string Dashboard = "Dashboard";
109
}

EstateManagementUI.BusinessLogic/PermissionService/Constants/MerchantFunctions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace EstateManagementUI.BusinessLogic.PermissionService.Constants;
44

55
[ExcludeFromCodeCoverage]
6-
public class MerchantFunctions
6+
public record MerchantFunctions
77
{
88
public static readonly string ViewList = "View Merchant List";
99
public static readonly string View = "View Single Merchant";

EstateManagementUI.BusinessLogic/PermissionService/Constants/OperatorFunctions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace EstateManagementUI.BusinessLogic.PermissionService.Constants;
44

55
[ExcludeFromCodeCoverage]
6-
public class OperatorFunctions
6+
public record OperatorFunctions
77
{
88
public static readonly string ViewList = "View Operators List";
99
public static readonly string View = "View Single Operator";

EstateManagementUI.IntegrationTests/Common/DockerHelper.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,8 @@ private async Task<IContainerService> StartEstateManagementUiContainer(List<INet
251251
if (response.IsSuccessStatusCode == false) {
252252
TraceX($"createRolesRequest failed [{response.StatusCode}]");
253253
}
254+
TraceX($"Create Role Response is [{response.StatusCode}]");
255+
254256
HttpRequestMessage addUserToRoleRequest = new(HttpMethod.Post,
255257
$"https://localhost:{this.EstateManagementUiPort}/api/Permissions/addUserToRole");
256258
List<AddUserToRole> userRolesList = new List<AddUserToRole> {
@@ -266,6 +268,7 @@ private async Task<IContainerService> StartEstateManagementUiContainer(List<INet
266268
TraceX($"addUserToRoleRequest failed [{response.StatusCode}]");
267269
}
268270

271+
TraceX($"Add User to Role Response is [{response.StatusCode}]");
269272

270273
HttpRequestMessage getRolePermissionsRequest = new(HttpMethod.Get,
271274
$"https://localhost:{this.EstateManagementUiPort}/api/Permissions/getRolePermissions?roleName=Administrator");

EstateManagementUI.UITests/AddContractDialogTests.cs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@ public async Task Save_AssignsContractToMerchant_WhenContractIdIsNotEmpty()
5757

5858
// Assert
5959
this._mediatorMock.Verify(m => m.Send(It.IsAny<Commands.AssignContractToMerchantCommand>(), It.IsAny<CancellationToken>()), Times.Once);
60-
this._addContractDialog.Events.Count.ShouldBe(2);
61-
this._addContractDialog.Events[0].ShouldBeOfType<MerchantPageEvents.ContractAssignedToMerchantEvent>();
62-
this._addContractDialog.Events[1].ShouldBeOfType<MerchantPageEvents.HideAddContractDialog>();
60+
var events = this._addContractDialog.GetDispatchedEvents();
61+
events.Count.ShouldBe(2);
62+
events[0].ShouldBeOfType<MerchantPageEvents.ContractAssignedToMerchantEvent>();
63+
events[1].ShouldBeOfType<MerchantPageEvents.HideAddContractDialog>();
6364
}
6465

6566
[Fact]
@@ -76,9 +77,10 @@ public async Task Save_ShowsErrorMessage_WhenAssignContractFails()
7677

7778
// Assert
7879
this._mediatorMock.Verify(m => m.Send(It.IsAny<Commands.AssignContractToMerchantCommand>(), It.IsAny<CancellationToken>()), Times.Once);
79-
this._addContractDialog.Events.Count.ShouldBe(2);
80-
this._addContractDialog.Events[0].ShouldBeOfType<ShowMessage>();
81-
this._addContractDialog.Events[1].ShouldBeOfType<MerchantPageEvents.HideAddContractDialog>();
80+
var events = this._addContractDialog.GetDispatchedEvents();
81+
events.Count.ShouldBe(2);
82+
events[0].ShouldBeOfType<ShowMessage>();
83+
events[1].ShouldBeOfType<MerchantPageEvents.HideAddContractDialog>();
8284
}
8385

8486
[Fact]
@@ -88,7 +90,8 @@ public async Task Close_DispatchesHideAddContractDialogEvent()
8890
await this._addContractDialog.Close();
8991

9092
// Assert
91-
this._addContractDialog.Events.Count.ShouldBe(1);
92-
this._addContractDialog.Events[0].ShouldBeOfType<MerchantPageEvents.HideAddContractDialog>();
93+
var events = this._addContractDialog.GetDispatchedEvents();
94+
events.Count.ShouldBe(1);
95+
events[0].ShouldBeOfType<MerchantPageEvents.HideAddContractDialog>();
9396
}
9497
}

EstateManagementUI.UITests/AddDeviceDialogTests.cs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,10 @@ public async Task Save_AssignsDeviceToMerchant()
5454

5555
// Assert
5656
this._mediatorMock.Verify(m => m.Send(It.IsAny<Commands.AssignDeviceToMerchantCommand>(), It.IsAny<CancellationToken>()), Times.Once);
57-
this._addDeviceDialog.Events.Count.ShouldBe(2);
58-
this._addDeviceDialog.Events[0].ShouldBeOfType<MerchantPageEvents.DeviceAssignedToMerchantEvent>();
59-
this._addDeviceDialog.Events[1].ShouldBeOfType<MerchantPageEvents.HideAddDeviceDialog>();
57+
var events = this._addDeviceDialog.GetDispatchedEvents();
58+
events.Count.ShouldBe(2);
59+
events[0].ShouldBeOfType<MerchantPageEvents.DeviceAssignedToMerchantEvent>();
60+
events[1].ShouldBeOfType<MerchantPageEvents.HideAddDeviceDialog>();
6061
}
6162

6263
[Fact]
@@ -73,10 +74,11 @@ public async Task Save_AssignsDeviceToMerchant_Fails()
7374

7475
// Assert
7576
this._mediatorMock.Verify(m => m.Send(It.IsAny<Commands.AssignDeviceToMerchantCommand>(), It.IsAny<CancellationToken>()), Times.Once);
76-
77-
this._addDeviceDialog.Events.Count.ShouldBe(2);
78-
this._addDeviceDialog.Events[0].ShouldBeOfType<ShowMessage>();
79-
this._addDeviceDialog.Events[1].ShouldBeOfType<MerchantPageEvents.HideAddDeviceDialog>();
77+
78+
var events = this._addDeviceDialog.GetDispatchedEvents();
79+
events.Count.ShouldBe(2);
80+
events[0].ShouldBeOfType<ShowMessage>();
81+
events[1].ShouldBeOfType<MerchantPageEvents.HideAddDeviceDialog>();
8082
}
8183

8284
[Fact]
@@ -86,7 +88,8 @@ public async Task Close_DispatchesHideAddContractDialogEvent()
8688
await this._addDeviceDialog.Close();
8789

8890
// Assert
89-
this._addDeviceDialog.Events.Count.ShouldBe(1);
90-
this._addDeviceDialog.Events[0].ShouldBeOfType<MerchantPageEvents.HideAddDeviceDialog>();
91+
var events = this._addDeviceDialog.GetDispatchedEvents();
92+
events.Count.ShouldBe(1);
93+
events[0].ShouldBeOfType<MerchantPageEvents.HideAddDeviceDialog>();
9194
}
9295
}

EstateManagementUI.UITests/AddOperatorDialogTests.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ public async Task Save_ShouldAssignOperatorToMerchant()
6161

6262
// Assert
6363
this._mediatorMock.Verify(m => m.Send(It.IsAny<Commands.AssignOperatorToMerchantCommand>(), It.IsAny<CancellationToken>()), Times.Once);
64-
this._addOperatorDialog.Events.ShouldContain(e => e is MerchantPageEvents.OperatorAssignedToMerchantEvent);
64+
var events = this._addOperatorDialog.GetDispatchedEvents();
65+
events.ShouldContain(e => e is MerchantPageEvents.OperatorAssignedToMerchantEvent);
6566
}
6667

6768
[Fact]
@@ -81,7 +82,8 @@ public async Task Save_ShouldShowErrorMessageOnFailure()
8182

8283
// Assert
8384
this._mediatorMock.Verify(m => m.Send(It.IsAny<Commands.AssignOperatorToMerchantCommand>(), It.IsAny<CancellationToken>()), Times.Once);
84-
this._addOperatorDialog.Events.ShouldContain(e => e is ShowMessage && ((ShowMessage)e).Message == "Error assigning operator to Merchant");
85+
var events = this._addOperatorDialog.GetDispatchedEvents();
86+
events.ShouldContain(e => e is ShowMessage && ((ShowMessage)e).Message == "Error assigning operator to Merchant");
8587
}
8688

8789
[Fact]
@@ -91,6 +93,7 @@ public async Task Close_ShouldDispatchHideAddOperatorDialogEvent()
9193
await this._addOperatorDialog.Close();
9294

9395
// Assert
94-
this._addOperatorDialog.Events.ShouldContain(e => e is MerchantPageEvents.HideAddOperatorDialog);
96+
var events = this._addOperatorDialog.GetDispatchedEvents();
97+
events.ShouldContain(e => e is MerchantPageEvents.HideAddOperatorDialog);
9598
}
9699
}

EstateManagementUI.UITests/EditMerchantTests.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ public void AddOperator_ShouldDispatchShowAddOperatorDialogEvent()
4242
this._editMerchant.AddOperator();
4343

4444
// Assert
45-
this._editMerchant.Events.ShouldContain(e => e is MerchantPageEvents.ShowAddOperatorDialog);
45+
var events = this._editMerchant.GetDispatchedEvents();
46+
events.ShouldContain(e => e is MerchantPageEvents.ShowAddOperatorDialog);
4647
}
4748

4849
[Fact]
@@ -51,7 +52,8 @@ public void AddContract_ShouldDispatchShowAddContractDialogEvent() {
5152
this._editMerchant.AddContract();
5253

5354
// Assert
54-
this._editMerchant.Events.ShouldContain(e => e is MerchantPageEvents.ShowAddContractDialog);
55+
var events = this._editMerchant.GetDispatchedEvents();
56+
events.ShouldContain(e => e is MerchantPageEvents.ShowAddContractDialog);
5557
}
5658

5759
[Fact]
@@ -61,7 +63,8 @@ public void AddDevice_ShouldDispatchShowAddDeviceDialogEvent()
6163
this._editMerchant.AddDevice();
6264

6365
// Assert
64-
this._editMerchant.Events.ShouldContain(e => e is MerchantPageEvents.ShowAddDeviceDialog);
66+
var events = this._editMerchant.GetDispatchedEvents();
67+
events.ShouldContain(e => e is MerchantPageEvents.ShowAddDeviceDialog);
6568
}
6669

6770

@@ -127,7 +130,8 @@ public async Task Save_MerchantDepositIsMade()
127130

128131
await this._makeDeposit.Save();
129132

130-
this._makeDeposit.Events.ShouldContain(e => e is MerchantPageEvents.DepositMadeEvent);
133+
var events = this._makeDeposit.GetDispatchedEvents();
134+
events.ShouldContain(e => e is MerchantPageEvents.DepositMadeEvent);
131135
}
132136

133137
[Fact]
@@ -143,6 +147,7 @@ public async Task Save_SaveFailed_MerchantDepositIsNotMade()
143147

144148
await this._makeDeposit.Save();
145149

146-
this._makeDeposit.Events.ShouldContain(e => e is ShowMessage);
150+
var events = this._makeDeposit.GetDispatchedEvents();
151+
events.ShouldContain(e => e is ShowMessage);
147152
}
148153
}

0 commit comments

Comments
 (0)