# Class PumpAlarmStateRepositoryTest

Namespace
  adas_core.Test.Repositories

Assembly
  adas-core.Test.dll

    [TestFixture]
    [Category("Integration")]
    public class PumpAlarmStateRepositoryTest

Inheritance
  object
  PumpAlarmStateRepositoryTest

Inherited Members
  object.Equals(object)
  object.Equals(object, object)
  object.GetHashCode()
  object.GetType()
  object.MemberwiseClone()
  object.ReferenceEquals(object, object)
  object.ToString()

Extension Methods
  NumberUtils.IsNumber(object)
  NumberUtils.ToDouble(object)
  ObjectUtils.ToStr(object?)

## Methods

### DeleteByPatientId_Works()

Verifies that the repository's `DeleteByPatientId` method successfully removes a previously upserted PumpAlarmState for the specified patient, ensuring no matching records remain in the collection.

    [Test]
    public Task DeleteByPatientId_Works()

#### Returns

Task

### FindActiveAsync_ReturnsCorrectAlarm()

Verifies that `FindActiveAsync` returns the correct active alarm matching the specified device identifier, alarm type, and alarm code.

    [Test]
    public Task FindActiveAsync_ReturnsCorrectAlarm()

#### Returns

Task

### FindActiveAsync_ReturnsNull_WhenNotFound()

Verifies that `FindActiveAsync` returns `null` when no active alarm matching the specified device, alarm type, and identifier exists.

    [Test]
    public Task FindActiveAsync_ReturnsNull_WhenNotFound()

#### Returns

Task

### FindAllActiveByDeviceAsync_ReturnsCorrect()

Verifies that `FindAllActiveByDeviceAsync` returns only active pump alarm states that belong to the specified device.

    [Test]
    public Task FindAllActiveByDeviceAsync_ReturnsCorrect()

#### Returns

Task

### Init()

One-time setup that prepares the integration test environment for PumpAlarmStateRepository. Configures the API settings, drops and recreates the "pump_alarm_state" collection, instantiates the repository with its indexes, and seeds three initial alarm state records across two devices, verifying the seeded count.

    [OneTimeSetUp]
    public Task Init()

#### Returns

Task

### RemoveAsync_RemovesAllMatching()

Verifies that `RemoveAsync` removes every active alarm matching the specified device identifier and alarm type, not just a single record.

    [Test]
    public Task RemoveAsync_RemovesAllMatching()

#### Returns

Task

### RemoveAsync_Works()

Verifies that `RemoveAsync` correctly deletes an active alarm by device, alarm type, and alarm code, and that a subsequent lookup returns no result.

    [Test]
    public Task RemoveAsync_Works()

#### Returns

Task

### UpdateManyObjectIdByFieldNameAsync_Works()

Verifies that `UpdateManyObjectIdByFieldNameAsync` successfully updates the `PatientId` field from the old ObjectId to a new ObjectId for matching documents, returning the expected count of updated records and making the document retrievable by the new ObjectId.

    [Test]
    public Task UpdateManyObjectIdByFieldNameAsync_Works()

#### Returns

Task

### UpsertActiveAsync_InsertsNew()

Verifies that `UpsertActiveAsync` correctly inserts a new active pump alarm into the repository when no existing alarm with the same device, type, and code is found, and that the inserted alarm can subsequently be retrieved via `FindActiveAsync`.

    [Test]
    public Task UpsertActiveAsync_InsertsNew()

#### Returns

Task

### UpsertActiveAsync_InsertsWhenAlarmCodeIsNull()

Verifies that UpsertActiveAsync correctly inserts a PumpAlarmState record when the AlarmCodeMdc is null, and that the record can be retrieved via FindActiveAsync using a null alarm code.

    [Test]
    public Task UpsertActiveAsync_InsertsWhenAlarmCodeIsNull()

#### Returns

Task

### UpsertActiveAsync_NoDuplicateOnRepeatedCalls()

    [Test]
    public Task UpsertActiveAsync_NoDuplicateOnRepeatedCalls()

#### Returns

Task

### UpsertActiveAsync_UpdatesExisting()

    [Test]
    public Task UpsertActiveAsync_UpdatesExisting()

#### Returns

Task