forked from microsoft/aspire
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMetricsViewModelTests.cs
More file actions
44 lines (39 loc) · 2.29 KB
/
MetricsViewModelTests.cs
File metadata and controls
44 lines (39 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Aspire.Dashboard.Model;
using Aspire.Dashboard.Otlp.Model;
using Xunit;
using static Aspire.Dashboard.Components.Pages.Metrics;
namespace Aspire.Dashboard.Components.Tests.Pages;
public sealed class MetricsViewModelTests
{
[Fact]
public void IsDashpageAvailable()
{
OtlpInstrument instrument = new()
{
Name = "present-instrument",
Description = "",
Options = null!,
Parent = null!,
Type = OtlpInstrumentType.Histogram,
Unit = null!
};
MetricsViewModel vm = new()
{
Dashpages = [],
SelectedDuration = null!,
SelectedViewKind = MetricViewKind.Graph,
SelectedApplication = new() { Id = ResourceTypeDetails.CreateSingleton("my-instance", "my-replica-set"), Name = "" },
Instruments = [instrument],
ApplicationNames = ["present-application"],
};
Assert.True(vm.IsDashpageAvailable(new() { Name = "", Charts = [new() { InstrumentName = "present-instrument", Title = "" }] }));
Assert.True(vm.IsDashpageAvailable(new() { Name = "", Charts = [new() { InstrumentName = "present-instrument", Title = "", ResourceName = "present-application" }] }));
Assert.False(vm.IsDashpageAvailable(new() { Name = "", Charts = [new() { InstrumentName = "present-instrument", Title = "", ResourceName = "absent-application" }] }));
Assert.True(vm.IsDashpageAvailable(new() { Name = "", Charts = [new() { InstrumentName = "present-instrument", Title = "" }, new() { InstrumentName = "absent-instrument", Title = "" }] }));
Assert.False(vm.IsDashpageAvailable(new() { Name = "", Charts = [new() { InstrumentName = "absent-instrument", Title = "" }] }));
Assert.False(vm.IsDashpageAvailable(new() { Name = "", Charts = [new() { InstrumentName = "absent-instrument", Title = "" }, new() { InstrumentName = "absent-instrument", Title = "" }] }));
Assert.False(vm.IsDashpageAvailable(new() { Name = "", Charts = [new() { InstrumentName = "present-instrument", Title = "" }, new() { InstrumentName = "absent-instrument", Title = "", IsRequired = true }] }));
}
}