/// <summary>
 /// Determines whether [is component of a program] [the specified delivery].
 /// </summary>
 /// <param name="delivery">The delivery.</param>
 /// <returns>
 ///   <c>true</c> if [is component of a program] [the specified delivery]; otherwise, <c>false</c>.
 /// </returns>
 public bool IsComponentOfAProgram(ILearningDelivery delivery) =>
 It.IsInRange(delivery.AimType, TypeOfAim.ComponentAimInAProgramme);
コード例 #2
0
 /// <summary>
 /// Determines whether [is basic skills learner] [the specified monitor].
 /// </summary>
 /// <param name="monitor">The monitor.</param>
 /// <returns>
 ///   <c>true</c> if [is basic skills learner] [the specified monitor]; otherwise, <c>false</c>.
 /// </returns>
 public bool IsBasicSkillsLearner(ILARSAnnualValue monitor) =>
     It.IsInRange(monitor.BasicSkillsType, TypeOfLARSBasicSkill.AsEnglishAndMathsBasicSkills);
コード例 #3
0
 /// <summary>
 /// Determines whether [is fully funded] [the specified monitor].
 /// </summary>
 /// <param name="monitor">The monitor.</param>
 /// <returns>
 ///   <c>true</c> if [is fully funded] [the specified monitor]; otherwise, <c>false</c>.
 /// </returns>
 public bool IsFullyFunded(ILearningDeliveryFAM monitor) =>
     It.IsInRange($"{monitor.LearnDelFAMType}{monitor.LearnDelFAMCode}", Monitoring.Delivery.FullyFundedLearningAim);
コード例 #4
0
 /// <summary>
 /// Determines whether [is released on temporary licence] [the specified monitor].
 /// </summary>
 /// <param name="monitor">The monitor.</param>
 /// <returns>
 ///   <c>true</c> if [is released on temporary licence] [the specified monitor]; otherwise, <c>false</c>.
 /// </returns>
 public bool IsReleasedOnTemporaryLicence(ILearningDeliveryFAM monitor) =>
     It.IsInRange($"{monitor.LearnDelFAMType}{monitor.LearnDelFAMCode}", Monitoring.Delivery.ReleasedOnTemporaryLicence);
コード例 #5
0
 /// <summary>
 /// Determines whether [is steel worker] [the specified monitor].
 /// </summary>
 /// <param name="monitor">The monitor.</param>
 /// <returns>
 ///   <c>true</c> if [is steel worker] [the specified monitor]; otherwise, <c>false</c>.
 /// </returns>
 public bool IsSteelWorkerRedundancyTraining(ILearningDeliveryFAM monitor) =>
     It.IsInRange($"{monitor.LearnDelFAMType}{monitor.LearnDelFAMCode}", Monitoring.Delivery.SteelIndustriesRedundancyTraining);
コード例 #6
0
 /// <summary>
 /// Determines whether [has qualifying fund model] [the specified delivery].
 /// </summary>
 /// <param name="delivery">The delivery.</param>
 /// <returns>
 ///   <c>true</c> if [has qualifying fund model] [the specified delivery]; otherwise, <c>false</c>.
 /// </returns>
 public bool HasQualifyingFundModel(ILearningDelivery delivery) =>
 It.IsInRange(delivery.FundModel, TypeOfFunding.Age16To19ExcludingApprenticeships, TypeOfFunding.AdultSkills, TypeOfFunding.EuropeanSocialFund, TypeOfFunding.OtherAdult);
