Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework device models/command controllers to use database #1226 #1241

Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (c) CGI France. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace AzureIoTHub.Portal.Infrastructure.Repositories
{
using AzureIoTHub.Portal.Domain.Repositories;
using Domain.Entities;

public class DeviceModelCommandRepository : GenericRepository<DeviceModelCommand>, IDeviceModelCommandRepository
{
public DeviceModelCommandRepository(PortalDbContext context) : base(context)
{
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (c) CGI France. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace AzureIoTHub.Portal.Infrastructure.Repositories
{
using AzureIoTHub.Portal.Domain.Repositories;
using Domain.Entities;

public class DeviceModelRepository : GenericRepository<DeviceModel>, IDeviceModelRepository
{
public DeviceModelRepository(PortalDbContext context) : base(context)
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void DeviceConfigurationDetailPageShouldRenderCorrectly()

_ = this.mockDeviceModelsClientService.Setup(service =>
service.GetDeviceModels())
.ReturnsAsync(new List<DeviceModel>());
.ReturnsAsync(new List<DeviceModelDto>());

_ = this.mockDeviceTagSettingsClientService.Setup(service =>
service.GetDeviceTags())
Expand Down Expand Up @@ -80,7 +80,7 @@ public void DeviceConfigurationDetailShouldCreateConfiguration()

_ = this.mockDeviceModelsClientService.Setup(service =>
service.GetDeviceModels())
.ReturnsAsync(new List<DeviceModel>());
.ReturnsAsync(new List<DeviceModelDto>());

_ = this.mockDeviceTagSettingsClientService.Setup(service =>
service.GetDeviceTags())
Expand Down Expand Up @@ -116,7 +116,7 @@ public void DeviceConfigurationDetailShouldProcessProblemDetailsExceptionWhenIss

_ = this.mockDeviceModelsClientService.Setup(service =>
service.GetDeviceModels())
.ReturnsAsync(new List<DeviceModel>());
.ReturnsAsync(new List<DeviceModelDto>());

_ = this.mockDeviceTagSettingsClientService.Setup(service =>
service.GetDeviceTags())
Expand Down Expand Up @@ -158,7 +158,7 @@ public void DeviceConfigurationDetailPageShouldProcessProblemDetailsExceptionWhe
// Arrange
_ = this.mockDeviceModelsClientService.Setup(service =>
service.GetDeviceModels())
.ReturnsAsync(new List<DeviceModel>());
.ReturnsAsync(new List<DeviceModelDto>());

_ = this.mockDeviceTagSettingsClientService.Setup(service =>
service.GetDeviceTags())
Expand All @@ -177,7 +177,7 @@ public void WhenClickToDeleteTagShouldRemoveTheSelectedTag()
// Arrange
_ = this.mockDeviceModelsClientService.Setup(service =>
service.GetDeviceModels())
.ReturnsAsync(new List<DeviceModel>());
.ReturnsAsync(new List<DeviceModelDto>());

_ = this.mockDeviceTagSettingsClientService.Setup(service =>
service.GetDeviceTags())
Expand Down Expand Up @@ -213,7 +213,7 @@ public void WhenClickToAddTagShouldAddTheSelectedTag()

_ = this.mockDeviceModelsClientService.Setup(service =>
service.GetDeviceModels())
.ReturnsAsync(new List<DeviceModel>
.ReturnsAsync(new List<DeviceModelDto>
{
new ()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void DeviceConfigurationDetailPageShouldRenderCorrectly()

_ = this.mockDeviceModelsClientService.Setup(service =>
service.GetDeviceModel(It.Is<string>(s => modelId.Equals(s, StringComparison.Ordinal))))
.ReturnsAsync(new DeviceModel
.ReturnsAsync(new DeviceModelDto
{
ModelId = modelId,
Name = Guid.NewGuid().ToString()
Expand Down Expand Up @@ -140,7 +140,7 @@ public void ClickOnDeleteDeviceConfigurationShouldShowDeleteDialog()

_ = this.mockDeviceModelsClientService.Setup(service =>
service.GetDeviceModel(It.Is<string>(s => modelId.Equals(s, StringComparison.Ordinal))))
.ReturnsAsync(new DeviceModel
.ReturnsAsync(new DeviceModelDto
{
ModelId = modelId,
Name = Guid.NewGuid().ToString()
Expand Down Expand Up @@ -176,7 +176,7 @@ public void DeviceConfigurationDetailPageShouldRenderCardCorrectly()
var configurationId = Guid.NewGuid().ToString();
var modelId = Guid.NewGuid().ToString();

var model = new DeviceModel
var model = new DeviceModelDto
{
ModelId = modelId,
Name = Guid.NewGuid().ToString()
Expand Down Expand Up @@ -267,7 +267,7 @@ public void DeviceConfigurationDetailPageShouldRenderTags()

_ = this.mockDeviceModelsClientService.Setup(service =>
service.GetDeviceModel(It.Is<string>(s => modelId.Equals(s, StringComparison.Ordinal))))
.ReturnsAsync(new DeviceModel
.ReturnsAsync(new DeviceModelDto
{
ModelId = modelId,
Name = Guid.NewGuid().ToString()
Expand Down Expand Up @@ -324,7 +324,7 @@ public void WhenClickToDeleteTagShouldRemoveTheSelectedTag()

_ = this.mockDeviceModelsClientService.Setup(service =>
service.GetDeviceModel(It.Is<string>(s => modelId.Equals(s, StringComparison.Ordinal))))
.ReturnsAsync(new DeviceModel
.ReturnsAsync(new DeviceModelDto
{
ModelId = modelId,
Name = Guid.NewGuid().ToString()
Expand Down Expand Up @@ -385,7 +385,7 @@ public void WhenClickToAddTagShouldAddTheSelectedTag()

_ = this.mockDeviceModelsClientService.Setup(service =>
service.GetDeviceModel(It.Is<string>(s => modelId.Equals(s, StringComparison.Ordinal))))
.ReturnsAsync(new DeviceModel
.ReturnsAsync(new DeviceModelDto
{
ModelId = modelId,
Name = Guid.NewGuid().ToString()
Expand Down Expand Up @@ -451,7 +451,7 @@ public void DeviceConfigurationDetailPageShouldRenderProperties()

_ = this.mockDeviceModelsClientService.Setup(service =>
service.GetDeviceModel(It.Is<string>(s => modelId.Equals(s, StringComparison.Ordinal))))
.ReturnsAsync(new DeviceModel
.ReturnsAsync(new DeviceModelDto
{
ModelId = modelId,
Name = Guid.NewGuid().ToString()
Expand Down Expand Up @@ -535,7 +535,7 @@ public void WhenClickToDeletePropertyShouldRemoveTheSelectedProperty()

_ = this.mockDeviceModelsClientService.Setup(service =>
service.GetDeviceModel(It.Is<string>(s => modelId.Equals(s, StringComparison.Ordinal))))
.ReturnsAsync(new DeviceModel
.ReturnsAsync(new DeviceModelDto
{
ModelId = modelId,
Name = Guid.NewGuid().ToString()
Expand Down Expand Up @@ -617,7 +617,7 @@ public void WhenClickToAddPropertyShouldAddTheSelectedProperty()

_ = this.mockDeviceModelsClientService.Setup(service =>
service.GetDeviceModel(It.Is<string>(s => modelId.Equals(s, StringComparison.Ordinal))))
.ReturnsAsync(new DeviceModel
.ReturnsAsync(new DeviceModelDto
{
ModelId = modelId,
Name = Guid.NewGuid().ToString()
Expand Down Expand Up @@ -704,7 +704,7 @@ public void WhenClickToSaveShouldSendPutToTheEndpoint()

_ = this.mockDeviceModelsClientService.Setup(service =>
service.GetDeviceModel(It.Is<string>(s => modelId.Equals(s, StringComparison.Ordinal))))
.ReturnsAsync(new DeviceModel
.ReturnsAsync(new DeviceModelDto
{
ModelId = modelId,
Name = Guid.NewGuid().ToString()
Expand Down Expand Up @@ -797,7 +797,7 @@ public void DeviceConfigurationDetailPageShouldProcessProblemDetailsExceptionWhe

_ = this.mockDeviceModelsClientService.Setup(service =>
service.GetDeviceModel(It.Is<string>(s => modelId.Equals(s, StringComparison.Ordinal))))
.ReturnsAsync(new DeviceModel
.ReturnsAsync(new DeviceModelDto
{
ModelId = modelId,
Name = Guid.NewGuid().ToString()
Expand Down Expand Up @@ -887,7 +887,7 @@ public void ReturnButtonMustNavigateToPreviousPage()

_ = this.mockDeviceModelsClientService.Setup(service =>
service.GetDeviceModel(It.Is<string>(s => modelId.Equals(s, StringComparison.Ordinal))))
.ReturnsAsync(new DeviceModel
.ReturnsAsync(new DeviceModelDto
{
ModelId = modelId,
Name = Guid.NewGuid().ToString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public override void Setup()
[Test]
public async Task ClickOnSaveShouldPostDeviceDetailsAsync()
{
var mockDeviceModel = new DeviceModel
var mockDeviceModel = new DeviceModelDto
{
ModelId = Guid.NewGuid().ToString(),
Description = Guid.NewGuid().ToString(),
Expand All @@ -81,7 +81,7 @@ public async Task ClickOnSaveShouldPostDeviceDetailsAsync()
.Returns(Task.CompletedTask);

_ = this.mockDeviceModelsClientService.Setup(service => service.GetDeviceModels())
.ReturnsAsync(new List<DeviceModel>
.ReturnsAsync(new List<DeviceModelDto>
{
mockDeviceModel
});
Expand Down Expand Up @@ -124,7 +124,7 @@ public async Task ClickOnSaveShouldPostDeviceDetailsAsync()
[Test]
public async Task DeviceShouldNotBeCreatedWhenModelIsNotValid()
{
var mockDeviceModel = new DeviceModel
var mockDeviceModel = new DeviceModelDto
{
ModelId = Guid.NewGuid().ToString(),
Description = Guid.NewGuid().ToString(),
Expand All @@ -133,7 +133,7 @@ public async Task DeviceShouldNotBeCreatedWhenModelIsNotValid()
};

_ = this.mockDeviceModelsClientService.Setup(service => service.GetDeviceModels())
.ReturnsAsync(new List<DeviceModel>
.ReturnsAsync(new List<DeviceModelDto>
{
mockDeviceModel
});
Expand Down Expand Up @@ -171,7 +171,7 @@ public async Task DeviceShouldNotBeCreatedWhenModelIsNotValid()
[Test]
public void OnInitializedAsyncShouldProcessProblemDetailsExceptionWhenIssueOccursOnGettingDeviceTags()
{
var mockDeviceModel = new DeviceModel
var mockDeviceModel = new DeviceModelDto
{
ModelId = Guid.NewGuid().ToString(),
Description = Guid.NewGuid().ToString(),
Expand All @@ -180,7 +180,7 @@ public void OnInitializedAsyncShouldProcessProblemDetailsExceptionWhenIssueOccur
};

_ = this.mockDeviceModelsClientService.Setup(service => service.GetDeviceModels())
.ReturnsAsync(new List<DeviceModel>
.ReturnsAsync(new List<DeviceModelDto>
{
mockDeviceModel
});
Expand Down Expand Up @@ -213,7 +213,7 @@ public void OnInitializedAsyncShouldProcessProblemDetailsExceptionWhenIssueOccur
[Test]
public async Task SaveShouldProcessProblemDetailsExceptionWhenIssueOccursOnCreatingDevice()
{
var mockDeviceModel = new DeviceModel
var mockDeviceModel = new DeviceModelDto
{
ModelId = Guid.NewGuid().ToString(),
Description = Guid.NewGuid().ToString(),
Expand All @@ -232,7 +232,7 @@ public async Task SaveShouldProcessProblemDetailsExceptionWhenIssueOccursOnCreat
.ThrowsAsync(new ProblemDetailsException(new ProblemDetailsWithExceptionDetails()));

_ = this.mockDeviceModelsClientService.Setup(service => service.GetDeviceModels())
.ReturnsAsync(new List<DeviceModel>
.ReturnsAsync(new List<DeviceModelDto>
{
mockDeviceModel
});
Expand Down Expand Up @@ -271,7 +271,7 @@ public async Task SaveShouldProcessProblemDetailsExceptionWhenIssueOccursOnCreat
[Test]
public async Task ChangeModelShouldProcessProblemDetailsExceptionWhenIssueOccursOnGettingModelProperties()
{
var mockDeviceModel = new DeviceModel
var mockDeviceModel = new DeviceModelDto
{
ModelId = Guid.NewGuid().ToString(),
Description = Guid.NewGuid().ToString(),
Expand All @@ -287,7 +287,7 @@ public async Task ChangeModelShouldProcessProblemDetailsExceptionWhenIssueOccurs
};

_ = this.mockDeviceModelsClientService.Setup(service => service.GetDeviceModels())
.ReturnsAsync(new List<DeviceModel>
.ReturnsAsync(new List<DeviceModelDto>
{
mockDeviceModel
});
Expand Down Expand Up @@ -322,7 +322,7 @@ public async Task ChangeModelShouldProcessProblemDetailsExceptionWhenIssueOccurs
[Test]
public async Task ClickOnSaveAndAddNewShouldCreateDeviceAndResetCreateDevicePage()
{
var mockDeviceModel = new DeviceModel
var mockDeviceModel = new DeviceModelDto
{
ModelId = Guid.NewGuid().ToString(),
Description = Guid.NewGuid().ToString(),
Expand All @@ -341,7 +341,7 @@ public async Task ClickOnSaveAndAddNewShouldCreateDeviceAndResetCreateDevicePage
.Returns(Task.CompletedTask);

_ = this.mockDeviceModelsClientService.Setup(service => service.GetDeviceModels())
.ReturnsAsync(new List<DeviceModel>
.ReturnsAsync(new List<DeviceModelDto>
{
mockDeviceModel
});
Expand Down Expand Up @@ -398,7 +398,7 @@ public async Task ClickOnSaveAndAddNewShouldCreateDeviceAndResetCreateDevicePage
[Test]
public async Task ClickOnSaveAndDuplicateShouldCreateDeviceAndDuplicateDeviceDetailsInCreateDevicePage()
{
var mockDeviceModel = new DeviceModel
var mockDeviceModel = new DeviceModelDto
{
ModelId = Guid.NewGuid().ToString(),
Description = Guid.NewGuid().ToString(),
Expand All @@ -417,7 +417,7 @@ public async Task ClickOnSaveAndDuplicateShouldCreateDeviceAndDuplicateDeviceDet
.Returns(Task.CompletedTask);

_ = this.mockDeviceModelsClientService.Setup(service => service.GetDeviceModels())
.ReturnsAsync(new List<DeviceModel>
.ReturnsAsync(new List<DeviceModelDto>
{
mockDeviceModel
});
Expand Down
Loading