public async Task WhenCohortExistsAndWithCorrectPartyAndThisIsTheLastApprenticeship_ThenMarksModelAsIsLastApprenticeship()
        {
            var f = new DeleteDraftApprenticeshipViewModelMapperTestsFixture().WithParty(Party.Employer).WithSingleApprenticeship();

            var result = await f.Sut.Map(f.DeleteApprenticeshipRequest);

            Assert.IsTrue(result.IsLastApprenticeshipInCohort);
        }
        public async Task WhenCohortExistsAndWithCorrectPartyAndApprenticeshipFound_ThenIsLastApprenticeshipIsFalse()
        {
            var f = new DeleteDraftApprenticeshipViewModelMapperTestsFixture().WithParty(Party.Employer).ApprenticeshipsExists();

            var result = await f.Sut.Map(f.DeleteApprenticeshipRequest);

            Assert.IsFalse(result.IsLastApprenticeshipInCohort);
        }
        public async Task WhenCohortExistsAndWithCorrectPartyAndApprenticeshipFound_ThenCallsCommitmentsApiToGetDraftApprenticeships()
        {
            var f = new DeleteDraftApprenticeshipViewModelMapperTestsFixture().WithParty(Party.Employer).ApprenticeshipsExists();

            await f.Sut.Map(f.DeleteApprenticeshipRequest);

            f.VerifyGetDraftApprenticeshipsIsCalledCorrectly();
        }
        public async Task ThenMapsRequestValuesToViewModel()
        {
            var f = new DeleteDraftApprenticeshipViewModelMapperTestsFixture().WithParty(Party.Employer).WithSingleApprenticeship();

            var result = await f.Sut.Map(f.DeleteApprenticeshipRequest);

            Assert.AreEqual(f.SingleApprenticeship.FirstName, result.FirstName);
            Assert.AreEqual(f.SingleApprenticeship.LastName, result.LastName);
            Assert.AreEqual(f.SingleApprenticeship.FirstName + " " + f.SingleApprenticeship.LastName, result.FullName);
            Assert.AreEqual(f.DeleteApprenticeshipRequest.AccountHashedId, result.AccountHashedId);
            Assert.AreEqual(f.DeleteApprenticeshipRequest.DraftApprenticeshipHashedId, result.DraftApprenticeshipHashedId);
            Assert.AreEqual(f.DeleteApprenticeshipRequest.AccountHashedId, result.AccountHashedId);
            Assert.AreEqual(f.DeleteApprenticeshipRequest.Origin, result.Origin);
            Assert.AreEqual(f.DeleteApprenticeshipRequest.CohortReference, result.CohortReference);
            Assert.AreEqual(f.GetCohortResponse.LegalEntityName, result.LegalEntityName);
            Assert.IsTrue(result.IsLastApprenticeshipInCohort);
        }
        public void WhenCohortExistsAndWithCorrectPartyButNoMatchingApprenticeship_ThenThrowsException()
        {
            var f = new DeleteDraftApprenticeshipViewModelMapperTestsFixture().WithParty(Party.Employer).WithNoMatchingApprentices();

            Assert.ThrowsAsync <DraftApprenticeshipNotFoundException>(async() => await f.Sut.Map(f.DeleteApprenticeshipRequest));
        }
        public void WhenCohortIsWithTheProvider_ThenThrowsException()
        {
            var f = new DeleteDraftApprenticeshipViewModelMapperTestsFixture().WithParty(Party.Provider).ApprenticeshipsExists();

            Assert.ThrowsAsync <CohortEmployerUpdateDeniedException>(async() => await f.Sut.Map(f.DeleteApprenticeshipRequest));
        }