3@using Escali.LicenseControl.Client.Components.IndexPageComponents
7 /// Creates an In Memory Database.
9 /// <returns>DataContext</returns>
10 private async Task<DataContext> GetDatabaseContext()
12 var options = new DbContextOptionsBuilder<DataContext>()
13 .UseInMemoryDatabase(databaseName: "TestDb")
15 var dataContext = new DataContext(options);
16 dataContext.Database.EnsureCreated();
22 /// Adds services to IServiceCollection for testing.
24 private void AddServices()
26 Services.AddDbContext<DataContext>();
27 Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
28 Services.AddScoped<StateService>();
29 Services.AddScoped<AlertService>();
30 Services.AddScoped<UserViewModel>();
31 Services.AddScoped<CustomerViewModel>();
35 /// Adds Services and creates a List<UserViewModel> and adds to component.
36 /// Will pass if LeaderBoard-component finds LeaderBoardContent-component
37 /// and css-tags are found (if not found list is null or empty)
40 public void IndexPage_LeaderBoardIsRenderingSuccessfully_WithListUsers()
43 var list = new List<UserClientModel>()
47 UserEmail="user@user.com"
51 UserEmail="rune@user.com"
55 UserEmail="simen@user.com"
59 UserEmail="man@user.com"
62 var component = Render(
64 component.FindComponent<LeaderBoardContent>();
66 var contentComponent = Render(@<LeaderBoardContent ListUsers="list"/>
68 contentComponent.Find($".leaderboard-first");
69 contentComponent.Find($".leaderboard-rest");
73 /// Renders the LeaderBoardContent-component without list.
74 /// Will pass if markup matching.
77 public void IndexPage_LeaderBoardIsNotRenderingSuccessfully_WithoutList()
79 var component = Render(
80 @<LeaderBoardContent />);
81 component.MarkupMatches(@<p>Loading ...</p>);