Skip to content

Commit

Permalink
Fix typos and other problems reported by static analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
jakzal committed Oct 10, 2024
1 parent 10cebb0 commit 794893d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public async Task Execute_ShouldUpdateOrganisation_WhenOrganisationExists()
AdditionalIdentifiers = [new OrganisationIdentifier
{
Id = "FakeId",
LegalName = "Illigal",
LegalName = "Illegal",
Scheme = "FakeScheme"
}]
}
Expand All @@ -41,7 +41,7 @@ public async Task Execute_ShouldUpdateOrganisation_WhenOrganisationExists()
var result = await UseCase.Execute((_organisationId, updateOrganisation));

result.Should().BeTrue();
_organisationRepositoryMock.Verify(repo => repo.Save(organisation!), Times.Once);
_organisationRepositoryMock.Verify(repo => repo.Save(organisation), Times.Once);
}

[Fact]
Expand All @@ -66,7 +66,7 @@ public async Task Execute_ItAssignsVatIdentifierAsPrimaryWhenOtherIdentifierExis
var result = await UseCase.Execute((_organisationId, updateOrganisation));

result.Should().BeTrue();
_organisationRepositoryMock.Verify(repo => repo.Save(organisation!), Times.Once);
_organisationRepositoryMock.Verify(repo => repo.Save(organisation), Times.Once);

organisation.Identifiers.First(i => i.Scheme == "Other").Primary.Should().BeFalse();
organisation.Identifiers.First(i => i.Scheme == "VAT").Primary.Should().BeTrue();
Expand Down Expand Up @@ -94,7 +94,7 @@ public async Task Execute_ItAssignsVatIdentifierAsPrimaryWhenPponIdentifierExist
var result = await UseCase.Execute((_organisationId, updateOrganisation));

result.Should().BeTrue();
_organisationRepositoryMock.Verify(repo => repo.Save(organisation!), Times.Once);
_organisationRepositoryMock.Verify(repo => repo.Save(organisation), Times.Once);

organisation.Identifiers.First(i => i.Scheme == "GB-PPON").Primary.Should().BeFalse();
organisation.Identifiers.First(i => i.Scheme == "VAT").Primary.Should().BeTrue();
Expand Down Expand Up @@ -225,7 +225,7 @@ public async Task Execute_ShouldUpdateVatNumber_WhenVatIdentifierAlreadyExists()
var result = await UseCase.Execute((_organisationId, command));

result.Should().BeTrue();
_organisationRepositoryMock.Verify(repo => repo.Save(organisation!), Times.Once);
_organisationRepositoryMock.Verify(repo => repo.Save(organisation), Times.Once);

organisation.Identifiers.Should().Contain(i => i.Scheme == "VAT" && i.IdentifierId == "999999");
organisation.Identifiers.Should().ContainSingle();
Expand Down Expand Up @@ -279,12 +279,10 @@ public async Task Execute_ShouldAssignPponAsPrimary_WhenVatIdentifierIsRemoved()
var result = await UseCase.Execute((_organisationId, command));

result.Should().BeTrue();
_organisationRepositoryMock.Verify(repo => repo.Save(organisation!), Times.Once);
_organisationRepositoryMock.Verify(repo => repo.Save(organisation), Times.Once);

organisation.Identifiers.FirstOrDefault(i =>
i.Scheme == "GB-PPON" &&
i.IdentifierId == "c0777aeb968b4113a27d94e55b10c1b4" &&
i.Primary)
i is { Scheme: "GB-PPON", IdentifierId: "c0777aeb968b4113a27d94e55b10c1b4", Primary: true })
.Should().NotBeNull();
organisation.Identifiers.Should().ContainSingle();
}
Expand Down Expand Up @@ -317,7 +315,7 @@ public async Task Execute_ShouldNotInsertIdentifier_WhenIdentifierIdIsEmptyOrNul
var result = await UseCase.Execute((_organisationId, command));

result.Should().BeTrue();
_organisationRepositoryMock.Verify(repo => repo.Save(organisation!), Times.Once);
_organisationRepositoryMock.Verify(repo => repo.Save(organisation), Times.Once);

organisation.Identifiers.FirstOrDefault(i => i.Scheme == "VAT").Should().BeNull();
}
Expand Down Expand Up @@ -356,7 +354,7 @@ public async Task Execute_ShouldUpdateOrganisationName_WhenOrganisationAlreadyEx
var result = await UseCase.Execute((_organisationId, command));

