Converting Tests back to C# but still with Playwright
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
@implements IDisposable;
|
||||
|
||||
@inject IMemoryTesterService MemoryTesterService;
|
||||
|
||||
<div class="quizContainer">
|
||||
<div class="quizListContainer">
|
||||
@if (entities != null && questions != null)
|
||||
{
|
||||
@foreach (var entityMemory in entities)
|
||||
{
|
||||
<UnitMemory EntityMemory="entityMemory"></UnitMemory>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="quizButtons">
|
||||
<ButtonComponent MyButtonType="MyButtonType.Secondary" OnClick="OnRefreshQuiz">Refresh</ButtonComponent>
|
||||
<ButtonComponent MyButtonType="MyButtonType.Primary" OnClick="OnSubmitQuiz">Submit</ButtonComponent>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.quizContainer {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.quizListContainer {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
@@media (min-width: @SupportedWebSizes.Tablet) {
|
||||
.quizContainer {
|
||||
}
|
||||
|
||||
.quizButtons {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 16px;
|
||||
justify-content: flex-end;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.quizListContainer {
|
||||
}
|
||||
}
|
||||
|
||||
@@media (min-width: @SupportedWebSizes.Desktop) {
|
||||
.quizListContainer {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
@code {
|
||||
private List<MemoryEntityModel> entities = null!;
|
||||
private List<MemoryQuestionModel> questions = null!;
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
base.OnInitialized();
|
||||
MemoryTesterService.Subscribe(OnMemoryEvent);
|
||||
|
||||
MemoryTesterService.GenerateQuiz();
|
||||
}
|
||||
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
MemoryTesterService.Unsubscribe(OnMemoryEvent);
|
||||
}
|
||||
|
||||
void OnMemoryEvent(MemoryTesterEvent memoryTesterEvent)
|
||||
{
|
||||
if (memoryTesterEvent == MemoryTesterEvent.OnVerify)
|
||||
{
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
if (memoryTesterEvent == MemoryTesterEvent.OnRefresh)
|
||||
{
|
||||
entities = MemoryTesterService.GetEntities();
|
||||
questions = MemoryTesterService.GetQuestions();
|
||||
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void OnSubmitQuiz(EventArgs eventArgs)
|
||||
{
|
||||
MemoryTesterService.Verify();
|
||||
}
|
||||
|
||||
void OnRefreshQuiz(EventArgs eventArgs)
|
||||
{
|
||||
MemoryTesterService.GenerateQuiz();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user