Skip to content

Commit

Permalink
Concentrator CRUD is now using database (#1323)
Browse files Browse the repository at this point in the history
* Concentrator list use database + Add sorting

* Get concentrator now uses DB

* CreateConcentrator now uses DB

* Update concentrator now uses DB

* Delete concentrator now uses DB

* Fix LoRaWANConcentratorsControllerTests

* Fix LoRaWANConcentratorServiceTests

* Fix ConcentratorListPageTests

* Delete Route from GetAllDeviceConcentrator() in LoRaWANConcentratorsController

* Make protected as private + remove unused usings

Co-authored-by: Hocine Hacherouf <hacherouf.hocine@gmail.com>
  • Loading branch information
audserraCGI and hocinehacherouf authored Oct 13, 2022
1 parent ee40b28 commit 6d43858
Show file tree
Hide file tree
Showing 18 changed files with 622 additions and 665 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace AzureIoTHub.Portal.Tests.Unit.Client.Pages.LoRaWan.Concentrator
public class ConcentratorDetailPageTests : BlazorUnitTest
{
private Mock<IDialogService> mockDialogService;
private Mock<ILoRaWanConcentratorsClientService> mockLoRaWanConcentratorsClientService;
private Mock<ILoRaWanConcentratorClientService> mockLoRaWanConcentratorsClientService;

private readonly string mockDeviceId = Guid.NewGuid().ToString();

Expand All @@ -38,7 +38,7 @@ public override void Setup()
base.Setup();

this.mockDialogService = MockRepository.Create<IDialogService>();
this.mockLoRaWanConcentratorsClientService = MockRepository.Create<ILoRaWanConcentratorsClientService>();
this.mockLoRaWanConcentratorsClientService = MockRepository.Create<ILoRaWanConcentratorClientService>();

_ = Services.AddSingleton(this.mockDialogService.Object);
_ = Services.AddSingleton(this.mockLoRaWanConcentratorsClientService.Object);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ public class ConcentratorListPageTests : BlazorUnitTest
{
private Mock<IDialogService> mockDialogService;
private Mock<ISnackbar> mockSnackbarService;
private Mock<ILoRaWanConcentratorsClientService> mockLoRaWanConcentratorsClientService;
private Mock<ILoRaWanConcentratorClientService> mockLoRaWanConcentratorClientService;

public override void Setup()
{
base.Setup();

this.mockDialogService = MockRepository.Create<IDialogService>();
this.mockSnackbarService = MockRepository.Create<ISnackbar>();
this.mockLoRaWanConcentratorsClientService = MockRepository.Create<ILoRaWanConcentratorsClientService>();
this.mockLoRaWanConcentratorClientService = MockRepository.Create<ILoRaWanConcentratorClientService>();

_ = Services.AddSingleton(this.mockDialogService.Object);
_ = Services.AddSingleton(this.mockSnackbarService.Object);
_ = Services.AddSingleton(this.mockLoRaWanConcentratorsClientService.Object);
_ = Services.AddSingleton(this.mockLoRaWanConcentratorClientService.Object);

_ = Services.AddSingleton(new PortalSettings { IsLoRaSupported = true });
}
Expand All @@ -46,9 +46,9 @@ public override void Setup()
public void ConcentratorListPageShouldLoadAndShowConcentrators()
{
// Arrange
var expectedUri = "api/lorawan/concentrators?pageSize=10";
var expectedUri = "api/lorawan/concentrators?pageNumber=0&pageSize=10&orderBy=";

_ = this.mockLoRaWanConcentratorsClientService.Setup(service =>
_ = this.mockLoRaWanConcentratorClientService.Setup(service =>
service.GetConcentrators(It.Is<string>(s => expectedUri.Equals(s, StringComparison.Ordinal))))
.ReturnsAsync(new PaginationResult<ConcentratorDto>
{
Expand All @@ -74,9 +74,9 @@ public void ConcentratorListPageShouldLoadAndShowConcentrators()
public void ConcentratorListPageShouldProcessProblemDetailsExceptionWhenIssueOccursOnLoadingConcentrators()
{
// Arrange
var expectedUri = "api/lorawan/concentrators?pageSize=10";
var expectedUri = "api/lorawan/concentrators?pageNumber=0&pageSize=10&orderBy=";

_ = this.mockLoRaWanConcentratorsClientService.Setup(service =>
_ = this.mockLoRaWanConcentratorClientService.Setup(service =>
service.GetConcentrators(It.Is<string>(s => expectedUri.Equals(s, StringComparison.Ordinal))))
.ThrowsAsync(new ProblemDetailsException(new ProblemDetailsWithExceptionDetails()));

Expand All @@ -96,9 +96,9 @@ public void ClickToItemShouldRedirectToConcentratorDetailsPage()
{
// Arrange
var deviceId = Guid.NewGuid().ToString();
var expectedUri = "api/lorawan/concentrators?pageSize=10";
var expectedUri = "api/lorawan/concentrators?pageNumber=0&pageSize=10&orderBy=";

_ = this.mockLoRaWanConcentratorsClientService.Setup(service =>
_ = this.mockLoRaWanConcentratorClientService.Setup(service =>
service.GetConcentrators(It.Is<string>(s => expectedUri.Equals(s, StringComparison.Ordinal))))
.ReturnsAsync(new PaginationResult<ConcentratorDto>
{
Expand Down Expand Up @@ -126,9 +126,9 @@ public void ClickToItemShouldRedirectToConcentratorDetailsPage()
public void ClickOnAddNewDeviceShouldNavigateToNewDevicePage()
{
// Arrange
const string expectedUri = "api/lorawan/concentrators?pageSize=10";
const string expectedUri = "api/lorawan/concentrators?pageNumber=0&pageSize=10&orderBy=";

_ = this.mockLoRaWanConcentratorsClientService.Setup(service =>
_ = this.mockLoRaWanConcentratorClientService.Setup(service =>
service.GetConcentrators(It.Is<string>(s => expectedUri.Equals(s, StringComparison.Ordinal))))
.ReturnsAsync(new PaginationResult<ConcentratorDto>
{
Expand All @@ -155,9 +155,9 @@ public void ClickOnAddNewDeviceShouldNavigateToNewDevicePage()
public void ClickOnRefreshShouldReloadConcentrators()
{
// Arrange
var expectedUri = "api/lorawan/concentrators?pageSize=10";
var expectedUri = "api/lorawan/concentrators?pageNumber=0&pageSize=10&orderBy=";

_ = this.mockLoRaWanConcentratorsClientService.Setup(service =>
_ = this.mockLoRaWanConcentratorClientService.Setup(service =>
service.GetConcentrators(It.Is<string>(s => expectedUri.Equals(s, StringComparison.Ordinal))))
.ReturnsAsync(new PaginationResult<ConcentratorDto>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class CreateConcentratorPageTest : BlazorUnitTest
{
private Mock<IDialogService> mockDialogService;
private Mock<ISnackbar> mockSnackbarService;
private Mock<ILoRaWanConcentratorsClientService> mockLoRaWanConcentratorsClientService;
private Mock<ILoRaWanConcentratorClientService> mockLoRaWanConcentratorsClientService;

private FakeNavigationManager mockNavigationManager;

Expand All @@ -38,7 +38,7 @@ public override void Setup()

this.mockDialogService = MockRepository.Create<IDialogService>();
this.mockSnackbarService = MockRepository.Create<ISnackbar>();
this.mockLoRaWanConcentratorsClientService = MockRepository.Create<ILoRaWanConcentratorsClientService>();
this.mockLoRaWanConcentratorsClientService = MockRepository.Create<ILoRaWanConcentratorClientService>();

_ = Services.AddSingleton(this.mockDialogService.Object);
_ = Services.AddSingleton(this.mockSnackbarService.Object);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ public class DeleteConcentratorPageTests : BlazorUnitTest
{
private DialogService dialogService;
private Mock<ISnackbar> mockSnackbarService;
private Mock<ILoRaWanConcentratorsClientService> mockLoRaWanConcentratorsClientService;
private Mock<ILoRaWanConcentratorClientService> mockLoRaWanConcentratorsClientService;

public override void Setup()
{
base.Setup();

this.mockSnackbarService = MockRepository.Create<ISnackbar>();
this.mockLoRaWanConcentratorsClientService = MockRepository.Create<ILoRaWanConcentratorsClientService>();
this.mockLoRaWanConcentratorsClientService = MockRepository.Create<ILoRaWanConcentratorClientService>();

_ = Services.AddSingleton(this.mockSnackbarService.Object);
_ = Services.AddSingleton(this.mockLoRaWanConcentratorsClientService.Object);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ namespace AzureIoTHub.Portal.Tests.Unit.Client.Services
[TestFixture]
public class LoRaWanConcentratorsClientServiceTests : BlazorUnitTest
{
private ILoRaWanConcentratorsClientService loRaWanConcentratorsClientService;
private ILoRaWanConcentratorClientService loRaWanConcentratorsClientService;

public override void Setup()
{
base.Setup();

_ = Services.AddSingleton<ILoRaWanConcentratorsClientService, LoRaWanConcentratorsClientService>();
_ = Services.AddSingleton<ILoRaWanConcentratorClientService, LoRaWanConcentratorClientService>();

this.loRaWanConcentratorsClientService = Services.GetRequiredService<ILoRaWanConcentratorsClientService>();
this.loRaWanConcentratorsClientService = Services.GetRequiredService<ILoRaWanConcentratorClientService>();
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ namespace AzureIoTHub.Portal.Tests.Unit.Server.Controllers.v1._0
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.AspNetCore.Mvc.Routing;
using Microsoft.AspNetCore.Routing;
using Microsoft.Azure.Devices;
using Microsoft.Azure.Devices.Shared;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Primitives;
using Models.v10;
Expand Down
Loading

0 comments on commit 6d43858

Please sign in to comment.