Skip to content

Commit

Permalink
solved some sonarqube issues
Browse files Browse the repository at this point in the history
  • Loading branch information
joao4all committed Jun 19, 2024
1 parent e1eb940 commit 41916dc
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 25 deletions.
4 changes: 2 additions & 2 deletions COMET.Web.Common.Tests/Components/OpenModelTestFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace COMET.Web.Common.Tests.Components
[TestFixture]
public class OpenModelTestFixture
{
private IOpenModelViewModel viewModel;
private OpenModelViewModel viewModel;
private TestContext context;
private Mock<ISessionService> sessionService;
private Mock<IConfigurationService> configurationService;
Expand All @@ -66,7 +66,7 @@ public void Setup()
this.configurationService = new Mock<IConfigurationService>();
this.viewModel = new OpenModelViewModel(this.sessionService.Object, this.configurationService.Object);
this.context.ConfigureDevExpressBlazor();
this.context.Services.AddSingleton(this.viewModel);
this.context.Services.AddSingleton<IOpenModelViewModel>(this.viewModel);

var stringTableService = new Mock<IStringTableService>();
this.context.Services.AddSingleton(stringTableService.Object);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace COMET.Web.Common.Tests.ViewModels.Components.ParameterEditors
[TestFixture]
public class ParameterTypeEditorSelectorViewModelTestFixture
{
private IParameterTypeEditorSelectorViewModel viewModel;
private ParameterTypeEditorSelectorViewModel viewModel;
private CDPMessageBus messageBus;

private IParameterEditorBaseViewModel<T> CreateParameterEditorViewModel<T>() where T : ParameterType, new()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public class ModelDashboardBodyTestFixture
private TestContext context;
private ModelDashboardBodyViewModel viewModel;
private Mock<ISessionService> sessionService;
private ICDPMessageBus messageBus;
private CDPMessageBus messageBus;

[SetUp]
public void Setup()
Expand All @@ -85,7 +85,7 @@ public void Setup()
var configuration = new Mock<IConfigurationService>();
configuration.Setup(x => x.ServerConfiguration).Returns(new ServerConfiguration());
this.context.Services.AddSingleton(configuration.Object);
this.context.Services.AddSingleton(this.messageBus);
this.context.Services.AddSingleton<ICDPMessageBus>(this.messageBus);
this.viewModel = this.context.Services.GetService<IModelDashboardBodyViewModel>() as ModelDashboardBodyViewModel;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ namespace COMETwebapp.Tests.Components.ReferenceData
using CDP4Dal.Events;
using CDP4Dal.Permission;

using CDP4Web.Enumerations;

using COMET.Web.Common.Model;
using COMET.Web.Common.Services.SessionManagement;
using COMET.Web.Common.Test.Helpers;
Expand All @@ -64,7 +62,7 @@ namespace COMETwebapp.Tests.Components.ReferenceData
public class CategoriesTableTestFixture
{
private TestContext context;
private ICategoriesTableViewModel viewModel;
private CategoriesTableViewModel viewModel;
private Mock<ISession> session;
private Mock<IPermissionService> permissionService;
private Mock<ISessionService> sessionService;
Expand Down Expand Up @@ -117,7 +115,7 @@ public void SetUp()

this.viewModel = new CategoriesTableViewModel(this.sessionService.Object, this.showHideDeprecatedThingsService.Object, this.messageBus, this.logger.Object);

this.context.Services.AddSingleton(this.viewModel);
this.context.Services.AddSingleton<ICategoriesTableViewModel>(this.viewModel);

this.person = new Person(Guid.NewGuid(), this.assembler.Cache, this.uri)
{
Expand Down Expand Up @@ -362,20 +360,6 @@ public async Task VerifyAddOrEditCategory()
this.messageBus.SendMessage(new SessionEvent(null, SessionStatus.EndUpdate));
}

[Test]
public async Task VerifyOnInitialized()
{
var renderer = this.context.RenderComponent<CategoriesTable>();

await TaskHelper.WaitWhileAsync(() => this.viewModel.IsLoading);

Assert.Multiple(() =>
{
Assert.That(renderer.Markup, Does.Contain(this.elementDefinitionCategory1.Name));
Assert.That(renderer.Markup, Does.Contain(this.elementDefinitionCategory2.Name));
});
}

[Test]
public async Task VerifyGridActions()
{
Expand Down Expand Up @@ -405,5 +389,19 @@ public async Task VerifyGridActions()

this.sessionService.Verify(x => x.CreateOrUpdateThingsWithNotification(It.IsAny<Thing>(), It.IsAny<IReadOnlyCollection<Thing>>(), It.IsAny<NotificationDescription>()), Times.Once);
}

[Test]
public async Task VerifyOnInitialized()
{
var renderer = this.context.RenderComponent<CategoriesTable>();

await TaskHelper.WaitWhileAsync(() => this.viewModel.IsLoading);

Assert.Multiple(() =>
{
Assert.That(renderer.Markup, Does.Contain(this.elementDefinitionCategory1.Name));
Assert.That(renderer.Markup, Does.Contain(this.elementDefinitionCategory2.Name));
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace COMETwebapp.Tests.Components.SystemRepresentation
public class SystemRepresentationPageTestFixture
{
private TestContext context;
private ISystemRepresentationBodyViewModel viewModel;
private SystemRepresentationBodyViewModel viewModel;
private Mock<ISession> session;
private Mock<ISessionService> sessionService;
private Assembler assembler;
Expand Down Expand Up @@ -100,7 +100,7 @@ public void SetUp()
this.domain = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri);

this.viewModel = new SystemRepresentationBodyViewModel(this.sessionService.Object, this.messageBus);
this.context.Services.AddSingleton(this.viewModel);
this.context.Services.AddSingleton<ISystemRepresentationBodyViewModel>(this.viewModel);

this.person = new Person(Guid.NewGuid(), this.assembler.Cache, this.uri);

Expand Down

0 comments on commit 41916dc

Please sign in to comment.