-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* DO PACKAGE UPGRADE * migrate person view to MudBlazor * migrate edit and listing person * fix residence selector * migrate person listing * add contract page * show tax calculation results * remove Radzen completely --------- Co-authored-by: Dieter Niggeler <dieter.niggeler@swisslife.ch>
- Loading branch information
Showing
131 changed files
with
4,253 additions
and
23,230 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
src/BlazorApp.Components.Tests/BlazorApp.Components.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Razor"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Blazored.LocalStorage.TestExtensions" Version="4.3.0" /> | ||
<PackageReference Include="bunit" Version="1.20.8" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" /> | ||
<PackageReference Include="xunit" Version="2.4.2" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="3.2.0"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\BlazorApp\BlazorApp.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Blazored.LocalStorage; | ||
using Bunit; | ||
|
||
namespace BlazorApp.Components.Tests | ||
{ | ||
public class BrowserStorageTests : TestContext | ||
{ | ||
private readonly ILocalStorageService localStorageService; | ||
|
||
public BrowserStorageTests() | ||
{ | ||
localStorageService = this.AddBlazoredLocalStorage(); | ||
} | ||
|
||
[Fact] | ||
public async Task Successfully_Use_LocalStorage() | ||
{ | ||
// given | ||
string key = "name"; | ||
Guid expectedValue = Guid.NewGuid(); | ||
|
||
// when | ||
await localStorageService.ClearAsync(); | ||
await localStorageService.SetItemAsync(key, expectedValue); | ||
Guid result = await localStorageService.GetItemAsync<Guid>(key); | ||
|
||
// then | ||
Assert.True(result == expectedValue); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
using BlazorApp.Services; | ||
using BlazorApp.ViewModels; | ||
using Bunit; | ||
using PensionCoach.Tools.CommonTypes; | ||
|
||
namespace BlazorApp.Components.Tests; | ||
|
||
public class PersonServiceMockTests : TestContext | ||
{ | ||
public PersonServiceMockTests() | ||
{ | ||
this.AddBlazoredLocalStorage(); | ||
Services.AddMockServices(); | ||
} | ||
|
||
[Fact(DisplayName = "Add New Person")] | ||
public async Task Add_New_Person() | ||
{ | ||
// given | ||
Guid newId = Guid.NewGuid(); | ||
|
||
// when | ||
IPersonService personService = Services.GetService<IPersonService>(); | ||
|
||
PersonViewModel result = await AddNewPersonAsync(personService, newId); | ||
|
||
// then | ||
Assert.True(result is not null); | ||
} | ||
|
||
[Fact(DisplayName = "Delete Person")] | ||
public async Task Delete_Person() | ||
{ | ||
// given | ||
Guid newId = Guid.NewGuid(); | ||
|
||
// when | ||
IPersonService personService = Services.GetService<IPersonService>(); | ||
|
||
await AddNewPersonAsync(personService, newId); | ||
|
||
await personService.DeletePersonAsync(newId); | ||
|
||
var result = await personService.GetAsync(newId); | ||
|
||
// then | ||
Assert.True(result is null); | ||
} | ||
|
||
[Fact(DisplayName = "Edit and Save Person")] | ||
public async Task Edit_And_Save_Person() | ||
{ | ||
// given | ||
Guid newId = Guid.NewGuid(); | ||
DateTime birthday = new DateTime(1966, 2, 10); | ||
|
||
// when | ||
IPersonService personService = Services.GetService<IPersonService>(); | ||
|
||
PersonViewModel newPerson = await AddNewPersonAsync(personService, newId); | ||
newPerson.DateOfBirth = birthday; | ||
await personService.UpdateAsync(newPerson); | ||
|
||
PersonViewModel result = await personService.GetAsync(newId); | ||
|
||
// then | ||
Assert.True(result.DateOfBirth == birthday); | ||
} | ||
|
||
private async Task<PersonViewModel> AddNewPersonAsync(IPersonService personService, Guid id) | ||
{ | ||
PersonViewModel newPerson = CreatePerson(id); | ||
await personService.AddAsync(newPerson); | ||
|
||
return await personService.GetAsync(id); | ||
} | ||
|
||
private PersonViewModel CreatePerson(Guid id) | ||
{ | ||
return new PersonViewModel | ||
{ | ||
Id = id, | ||
Name = "Tester 1", | ||
DateOfBirth = new DateTime(1990, 11, 11), | ||
Gender = Gender.Male, | ||
CivilStatus = CivilStatus.Single, | ||
BfsMunicipalityId = 136, | ||
Canton = Canton.ZH, | ||
MunicipalityName = "Langnau aA", | ||
NumberOfChildren = 0, | ||
ReligiousGroupType = ReligiousGroupType.Protestant, | ||
TaxableIncome = 100_000, | ||
TaxableWealth = 500_000, | ||
FinalCapital3a = 150_000, | ||
FinalRetirementCapital = 500_000 | ||
}; | ||
} | ||
} |
98 changes: 98 additions & 0 deletions
98
src/BlazorApp.Components.Tests/PersonServiceWithBrowserStorageTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
using BlazorApp.Services; | ||
using BlazorApp.ViewModels; | ||
using Bunit; | ||
using PensionCoach.Tools.CommonTypes; | ||
|
||
namespace BlazorApp.Components.Tests; | ||
|
||
public class PersonServiceWithBrowserStorageTests : TestContext | ||
{ | ||
public PersonServiceWithBrowserStorageTests() | ||
{ | ||
this.AddBlazoredLocalStorage(null); | ||
Services.AddServices(); | ||
} | ||
|
||
[Fact(DisplayName = "Add New Person")] | ||
public async Task Add_New_Person() | ||
{ | ||
// given | ||
Guid newId = Guid.NewGuid(); | ||
|
||
// when | ||
IPersonService personService = Services.GetService<IPersonService>(); | ||
|
||
PersonViewModel result = await AddNewPersonAsync(personService, newId); | ||
|
||
// then | ||
Assert.True(result is not null); | ||
} | ||
|
||
[Fact(DisplayName = "Delete Person")] | ||
public async Task Delete_Person() | ||
{ | ||
// given | ||
Guid newId = Guid.NewGuid(); | ||
|
||
// when | ||
IPersonService personService = Services.GetService<IPersonService>(); | ||
|
||
await AddNewPersonAsync(personService, newId); | ||
|
||
await personService.DeletePersonAsync(newId); | ||
|
||
var result = await personService.GetAsync(newId); | ||
|
||
// then | ||
Assert.True(result is null); | ||
} | ||
|
||
[Fact(DisplayName = "Edit and Save Person")] | ||
public async Task Edit_And_Save_Person() | ||
{ | ||
// given | ||
Guid newId = Guid.NewGuid(); | ||
DateTime birthday = new DateTime(1966, 2, 10); | ||
|
||
// when | ||
IPersonService personService = Services.GetService<IPersonService>(); | ||
|
||
PersonViewModel newPerson = await AddNewPersonAsync(personService, newId); | ||
newPerson.DateOfBirth = birthday; | ||
await personService.UpdateAsync(newPerson); | ||
|
||
PersonViewModel result = await personService.GetAsync(newId); | ||
|
||
// then | ||
Assert.True(result.DateOfBirth == birthday); | ||
} | ||
|
||
private async Task<PersonViewModel> AddNewPersonAsync(IPersonService personService, Guid id) | ||
{ | ||
PersonViewModel newPerson = CreatePerson(id); | ||
await personService.AddAsync(newPerson); | ||
|
||
return await personService.GetAsync(id); | ||
} | ||
|
||
private PersonViewModel CreatePerson(Guid id) | ||
{ | ||
return new PersonViewModel | ||
{ | ||
Id = id, | ||
Name = "Tester 1", | ||
DateOfBirth = new DateTime(1990, 11, 11), | ||
Gender = Gender.Male, | ||
CivilStatus = CivilStatus.Single, | ||
BfsMunicipalityId = 136, | ||
Canton = Canton.ZH, | ||
MunicipalityName = "Langnau aA", | ||
NumberOfChildren = 0, | ||
ReligiousGroupType = ReligiousGroupType.Protestant, | ||
TaxableIncome = 100_000, | ||
TaxableWealth = 500_000, | ||
FinalCapital3a = 150_000, | ||
FinalRetirementCapital = 500_000 | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
global using Xunit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
@using PensionCoach.Tools.CommonTypes | ||
@using PensionCoach.Tools.CommonTypes.Tax | ||
|
||
<MudSelect T="Canton" Label="@Label" ReadOnly="@IsReadOnly" Value="@CantonCode" ValueChanged="HandleCantonChange"> | ||
@foreach (var m in cantons) | ||
{ | ||
<MudSelectItem Value="m.Canton">@m.Name</MudSelectItem> | ||
} | ||
</MudSelect> | ||
|
||
|
||
@code { | ||
|
||
internal record CantonHolder | ||
{ | ||
public Canton Canton { get; init; } | ||
public string Name { get; init; } | ||
} | ||
|
||
[Parameter] | ||
public bool IsReadOnly { get; set; } | ||
|
||
[Parameter] | ||
public string Label { get; set; } | ||
|
||
[Parameter] | ||
public Canton CantonCode { get; set; } | ||
|
||
[Parameter] | ||
public EventCallback<Canton> OnSelected { get; set; } | ||
|
||
private List<CantonHolder> cantons = new(); | ||
|
||
protected override void OnInitialized() | ||
{ | ||
cantons = Enum.GetValues(typeof(Canton)) | ||
.Cast<Canton>() | ||
.Select(c => new CantonHolder { Canton = c, Name = c.ToString() }) | ||
.ToList(); | ||
} | ||
|
||
private async Task HandleCantonChange(Canton value) | ||
{ | ||
CantonCode = value; | ||
|
||
await OnSelected.InvokeAsync(CantonCode); | ||
} | ||
} |
Oops, something went wrong.