Skip to content

Commit

Permalink
fixed ocasional bugs + unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joao4all committed Jul 29, 2024
1 parent de4cdfb commit 9a97a13
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,21 +123,31 @@ public void Setup()
mockConfigurationService.Setup(x => x.ServerConfiguration).Returns(new ServerConfiguration());
this.messageBus = new CDPMessageBus();

var parameterTableViewModel = new Mock<IParameterTableViewModel>();
parameterTableViewModel.Setup(x => x.Rows).Returns(new SourceList<ParameterBaseRowViewModel>());

var parameterEditorBodyViewModel = new Mock<IParameterEditorBodyViewModel>();
parameterEditorBodyViewModel.Setup(x => x.OptionSelector).Returns(new Mock<IOptionSelectorViewModel>().Object);
parameterEditorBodyViewModel.Setup(x => x.BatchParameterEditorViewModel).Returns(new Mock<IBatchParameterEditorViewModel>().Object);
parameterEditorBodyViewModel.Setup(x => x.ParameterTypeSelector).Returns(new Mock<IParameterTypeSelectorViewModel>().Object);
parameterEditorBodyViewModel.Setup(x => x.ElementSelector).Returns(new Mock<IElementBaseSelectorViewModel>().Object);
parameterEditorBodyViewModel.Setup(x => x.ParameterTableViewModel).Returns(parameterTableViewModel.Object);

var configurationService = new Mock<IStringTableService>();
configurationService.Setup(x => x.GetText(It.IsAny<string>())).Returns("something");

this.context.ConfigureDevExpressBlazor();
this.context.Services.AddSingleton(this.viewModel);
this.context.Services.AddSingleton(this.sessionService.Object);
this.context.Services.AddSingleton(this.messageBus);
this.context.Services.AddSingleton(mockConfigurationService.Object);
this.context.Services.AddSingleton(parameterEditorBodyViewModel.Object);
this.context.Services.AddSingleton(parameterTableViewModel.Object);
this.context.Services.AddSingleton(configurationService.Object);
this.context.Services.AddSingleton<IOpenModelViewModel, OpenModelViewModel>();
this.context.Services.AddSingleton<IParameterEditorBodyViewModel, ParameterEditorBodyViewModel>();
this.context.Services.AddSingleton<IBatchParameterEditorViewModel, BatchParameterEditorViewModel>();
this.context.Services.AddSingleton<ISubscriptionService, SubscriptionService>();
this.context.Services.AddSingleton<IParameterTableViewModel, ParameterTableViewModel>();
this.context.Services.AddSingleton<INotificationService, NotificationService>();
this.context.Services.AddSingleton(mockConfigurationService.Object);
this.context.Services.AddSingleton(this.messageBus);

var configurationService = new Mock<IStringTableService>();
configurationService.Setup(x => x.GetText(It.IsAny<string>())).Returns("something");
this.context.Services.AddSingleton(configurationService.Object);
}

[TearDown]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ protected override void OnViewModelAssigned()
{
base.OnViewModelAssigned();

this.Disposables.Add(this.WhenAnyValue(x => x.ViewModel.OptionSelector.SelectedOption,
this.Disposables.Add(this.WhenAnyValue(
x => x.ViewModel.OptionSelector.SelectedOption,
x => x.ViewModel.ParameterTypeSelector.SelectedParameterType,
x => x.ViewModel.ElementSelector.SelectedElementBase,
x => x.ViewModel.IsOwnedParameters)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,12 @@ public ParameterEditorBodyViewModel(ISessionService sessionService, ISubscriptio
this.ParameterTableViewModel = parameterTableView;
this.BatchParameterEditorViewModel = batchParameterEditorViewModel;

this.Disposables.Add(this.WhenAnyValue(x => x.ElementSelector.SelectedElementBase,
this.Disposables.Add(this.WhenAnyValue(
x => x.ElementSelector.SelectedElementBase,
x => x.OptionSelector.SelectedOption,
x => x.ParameterTypeSelector.SelectedParameterType,
x => x.IsOwnedParameters).SubscribeAsync(_ => this.ApplyFilters()));
x => x.IsOwnedParameters)
.SubscribeAsync(_ => this.ApplyFilters()));

this.InitializeSubscriptions(ObjectChangedTypesOfInterest);
this.RegisterViewModelsWithReusableRows([this.ParameterTableViewModel]);
Expand Down Expand Up @@ -173,20 +175,19 @@ protected override async Task OnThingChanged()
{
await base.OnThingChanged();

this.IsLoading = true;

if (!this.HasSetInitialValuesOnce)
{
this.IsLoading = true;

this.IsOwnedParameters = true;
this.ElementSelector.CurrentIteration = this.CurrentThing;
this.OptionSelector.CurrentIteration = this.CurrentThing;
this.ParameterTypeSelector.CurrentIteration = this.CurrentThing;
this.BatchParameterEditorViewModel.CurrentIteration = this.CurrentThing;
this.ParameterTableViewModel.InitializeViewModel(this.CurrentThing, this.CurrentDomain, this.OptionSelector.SelectedOption);

this.IsLoading = false;
}

this.ParameterTableViewModel.InitializeViewModel(this.CurrentThing, this.CurrentDomain, this.OptionSelector.SelectedOption);
await this.ApplyFilters();
this.IsLoading = false;
}

Expand Down

0 comments on commit 9a97a13

Please sign in to comment.