コード例 #7
0
 /// <summary>
 /// Determines whether [in training] [the specified delivery].
 /// </summary>
 /// <param name="delivery">The delivery.</param>
 /// <returns>
 ///   <c>true</c> if [in training] [the specified delivery]; otherwise, <c>false</c>.
 /// </returns>
 public bool InTraining(ILearningDelivery delivery) =>
 It.IsInRange(delivery.ProgTypeNullable, TypeOfLearningProgramme.Traineeship, TypeOfLearningProgramme.ApprenticeshipStandard);
 /// <summary>
 /// Determines whether the specified delivery is apprencticeship.
 /// </summary>
 /// <param name="delivery">The delivery.</param>
 /// <returns>
 ///   <c>true</c> if the specified delivery is apprencticeship; otherwise, <c>false</c>.
 /// </returns>
 public bool IsTargetApprencticeship(ILearningDelivery delivery) =>
 It.IsInRange(delivery.ProgTypeNullable, TypeOfLearningProgramme.ApprenticeshipStandard);
 /// <summary>
 /// Determines whether [is right fund model] [for the specified delivery].
 /// </summary>
 /// <param name="delivery">The delivery.</param>
 /// <returns>
 ///   <c>true</c> if [is right fund model] [for the specified delivery]; otherwise, <c>false</c>.
 /// </returns>
 public bool IsInAProgramme(ILearningDelivery delivery) =>
 It.IsInRange(delivery.AimType, TypeOfAim.ProgrammeAim);
 /// <summary>
 /// Determines whether [is loans bursary] [the specified monitor].
 /// </summary>
 /// <param name="monitor">The monitor.</param>
 /// <returns>
 ///   <c>true</c> if [is loans bursary] [the specified monitor]; otherwise, <c>false</c>.
 /// </returns>
 public bool IsLoansBursary(ILearningDeliveryFAM monitor) =>
 It.IsInRange(monitor.LearnDelFAMType, Monitoring.Delivery.Types.AdvancedLearnerLoansBursaryFunding);
 /// <summary>
 /// Condition met.
 /// </summary>
 /// <param name="financialRecord">The financial record.</param>
 /// <returns>
 /// true if any any point the conditions are met
 /// </returns>
 public bool ConditionMet(IAppFinRecord financialRecord)
 {
     return(It.Has(financialRecord)
         ? It.IsInRange($"{financialRecord.AFinType}{financialRecord.AFinCode}", ApprenticeshipFinancialRecord.TotalAssessmentPrice, ApprenticeshipFinancialRecord.ResidualAssessmentPrice)
         : true);
 }
 /// <summary>
 /// Determines whether [is advanced learner loan] [the specified monitor].
 /// </summary>
 /// <param name="monitor">The monitor.</param>
 /// <returns>
 ///   <c>true</c> if [is advanced learner loan] [the specified monitor]; otherwise, <c>false</c>.
 /// </returns>
 public bool IsAdvancedLearnerLoan(ILearningDeliveryFAM monitor) =>
 It.IsInRange(monitor.LearnDelFAMType, Monitoring.Delivery.Types.AdvancedLearnerLoan);
 /// <summary>
 /// Determines whether the specified learning delivery has qualifying funding
 /// </summary>
 /// <param name="delivery">The delivery.</param>
 /// <param name="desiredFundings">The desired fundings.</param>
 /// <returns>
 ///   <c>true</c> if [has qualifying funding] [the specified delivery]; otherwise, <c>false</c>.
 /// </returns>
 public bool HasQualifyingFunding(ILearningDelivery delivery, params int[] desiredFundings) =>
 It.IsInRange(delivery.FundModel, desiredFundings);
 /// <summary>
 /// Determines whether the specified delivery is traineeship.
 /// </summary>
 /// <param name="delivery">The delivery.</param>
 /// <returns>
 ///   <c>true</c> if the specified delivery is traineeship; otherwise, <c>false</c>.
 /// </returns>
 public bool IsTraineeship(ILearningDelivery delivery) =>
 It.IsInRange(delivery.ProgTypeNullable, TypeOfLearningProgramme.Traineeship);
コード例 #15
0
        public async Task CreatePricelist()
        {
            var catalogKind     = CatalogKind.Cargo;
            var catalogItemKind = CatalogItemKind.Weight;
            var catalogItems    = new List <CatalogItemAM>
            {
                new CatalogItemAM {
                    Id    = 4,
                    Name  = "0.5t",
                    Value = 500
                },
                new CatalogItemAM {
                    Id    = 5,
                    Name  = "1t",
                    Value = 1000
                },
                new CatalogItemAM {
                    Id    = 6,
                    Name  = "1.5t",
                    Value = 1500
                }
            };

            Suite.CatalogServiceMock
            .Setup(m => m.GetCatalogItems(catalogKind, catalogItemKind))
            .ReturnsAsync(catalogItems);

            var pricelist = new PricelistAM
            {
                Items =
                {
                    new PriceAM {
                        CatalogItemId = catalogItems[0].Id
                    },
                    new PriceAM {
                        CatalogItemId = catalogItems[1].Id
                    },
                    new PriceAM {
                        CatalogItemId = catalogItems[2].Id
                    }
                }
            };

            var domainPricelist = new Pricelist {
                Id = 1
            };

            Suite.DomainPricelistServiceMock
            .Setup(m => m.Create())
            .ReturnsAsync(domainPricelist);

            var result = await Suite.PricelistService.CreateDomainPricelist();

            Suite.DomainPriceServiceMock
            .Verify(
                m => m.Create(
                    domainPricelist.Id,
                    It.IsInRange(4, 6, Range.Inclusive),
                    It.IsAny <string>(),
                    It.IsAny <byte>(),
                    It.IsAny <decimal>(),
                    It.IsAny <decimal>(),
                    It.IsAny <decimal>(),
                    It.IsAny <decimal>(),
                    It.IsAny <decimal>(),
                    It.IsAny <decimal>()),
                Times.Exactly(pricelist.Items.Count));
        }
