Class ConfigObservationServiceTest
[TestFixture]
public class ConfigObservationServiceTest
- Inheritance
-
ConfigObservationServiceTest
- Inherited Members
- Extension Methods
Methods
CreateConfig_duplicate_throws()
Verifies that BadRequestException is thrown when attempting to create a configuration that already exists.
[Test]
public void CreateConfig_duplicate_throws()
CreateConfig_ok()
Verifies that the CreateConfig service method successfully inserts the provided configuration and returns the expected result.
[Test]
public Task CreateConfig_ok()
Returns
Get_config_by_code_and_parent()
Verifies that the service retrieves the correct configuration by matching both the observation code with its coding system and the parent data code with its coding system, returning the configuration named "ph".
[Test]
public Task Get_config_by_code_and_parent()
Returns
Get_config_observation_item_by_code_and_codingSystem()
Verifies that Get returns the matching patient observation configuration for a given observation identified by its code and coding system.
Asserts that the resolved item is not null and that the displayed name is mapped from the configured lookup to the expected localized value.
[Test]
public Task Get_config_observation_item_by_code_and_codingSystem()
Returns
Get_config_observation_item_by_codingSystem_only_return_null()
Verifies that querying a patient observation by CodingSystem only, without specifying a code or name, returns a null result.
[Test]
public Task Get_config_observation_item_by_codingSystem_only_return_null()
Returns
Get_config_observation_item_by_name()
Verifies that the service retrieves the correct configuration observation item by its name, matching the requested observation against the list returned by the repository and returning the item with the expected name.
[Test]
public Task Get_config_observation_item_by_name()
Returns
Get_config_observation_item_by_name_not_exist_returns_null()
Verifies that the service returns null when a patient observation item is requested by a name that does not exist in the configuration list.
[Test]
public Task Get_config_observation_item_by_name_not_exist_returns_null()
Returns
Map_parent_ok()
Verifies that mapping a parent PatientObservation returns an Ok status when the repository successfully locates the configuration by identifier.
[Test]
public Task Map_parent_ok()
Returns
Map_threshold_Alert()
Verifies that mapping a PatientObservation with a SOFA score of 9 through the configured service results in a result with an Alert status.
[Test]
public Task Map_threshold_Alert()
Returns
Map_threshold_Ok()
Verifies that mapping a patient observation with a value of 14 results in an "Ok" status, confirming the threshold mapping logic returns the expected outcome.
[Test]
public Task Map_threshold_Ok()
Returns
Map_threshold_Warning()
Tests that the Map method returns a Warning status when a patient observation value exceeds the configured threshold.
[Test]
public Task Map_threshold_Warning()
Returns
Map_unknown_ignore_false_returns_obs()
Verifies that when ConfigObservation.IgnoreUnknownObservation is set to false,
the Map method returns the original observation as-is when no matching record is found
in the repository, rather than discarding it as an unknown observation.
[Test]
public Task Map_unknown_ignore_false_returns_obs()
Returns
Map_unknown_ignore_true_returns_null()
Verifies that the mapping service returns null when the observation name is unknown
and the configuration is set to ignore unknown observations.
[Test]
public Task Map_unknown_ignore_true_returns_null()
Returns
RemoveConfigItem_null()
Verifies that RemoveConfigItem returns null when the underlying delete operation on the repository yields no result, simulating the case where the configuration item does not exist.
[Test]
public Task RemoveConfigItem_null()
Returns
RemoveConfigItem_ok()
Verifies that RemoveConfigItem successfully removes a configuration item and returns the deleted entity when the repository finds and deletes it.
[Test]
public Task RemoveConfigItem_ok()
Returns
Setup()
Initializes the test fixture by creating mock instances of all dependencies required by ConfigObservationService, including the repository, unit service, audit service, HTTP context accessor, cache service, and logger. Configures a default authenticated ClaimsPrincipal in the HTTP context and sets the cache mocks to bypass caching by executing the factory function directly, ensuring repository calls are invoked during tests.
[SetUp]
public void Setup()
UpdateConfig_notfound()
Verifies that UpdateConfig throws a NotFoundException when the target ConfigObservation cannot be found by its identifier.
[Test]
public Task UpdateConfig_notfound()
Returns
UpdateConfig_ok()
Verifies that UpdateConfig successfully updates an existing configuration and returns the updated ConfigObservation with the new name.
[Test]
public Task UpdateConfig_ok()