Exemple #1
0
        public void Throws_Exception_If_Validation_Fails()
        {
            _moqer.GetMock <IVirtualApprenticeshipValidator>()
            .Setup(x => x.Validate(It.IsAny <VirtualApprenticeship>()))
            .Returns(new List <ValidationResult> {
                ValidationResult.Failed("test fail")
            });
            var estimation = ResolveEstimation();

            Assert.Throws <InvalidOperationException>(() => estimation.AddVirtualApprenticeship("course-1", "test course", 1, 1, 2019, 5, 18, 1000, FundingSource.Transfer), "Should throw an exception if the apprenticeship fails validation");
        }
Exemple #2
0
 public void SetUp()
 {
     _moqer = new AutoMoqer();
     _model = new AccountEstimationModel
     {
         Id = Guid.NewGuid().ToString("N"),
         Apprenticeships   = new List <VirtualApprenticeship>(),
         EmployerAccountId = 12345,
         EstimationName    = "default"
     };
     _moqer.SetInstance(_model);
     _moqer.GetMock <IVirtualApprenticeshipValidator>()
     .Setup(x => x.Validate(It.IsAny <VirtualApprenticeship>()))
     .Returns(new List <ValidationResult>());
     _moqer.GetMock <IAccountEstimationRepository>()
     .Setup(x => x.Get(It.IsAny <long>()))
     .Returns(Task.FromResult(_moqer.Resolve <AccountEstimation>()));
     _moqer.GetMock <IDateTimeService>()
     .Setup(x => x.GetCurrentDateTime())
     .Returns(new DateTimeService().GetCurrentDateTime());
 }