# Class PumpAlarmEventRepositoryTest

Namespace
  adas_core.Test.Repositories

Assembly
  adas-core.Test.dll

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

Inheritance
  object
  PumpAlarmEventRepositoryTest

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_DeletesMany_AndIsIdempotent()

Verifies that `DeleteByPatientId` removes all alarm events associated with the given patient and can be invoked repeatedly without throwing once the records no longer exist.

    [Test]
    public Task DeleteByPatientId_DeletesMany_AndIsIdempotent()

#### Returns

Task

### DeleteByPatientId_Works()

Verifies that DeleteByPatientId correctly removes all alarm events associated with a given patient. Inserts a sample `PumpAlarmEvent` for a specific patient, deletes it by patient ID, and asserts that no matching events remain in the collection.

    [Test]
    public Task DeleteByPatientId_Works()

#### Returns

Task

### FindByDeviceIdAsync_InclusiveRange_BoundsRespected()

Verifies that `FindByDeviceIdAsync` treats the `from` and `to` time bounds as inclusive, ensuring events whose timestamp matches the upper bound exactly are returned and that all returned events fall within the supplied range.

    [Test]
    public Task FindByDeviceIdAsync_InclusiveRange_BoundsRespected()

#### Returns

Task

### FindByDeviceIdAsync_MultipleOverlappingRanges()

Verifies that `FindByDeviceIdAsync` correctly filters pump alarm events by device identifier and time range when multiple queries are issued against overlapping windows, ensuring each range returns only the event that falls within its boundaries.

    [Test]
    public Task FindByDeviceIdAsync_MultipleOverlappingRanges()

#### Returns

Task

### FindByDeviceIdAsync_RespectsLimitAndOrder()

Verifies that `FindByDeviceIdAsync` correctly applies the requested limit and orders results so that the most recent alarm event for the given device is returned first. Seeds multiple events for the target device, requests a single record, and asserts that the returned entry matches the latest event retrieved by `FindLastByDeviceIdAsync`.

    [Test]
    public Task FindByDeviceIdAsync_RespectsLimitAndOrder()

#### Returns

Task

### FindByDeviceIdAsync_ReturnsEmpty_WhenOutOfRange()

Verifies that `FindByDeviceIdAsync` returns an empty result when the queried date range falls outside of the available data window.

    [Test]
    public Task FindByDeviceIdAsync_ReturnsEmpty_WhenOutOfRange()

#### Returns

Task

### FindByDeviceIdAsync_ReturnsOrdered()

Verifies that `FindByDeviceIdAsync` returns a non-empty collection of records for the specified device, ordered by time so that the most recent entry appears first.

    [Test]
    public Task FindByDeviceIdAsync_ReturnsOrdered()

#### Returns

Task

### FindByDeviceIdAsync_WithDateRange_Works()

Verifies that `FindByDeviceIdAsync` returns only pump alarm events whose timestamps fall within the specified date range.

    [Test]
    public Task FindByDeviceIdAsync_WithDateRange_Works()

#### Returns

Task

### FindByDeviceIdAsync_WithLimit_Works()

Verifies that `FindByDeviceIdAsync` returns at most the specified number of results when a limit is provided.

    [Test]
    public Task FindByDeviceIdAsync_WithLimit_Works()

#### Returns

Task

### FindLastByDeviceIdAsync_TracksNewest()

Verifies that FindLastByDeviceIdAsync returns the most recent alarm event for a given device and tracks newly inserted events as the latest entry.

    [Test]
    public Task FindLastByDeviceIdAsync_TracksNewest()

#### Returns

Task

### FindLastByDeviceIdAsync_Works()

    [Test]
    public Task FindLastByDeviceIdAsync_Works()

#### Returns

Task

### Init()

Performs one-time integration test setup for the pump alarm event repository by configuring API settings, resetting the dedicated MongoDB collection, creating required indexes, and seeding it with three initial alarm events covering both Device and DeviceB across attention and occlusion alarm types. Verifies that exactly three documents are present after seeding.

    [OneTimeSetUp]
    public Task Init()

#### Returns

Task

### InsertAsync_AllowsNullOptionalFields()

Verifies that InsertAsync successfully persists a PumpAlarmEvent when its optional fields (`PatientId` and `AlarmType`) are `null`, and that the record can be retrieved afterwards.

    [Test]
    public Task InsertAsync_AllowsNullOptionalFields()

#### Returns

Task

### InsertAsync_Works()

Verifies that InsertAsync correctly persists a PumpAlarmEvent to the repository by inserting an event and confirming it can be retrieved by its identifier.

    [Test]
    public Task InsertAsync_Works()

#### Returns

Task

### UpdateManyObjectIdByFiledNameAsync_UpdatesMultiple()

Verifies that `UpdateManyObjectIdByFiledNameAsync` updates the `PatientId` field from an old MongoDB.Bson.ObjectId to a new one across all matching documents, returning the modified count and persisting the new identifier in the collection.

    [Test]
    public Task UpdateManyObjectIdByFiledNameAsync_UpdatesMultiple()

#### Returns

Task

### UpdateManyObjectIdByFiledNameAsync_Works()

Verifies that `UpdateManyObjectIdByFiledNameAsync` correctly updates documents matching the specified field name and old ObjectId value, replacing it with the new ObjectId, and that the changes are persisted and queryable.

    [Test]
    public Task UpdateManyObjectIdByFiledNameAsync_Works()

#### Returns

Task