result.Should().BeTrue();
_organisationRepositoryMock.Verify(repo => repo.Save(organisation!), Times.Once);
_organisationRepositoryMock.Verify(repo => repo.Save(organisation), Times.Once);

organisation.Name.Should().Be("Updated Organisation Name");
}
Expand Down Expand Up @@ -423,13 +421,13 @@ public async Task Execute_ShouldUpdateOrganisationEmail_WhenOrganisationContactP
var result = await UseCase.Execute((_organisationId, command));

result.Should().BeTrue();
_organisationRepositoryMock.Verify(repo => repo.Save(organisation!), Times.Once);
_organisationRepositoryMock.Verify(repo => repo.Save(organisation), Times.Once);

organisation.ContactPoints.FirstOrDefault()!.Email.Should().Be("[email protected]");
}

[Fact]
public async Task Execute_ShouldThrowInvalidUpdateOrganisationCommand_WhenOrganisationRegsiteredAddressIsNull()
public async Task Execute_ShouldThrowInvalidUpdateOrganisationCommand_WhenOrganisationRegisteredAddressIsNull()
{
var updateOrganisation = new UpdateOrganisation
{
Expand All @@ -446,7 +444,7 @@ await act.Should()
}

[Fact]
public async Task Execute_ShouldThrowInvalidUpdateOrganisationCommand_WhenOrganisationRegsiteredAddressIsMissing()
public async Task Execute_ShouldThrowInvalidUpdateOrganisationCommand_WhenOrganisationRegisteredAddressIsMissing()
{
var updateOrganisation = new UpdateOrganisation
{
Expand All @@ -456,11 +454,11 @@ public async Task Execute_ShouldThrowInvalidUpdateOrganisationCommand_WhenOrgani
Addresses = [
new OrganisationAddress
{
Type=OrganisationInformation.AddressType.Postal,
Type=OrganisationInformation.AddressType.Postal,
StreetAddress = "1234 Test St",
Locality = "Test City",
PostalCode = "12345",
CountryName = "Testland",
CountryName = "Test Land",
Country = "AB",
Region="Test Region"
}
Expand All @@ -474,7 +472,7 @@ public async Task Execute_ShouldThrowInvalidUpdateOrganisationCommand_WhenOrgani

await act.Should()
.ThrowAsync<InvalidUpdateOrganisationCommand>()
.WithMessage("Missing Organisation regsitered address.");
.WithMessage("Missing Organisation registered address.");
}

[Fact]
Expand All @@ -492,7 +490,7 @@ public async Task Execute_ShouldUpdateOrganisationRegisteredAddress_WhenOrganisa
StreetAddress = "1234 Test St",
Locality = "Test City",
PostalCode = "12345",
CountryName = "Testland updated",
CountryName = "Test Land updated",
Country = "AB",
Region="Test Region"
}
Expand All @@ -505,9 +503,9 @@ public async Task Execute_ShouldUpdateOrganisationRegisteredAddress_WhenOrganisa
var result = await UseCase.Execute((_organisationId, command));

result.Should().BeTrue();
_organisationRepositoryMock.Verify(repo => repo.Save(organisation!), Times.Once);
_organisationRepositoryMock.Verify(repo => repo.Save(organisation), Times.Once);

organisation.Addresses.FirstOrDefault(x=>x.Type==OrganisationInformation.AddressType.Registered)!.Address!.CountryName.Should().Be("Testland updated");
organisation.Addresses.FirstOrDefault(x=>x.Type==OrganisationInformation.AddressType.Registered)!.Address.CountryName.Should().Be("Test Land updated");
}


Expand Down Expand Up @@ -570,7 +568,7 @@ public async Task Execute_ShouldUpdateOrganisationRegisteredAddress_WhenOrganisa
StreetAddress = "1234 Test St",
Locality = "Test City",
PostalCode = "12345",
CountryName = "Testland",
CountryName = "Test Land",
Country = "AB"
}
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public async Task<bool> Execute((Guid organisationId, UpdateOrganisation updateO

var newAddress = updateObject.Addresses.FirstOrDefault(x => x.Type == AddressType.Registered);
if (newAddress == null)
throw new InvalidUpdateOrganisationCommand("Missing Organisation regsitered address.");
throw new InvalidUpdateOrganisationCommand("Missing Organisation registered address.");

var existingAddress = organisation.Addresses.FirstOrDefault(i => i.Type == newAddress.Type);
if (existingAddress != null)
Expand Down

0 comments on commit 794893d

Please sign in to comment.