1@using Escali.LicenseControl.Client.Components
2@using Escali.LicenseControl.Client.Utils
4@using Microsoft.AspNetCore.Http
7@inject AlertService _alertService
8@inject IComponent _componentBase
9@inject StateService _stateService
10@inject UserViewModel _userViewModel
14 private void AddServices()
16 Services.AddDbContext<DataContext>();
17 Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
18 Services.AddScoped<StateService>();
19 Services.AddScoped<AlertService>();
21 Services.AddScoped<CurrencyViewModel>();
22 Services.AddScoped<ProductViewModel>();
23 Services.AddScoped<ModuleViewModel>();
24 Services.AddScoped<SegmentViewModel>();
25 Services.AddScoped<MainSegmentViewModel>();
26 Services.AddScoped<PriceListViewModel>();
27 Services.AddScoped<UserViewModel>();
28 Services.AddScoped<CustomerViewModel>();
29 Services.AddScoped<PriorityViewModel>();
30 Services.AddScoped<RegionViewModel>();
31 Services.AddScoped<PriceElementViewModel>();
32 Services.AddScoped<AgreementViewModel>();
33 Services.AddScoped<AgreementElementViewModel>();
34 Services.AddScoped<ModuleLevelViewModel>();
37 public void DropdownComponent_RenderSuccessfully()
39 var component = Render(@<Dropdown />
41 component.Find($".dropdown");
44 private (string, Action)[] CreateDropdownOptions(string context)
46 return new (string, Action)[] {
47 ("Oppdater modul", () => Console.WriteLine(context)),
52 public void DropdownComponentAdded_RenderSuccessfully()
54 string hello = "hello";
55 var component = RenderComponent<Dropdown>(parameters => parameters
56 .Add(p => p.Options, CreateDropdownOptions(hello))
59 component.FindAll("div").Count().Equals(3);
63 public void HeaderComponent_RenderSuccessfully()
67 var component = Render(
70 component.Find($".header");
74 public void StandardModalComponent_RenderSuccessfully()
76 var component = Render(
77 @<StandardModal ShowModal="true" Header="first" HeaderSecond="second" SubmitButtonName="submit"/>
79 component.Find($".modal-dialog");
83 public void StandardModalComponent_RenderSuccessfully_ButShowModalIsFalse()
85 var component = Render(
86 @<StandardModal ShowModal="false" />
89 component.MarkupMatches(string.Empty);
93 public void HeaderUserButtonComponent_RenderSuccessfully()
96 var component = Render(
99 component.Find($".button-menu-group");
103 public void HeaderUserButtonComponent_WithUsersList_RenderSuccessfully()
106 var options = new DbContextOptionsBuilder<DataContext>().UseInMemoryDatabase(databaseName: "db")
109 using(var context = new DataContext(options))
111 context.Users.Add(new User { UserEmail = "user@user.com", UserConsulentName="user" });
112 context.Users.Add(new User { UserEmail = "simen@user.com", UserConsulentName="simen" });
113 context.SaveChanges();
116 using(var context = new DataContext(options))
118 var component = Render(@<HeaderUserButton />
120 component.FindAll("option").Count().Equals(3);
121 Assert.NotNull(context.Users);
126 public void TooltipComponent_RenderSuccessfully()
128 var component = Render(
131 component.Find($".tooltip");