Ejemplo n.º 1
0
        public void ShouldNotFailWhenUserDoesNotHaveActivePackage()
        {
            var packageId     = Guid.NewGuid();
            var serviceUserId = Guid.NewGuid();
            var packageType   = PackageType.NursingCare;

            _carePackageGateway
            .Setup(g => g.GetServiceUserActivePackagesCount(serviceUserId, packageType, packageId))
            .ReturnsAsync(0);

            var useCase = new EnsureSingleActivePackageTypePerUserUseCase(_carePackageGateway.Object);

            useCase
            .Invoking(uc => uc.ExecuteAsync(serviceUserId, packageType, packageId))
            .Should().NotThrow();
        }
Ejemplo n.º 2
0
        public void ShouldFailWhenUserHasActivePackage()
        {
            var packageId     = Guid.NewGuid();
            var serviceUserId = Guid.NewGuid();
            var packageType   = PackageType.NursingCare;

            _carePackageGateway
            .Setup(g => g.GetServiceUserActivePackagesCount(serviceUserId, packageType, packageId))
            .ReturnsAsync(1);

            var useCase = new EnsureSingleActivePackageTypePerUserUseCase(_carePackageGateway.Object);

            useCase
            .Invoking(uc => uc.ExecuteAsync(serviceUserId, packageType, packageId))
            .Should().Throw <ApiException>()
            .Where(ex => ex.StatusCode == StatusCodes.Status500InternalServerError);
        }