Skip to content
This repository has been archived by the owner on Apr 12, 2023. It is now read-only.

Commit

Permalink
Merge pull request #789 from keiji/cocoa2/fix_exposurerisk_calculatio…
Browse files Browse the repository at this point in the history
…n_configequals

Fix an issue that wrong == operator used.
  • Loading branch information
cocoa-dev004 authored Jan 20, 2022
2 parents d6ad310 + 5f4bac7 commit d6ff39a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private async Task<V1ExposureRiskCalculationConfiguration> GetExposureRiskCalcul
{
currentConfiguration = CreateDefaultConfiguration();
}
else if(preferCache)
else if (preferCache)
{
_loggerService.EndMethod();
return currentConfiguration;
Expand Down Expand Up @@ -154,7 +154,7 @@ private async Task<V1ExposureRiskCalculationConfiguration> GetExposureRiskCalcul
return currentConfiguration;
}

if (newExposureRiskCalculationConfiguration == currentConfiguration)
if (newExposureRiskCalculationConfiguration.Equals(currentConfiguration))
{
_loggerService.Info("ExposureRiskCalculationConfiguration have not been changed.");
_loggerService.EndMethod();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,43 @@ V1ExposureRiskCalculationConfiguration newConfiguration
Assert.Equal(result, newConfiguration);
}

[Fact]
public async Task GetExposureRiskConfigurationTest_not_updated()
{
string currentConfigurationJson = GetTestJson(JSON_EXPOSURE_RISK_CONFIGURATION1);
File.WriteAllText(CURRENT_EXPOSURE_RISK_CONFIGURATION_FILE_PATH, currentConfigurationJson);
V1ExposureRiskCalculationConfiguration currentConfiguration
= JsonConvert.DeserializeObject<V1ExposureRiskCalculationConfiguration>(currentConfigurationJson);

string newConfigurationJson = GetTestJson(JSON_EXPOSURE_RISK_CONFIGURATION2);
V1ExposureRiskCalculationConfiguration newConfiguration
= JsonConvert.DeserializeObject<V1ExposureRiskCalculationConfiguration>(newConfigurationJson);

var jsonContent = new StringContent(
newConfigurationJson,
Encoding.UTF8,
"application/json"
);
var client = HttpClientUtils.CreateHttpClient(HttpStatusCode.OK, jsonContent);
mockClientService.Setup(x => x.Create()).Returns(client);

mockLocalPathService.Setup(x => x.ExposureConfigurationDirPath).Returns("./");
mockLocalPathService.Setup(x => x.CurrentExposureRiskCalculationConfigurationPath).Returns(CURRENT_EXPOSURE_RISK_CONFIGURATION_FILE_PATH);
mockServerConfigurationRepository.Setup(x => x.ExposureRiskCalculationConfigurationUrl).Returns("https://example.com/exposure_risk_configuration.json");

var unitUnderTest = CreateRepository();
var result = await unitUnderTest.GetExposureRiskCalculationConfigurationAsync(preferCache: false);

result = await unitUnderTest.GetExposureRiskCalculationConfigurationAsync(preferCache: false);

mockServerConfigurationRepository.Verify(s => s.LoadAsync(), Times.Exactly(2));
mockLoggerService.Verify(x => x.Info("ExposureRiskCalculationConfiguration have not been changed.", It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>()),Times.Once);

Assert.NotNull(result);

Assert.NotEqual(result, currentConfiguration);
Assert.Equal(result, newConfiguration);
}

}
}

0 comments on commit d6ff39a

Please sign in to comment.