コード例 #16
0
 /// <summary>
 /// Determines whether [is eligible for funding] [the specified candidate].
 /// </summary>
 /// <param name="candidate">The candidate.</param>
 /// <returns>
 ///   <c>true</c> if [is eligible for funding] [the specified candidate]; otherwise, <c>false</c>.
 /// </returns>
 public bool IsEligibleForFunding(ILearner candidate) =>
 It.IsInRange(candidate.EngGrade, Monitoring.Learner.Level1AndLowerGrades);
コード例 #17
0
        /// <summary>
        /// Validates the specified object.
        /// </summary>
        /// <param name="objectToValidate">The object to validate.</param>
        public void Validate(ILearner objectToValidate)
        {
            It.IsNull(objectToValidate)
            .AsGuard <ArgumentNullException>(nameof(objectToValidate));

            var learnRefNumber = objectToValidate.LearnRefNumber;

            objectToValidate.LearningDeliveries
            .SafeWhere(x => It.IsInRange(x.ProgTypeNullable, TypeOfLearningProgramme.Traineeship) && It.IsInRange(x.AimType, TypeOfAim.ProgrammeAim))
            .ForEach(x =>
            {
                var failedValidation = !ConditionMet(x);

                if (failedValidation)
                {
                    RaiseValidationMessage(learnRefNumber, x);
                }
            });
        }
コード例 #18
0
 /// <summary>
 /// Determines whether [has eligible funding] [the specified monitor].
 /// </summary>
 /// <param name="monitor">The monitor.</param>
 /// <returns>
 ///   <c>true</c> if [has eligible funding] [the specified monitor]; otherwise, <c>false</c>.
 /// </returns>
 public bool HasEligibleFunding(ILearnerFAM monitor) =>
 It.IsInRange($"{monitor.LearnFAMType}{monitor.LearnFAMCode}", Monitoring.Learner.NotAchievedLevel2EnglishGCSEByYear11);
コード例 #19
0
 /// <summary>
 /// Determines whether [has temporarily withdrawn] [the specified delivery].
 /// </summary>
 /// <param name="delivery">The delivery.</param>
 /// <returns>
 ///   <c>true</c> if [has temporarily withdrawn] [the specified delivery]; otherwise, <c>false</c>.
 /// </returns>
 public bool HasTemporarilyWithdrawn(ILearningDelivery delivery) =>
 It.IsInRange(delivery?.CompStatus, CompletionState.HasTemporarilyWithdrawn);
コード例 #20
0
 /// <summary>
 /// Determines whether [is assessment price] [the specified record].
 /// </summary>
 /// <param name="record">The record.</param>
 /// <returns>
 ///   <c>true</c> if [is assessment price] [the specified record]; otherwise, <c>false</c>.
 /// </returns>
 public bool IsAssessmentPrice(IAppFinRecord record) =>
 It.IsInRange($"{record.AFinType}{record.AFinCode}", ApprenticeshipFinanicalRecord.TotalAssessmentPrice, ApprenticeshipFinanicalRecord.ResidualAssessmentPrice);
コード例 #21
0
        public TimeSpan MinimumViableAge => new TimeSpan(8766, 0, 0, 0); // 24 years

        /// <summary>
        /// Determines whether [is learner in custody] [the specified monitor].
        /// </summary>
        /// <param name="monitor">The monitor.</param>
        /// <returns>
        ///   <c>true</c> if [is learner in custody] [the specified monitor]; otherwise, <c>false</c>.
        /// </returns>
        public bool IsLearnerInCustody(ILearningDeliveryFAM monitor) =>
            It.IsInRange($"{monitor.LearnDelFAMType}{monitor.LearnDelFAMCode}", Monitoring.Delivery.OLASSOffendersInCustody);
