# Class DischargeRepositoryTest

Namespace
  adas_core.Test.Repositories

Assembly
  adas-core.Test.dll

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

Inheritance
  object
  DischargeRepositoryTest

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

### Delete_ShouldDeleteDischarge()

Verifies that the `Delete` repository operation removes a discharge so that subsequent lookups by its identifier return no result.

    [Test]
    public Task Delete_ShouldDeleteDischarge()

#### Returns

Task

### FindAll_ReturnsAllDischarges()

Verifies that the repository's `FindAll` method returns all discharge records previously inserted via `InsertManyAsync`, returning a non-null, non-empty collection whose count matches the number of inserted records.

    [Test]
    public Task FindAll_ReturnsAllDischarges()

#### Returns

Task

### FindByDestination_ExistingDestination_ReturnsDischarges()

Verifies that the discharge repository's FindByDestination method returns the matching discharge records when queried with an existing destination.

    [Test]
    public Task FindByDestination_ExistingDestination_ReturnsDischarges()

#### Returns

Task

### FindByDestination_NonExistentDestination_ReturnsEmptyList()

Verifies that `FindByDestination` returns an empty collection when the provided destination does not match any stored discharge records.

    [Test]
    public Task FindByDestination_NonExistentDestination_ReturnsEmptyList()

#### Returns

Task

### FindById_ExistingId_ReturnsDischarge()

Verifies that the repository's `FindById` method returns the matching `Discharge` document when queried with an existing identifier.

    [Test]
    public Task FindById_ExistingId_ReturnsDischarge()

#### Returns

Task

### FindById_NonExistentId_ReturnsNull()

Verifies that the discharge repository's FindById method returns `null` when queried with a non-existent MongoDB.Bson.ObjectId.

    [Test]
    public Task FindById_NonExistentId_ReturnsNull()

#### Returns

Task

### FindByPoCId_ExistingPoCId_ReturnsDischarges()

Verifies that FindByPoCId(ObjectId) returns the matching discharge when a discharge is associated with the supplied point-of-care identifier.

    [Test]
    public Task FindByPoCId_ExistingPoCId_ReturnsDischarges()

#### Returns

Task

### FindByPoCId_NonExistentPoCId_ReturnsEmptyList()

Verifies that the discharge repository's FindByPoCId method returns an empty list when queried with a non-existent PoCId.

    [Test]
    public Task FindByPoCId_NonExistentPoCId_ReturnsEmptyList()

#### Returns

Task

### FindByService_ExistingService_ReturnsDischarges()

Verifies that FindByService(string) returns the matching discharge record when a previously inserted discharge exists for the specified service name.

    [Test]
    public Task FindByService_ExistingService_ReturnsDischarges()

#### Returns

Task

### FindByService_NonExistentService_ReturnsEmptyList()

Verifies that `FindByService` returns an empty list when queried with a service name that does not exist in the repository.

    [Test]
    public Task FindByService_NonExistentService_ReturnsEmptyList()

#### Returns

Task

### GetByPatientId_ExistingPatientId_ReturnsDischarge()

Verifies that `GetByPatientId` returns the matching Discharge record when a discharge exists for the specified patient identifier.

    [Test]
    public Task GetByPatientId_ExistingPatientId_ReturnsDischarge()

#### Returns

Task

### GetByPatientId_NonExistentPatientId_ReturnsNull()

Verifies that the GetByPatientId(ObjectId) repository method returns `null` when called with a patient ID that does not exist in the data store.

    [Test]
    public Task GetByPatientId_NonExistentPatientId_ReturnsNull()

#### Returns

Task

### GetDischargeByLocation_NonExistentLocation_ReturnsNull()

Verifies that `GetDischargeByLocation` returns `null` when queried with a location that does not exist in the repository.

    [Test]
    public Task GetDischargeByLocation_NonExistentLocation_ReturnsNull()

#### Returns

Task

### GetDischargeByPointOfCareId_ExistingId_ReturnsDischarge()

Verifies that `GetDischargeByPointOfCareId` returns the matching `Discharge` when queried with a point of care ID that already exists in the repository.

    [Test]
    public Task GetDischargeByPointOfCareId_ExistingId_ReturnsDischarge()

#### Returns

Task

### GetDischargeByPointOfCareId_NonExistentId_ReturnsNull()

Verifies that `GetDischargeByPointOfCareId` returns `null` when called with a non-existent point of care ID.

    [Test]
    public Task GetDischargeByPointOfCareId_NonExistentId_ReturnsNull()

#### Returns

Task

### Init()

Performs one-time test setup for discharge integration tests by initializing API settings, dropping and recreating the "discharge" collection in the integration database, and instantiating the DischargeRepository.

    [OneTimeSetUp]
    public Task Init()

#### Returns

Task

### InsertOneAsync_ShouldInsertDischarge()

Verifies that `InsertOneAsync` successfully persists a discharge document and that the inserted record can be retrieved by its identifier.

    [Test]
    public Task InsertOneAsync_ShouldInsertDischarge()

#### Returns

Task

### Update_DischargeSuccessfullyUpdated()

Verifies that an existing discharge record is successfully updated in the repository with new field values.

    [Test]
    public Task Update_DischargeSuccessfullyUpdated()

#### Returns

Task