Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: municipality status for MunicipalityWasImported should be Proposed #418

Merged
merged 2 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ public sealed class MunicipalitySnapshot
public MunicipalitySnapshot(
MunicipalityId municipalityId,
NisCode nisCode,
MunicipalityStatus? municipalityStatus,
MunicipalityStatus municipalityStatus,
IEnumerable<Language> officialLanguages,
IEnumerable<Language> facilityLanguages,
MunicipalityStreetNames streetNames)
{
MunicipalityId = municipalityId;
NisCode = nisCode;
MunicipalityStatus = municipalityStatus?.Status ?? string.Empty;
MunicipalityStatus = municipalityStatus.Status;
OfficialLanguages = officialLanguages;
FacilityLanguages = facilityLanguages;
StreetNames = streetNames.Select(x => new StreetNameData(x)).ToList();
Expand All @@ -48,9 +48,7 @@ private MunicipalitySnapshot(
: this(
new MunicipalityId(municipalityId),
new NisCode(nisCode),
string.IsNullOrEmpty(municipalityStatus)
? null
: StreetNameRegistry.Municipality.MunicipalityStatus.Parse(municipalityStatus),
StreetNameRegistry.Municipality.MunicipalityStatus.Parse(municipalityStatus),
officialLanguages,
facilityLanguages,
new MunicipalityStreetNames())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ private void When(MunicipalityWasImported @event)
{
_municipalityId = new MunicipalityId(@event.MunicipalityId);
_nisCode = new NisCode(@event.NisCode);
MunicipalityStatus = MunicipalityStatus.Proposed;
}

private void When(MunicipalityNisCodeWasChanged @event)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public readonly struct MunicipalityStatus
{
public static readonly MunicipalityStatus Current = new MunicipalityStatus("Current");
public static readonly MunicipalityStatus Retired = new MunicipalityStatus("Retired");
public static readonly MunicipalityStatus Proposed = new MunicipalityStatus("Proposed");

public string Status { get; }

Expand All @@ -14,8 +15,9 @@ public readonly struct MunicipalityStatus
public static MunicipalityStatus Parse(string status)
{
if (status != Retired.Status &&
status != Current.Status)
throw new NotImplementedException($"Cannot parse {status} to {nameof(MunicipalityStatus)}");
status != Current.Status &&
status != Proposed.Status)
throw new NotImplementedException($"Cannot parse '{status}' to {nameof(MunicipalityStatus)}");

return new MunicipalityStatus(status);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void MunicipalityWasImportedIsSavedInSnapshot()

municipalitySnapshot.NisCode.Should().Be(municipalityWasImported.NisCode);
municipalitySnapshot.MunicipalityId.Should().Be(municipalityWasImported.MunicipalityId);
municipalitySnapshot.MunicipalityStatus.Should().BeNullOrEmpty();
municipalitySnapshot.MunicipalityStatus.Should().Be(MunicipalityStatus.Proposed);
municipalitySnapshot.StreetNames.Should().BeEmpty();
municipalitySnapshot.OfficialLanguages.Should().BeEmpty();
municipalitySnapshot.FacilityLanguages.Should().BeEmpty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public void StateCheck()
// Assert
aggregate.MunicipalityId.Should().Be(municipalityId);
aggregate.NisCode.Should().Be(nisCode);
aggregate.MunicipalityStatus.Should().Be(MunicipalityStatus.Proposed);
}
}
}
Loading