コード例 #22
0
 /// <summary>
 /// Determines whether [is externally funded] [the specified delivery].
 /// </summary>
 /// <param name="delivery">The delivery.</param>
 /// <returns>
 ///   <c>true</c> if [is externally funded] [the specified delivery]; otherwise, <c>false</c>.
 /// </returns>
 public bool IsExternallyFunded(ILearningDelivery delivery) =>
 It.IsInRange(delivery.FundModel, TypeOfFunding.NotFundedByESFA);
コード例 #23
0
 /// <summary>
 /// Determines whether the specified monitor is restart.
 /// </summary>
 /// <param name="monitor">The monitor.</param>
 /// <returns>
 ///   <c>true</c> if the specified monitor is restart; otherwise, <c>false</c>.
 /// </returns>
 public bool IsRestart(ILearningDeliveryFAM monitor) =>
     It.IsInRange(monitor.LearnDelFAMType, Monitoring.Delivery.Types.Restart);
コード例 #24
0
 /// <summary>
 /// Determines whether [is hefce funded] [the specified monitor].
 /// </summary>
 /// <param name="monitor">The monitor.</param>
 /// <returns>
 ///   <c>true</c> if [is hefce funded] [the specified monitor]; otherwise, <c>false</c>.
 /// </returns>
 public bool IsHEFCEFunded(ILearningDeliveryFAM monitor) =>
 It.IsInRange($"{monitor.LearnDelFAMType}{monitor.LearnDelFAMCode}", Monitoring.Delivery.HigherEducationFundingCouncilEngland);
コード例 #25
0
 /// <summary>
 /// Determines whether [in receipt of low wages] [the specified monitor].
 /// </summary>
 /// <param name="monitor">The monitor.</param>
 /// <returns>
 ///   <c>true</c> if [is in receipt of low wages] [the specified monitor]; otherwise, <c>false</c>.
 /// </returns>
 public bool InReceiptOfLowWages(ILearningDeliveryFAM monitor) =>
     It.IsInRange($"{monitor.LearnDelFAMType}{monitor.LearnDelFAMCode}", Monitoring.Delivery.InReceiptOfLowWages);
コード例 #26
0
 /// <summary>
 /// Condition met.
 /// </summary>
 /// <param name="thisDelivery">this learning delivery.</param>
 /// <returns>
 /// true if any any point the conditions are met
 /// </returns>
 public bool ConditionMet(ILearningDelivery thisDelivery)
 {
     return(It.Has(thisDelivery)
         ? thisDelivery.AppFinRecords.SafeAny(afr => It.IsInRange(afr.AFinType, ApprenticeshipFinancialRecord.Types.TotalNegotiatedPrice))
         : true);
 }
コード例 #27
0
 /// <summary>
 /// Determines whether the specified delivery is funded.
 /// </summary>
 /// <param name="delivery">The delivery.</param>
 /// <returns>
 ///   <c>true</c> if the specified delivery is funded; otherwise, <c>false</c>.
 /// </returns>
 public bool IsAdultFunding(ILearningDelivery delivery) =>
     It.IsInRange(delivery.FundModel, TypeOfFunding.AdultSkills);
 /// <summary>
 /// Determines whether [has post GDPR merchandising codes] [the specified preference].
 /// </summary>
 /// <param name="preference">The preference.</param>
 /// <returns>
 ///   <c>true</c> if [has post GDPR merchandising codes] [the specified preference]; otherwise, <c>false</c>.
 /// </returns>
 public bool HasPostGDPRMerchandisingCodes(IContactPreference preference) =>
 It.IsInRange(
     $"{preference.ContPrefType}{preference.ContPrefCode}",
     ContactPreference.AgreesContactCoursesOrOpportunitiesPostGDPR,
     ContactPreference.AgreesContactSurveysAndResearchPostGDPR);
コード例 #29
0
        static void Main(string[] args)
        {
            var mock = new Mock <IFoo>();

            #region Methods

            // returns true when invoked with "concrete string"
            mock.Setup(foo => foo.DoSomething(It.IsAny <string>())).Returns <string>(s => s == "concrete string");

            // returns true when invoked with specific parameters
            mock.Setup(foo => foo.DoSomething("ping")).Returns(true);

            // throwing when invoked with specific parameters
            mock.Setup(foo => foo.DoSomething("reset")).Throws <InvalidOperationException>();
            mock.Setup(foo => foo.DoSomething("")).Throws(new ArgumentException("command"));

            // out arguments
            var outString = "this is out outString value";
            // TryParse will return true, and the out argument will return "ack", lazy evaluated
            mock.Setup(foo => foo.TryParse("ping", out outString)).Returns(true);

            // ref arguments
            var instance = new Bar();
            // Only matches if the ref argument to the invocation is the same instance
            mock.Setup(foo => foo.Submit(ref instance)).Returns(true);

            // access invocation arguments when returning a value
            mock.Setup(foo => foo.DoSomethingStringy(It.IsAny <string>())).Returns <string>(s => s.ToLower());
            // Multiple parameters overloads available

            var count = 13;
            // lazy evaluating return value
            mock.Setup(foo => foo.GetCount()).Returns(() => count);

            var calls = 0;
            mock.Setup(foo => foo.GetCountThing()).Returns(() => calls).Callback(() => calls++);
            // returns 0 on first invocation, 1 on the next, and so on

            Console.WriteLine(mock.Object.DoSomething("concrete string"));  // true
            Console.WriteLine(mock.Object.DoSomething("another string"));   // false

            Console.WriteLine(mock.Object.DoSomething("ping"));             // true
            Console.WriteLine(mock.Object.DoSomething("pong"));             // false

            try { Console.WriteLine(mock.Object.DoSomething("reset")); } catch (Exception e) { Console.WriteLine("{0}: {1}", e.GetType().FullName, e.Message); }
            try { Console.WriteLine(mock.Object.DoSomething("")); } catch (Exception e) { Console.WriteLine("{0}: {1}", e.GetType().FullName, e.Message); }

            string tmpString;
            Console.WriteLine(mock.Object.TryParse("ping", out tmpString));

            var tmpBar = new Bar();
            Console.WriteLine(mock.Object.Submit(ref tmpBar));             // false
            tmpBar = instance;
            Console.WriteLine(mock.Object.Submit(ref tmpBar));             // true

            Console.WriteLine(mock.Object.DoSomethingStringy("STRING IN UPPER CASE"));

            Console.WriteLine(mock.Object.GetCount());

            Console.WriteLine(mock.Object.GetCountThing());
            Console.WriteLine(mock.Object.GetCountThing());

            #endregion

            #region Matching Arguments

            // any value
            mock.Setup(foo => foo.DoSomething2(It.IsAny <string>())).Returns(true);

            // matching Func<int>, lazy evaluated
            mock.Setup(foo => foo.Add(It.Is <int>(i => i % 2 == 0))).Returns(true);

            // matching ranges
            mock.Setup(foo => foo.Add2(It.IsInRange <int>(0, 10, Range.Inclusive))).Returns(true);

            // matching regex
            mock.Setup(x => x.DoSomething3(It.IsRegex("[a-d]+", RegexOptions.IgnoreCase))).Returns("foo");

            Console.WriteLine(mock.Object.DoSomething2(null));             // true
            Console.WriteLine(mock.Object.DoSomething2(string.Empty));     // true
            Console.WriteLine(mock.Object.DoSomething2("blah-blah-blah")); // true

            Console.WriteLine(mock.Object.Add(12));                        // true
            Console.WriteLine(mock.Object.Add(13));                        // false

            Console.WriteLine(mock.Object.Add2(-1));                       // false
            Console.WriteLine(mock.Object.Add2(0));                        // true
            Console.WriteLine(mock.Object.Add2(5));                        // true
            Console.WriteLine(mock.Object.Add2(10));                       // true
            Console.WriteLine(mock.Object.Add2(11));                       // false

            Console.WriteLine(mock.Object.DoSomething3("aaa"));            // "foo"
            Console.WriteLine(mock.Object.DoSomething3("zzz"));            // null
            #endregion
        }
 /// <summary>
 /// Determines whether [is qualifying category] [the specified category].
 /// </summary>
 /// <param name="category">The category.</param>
 /// <returns>
 ///   <c>true</c> if [is qualifying category] [the specified category]; otherwise, <c>false</c>.
 /// </returns>
 public bool IsQualifyingCategory(ILARSLearningCategory category) =>
 It.IsInRange(category.CategoryRef, TypeOfLARSCategory.OnlyForLegalEntitlementAtLevel3);