コード例 #1
0
        /**
         * <summary>
         * Helper method for display any action that uses the "_ApplicantDetails.cshtml" partial view.
         * </summary>
         **/
        private void PrepareApplicantDetailView(Applicant applicant)
        {
            // Applied schools
            var applieds = db.Applieds.Where(a => a.ApplicantID == applicant.ID).OrderBy(a => a.School.Name).ToList();

            ViewBag.AppliedSchools = Utils.GetSchools(applieds);

            // Selected school
            var selected = db.Selecteds.FirstOrDefault(s => s.ApplicantID == applicant.ID);

            if (selected != null)
            {
                ViewBag.SelectedSchool = selected.School;
            }

            // Waitlisted schools
            ViewBag.WaitlistedSchools =
                Utils.GetSchools(db.Waitlisteds.Where(a => a.ApplicantID == applicant.ID).OrderBy(a => a.School.Name).ToList());
            ViewBag.WasLotteryRun = GetLotteryRunDate() != null;

            // Income status
            var incomeCalc = new IncomeCalculator(db);

            ViewBag.IsBelowPoverty = incomeCalc.IsBelowPovertyLine(applicant);
        }
コード例 #2
0
        public void CalculateTodayOrderIncomeMoney()
        {
            JieshaiManager jieshaiManager = new JieshaiManager();

            IncomeCalculator orderIncomeCalculator = new IncomeCalculator(null, null);
            var money1 = orderIncomeCalculator.CalculateTodayOrderIncomeMoney(99);

            Assert.Equal((99 - 10) * 30, money1);

            var money2 = orderIncomeCalculator.CalculateTodayOrderIncomeMoney(160);

            Assert.Equal((100 - 10) * 30 + (160 - 100) * 40, money2);

            var money3 = orderIncomeCalculator.CalculateTodayOrderIncomeMoney(360);

            Assert.Equal((100 - 10) * 30 + (300 - 100) * 40 + (360 - 300) * 50, money3);

            var money4 = orderIncomeCalculator.CalculateTodayOrderIncomeMoney(2600);

            Assert.Equal((100 - 10) * 30 + (300 - 100) * 40 + (1000 - 300) * 50 + (2600 - 1000) * 60, money4);

            var money5 = orderIncomeCalculator.CalculateTodayOrderIncomeMoney(6600);

            Assert.Equal((100 - 10) * 30 + (300 - 100) * 40 + (1000 - 300) * 50 + (3000 - 1000) * 60 + (6600 - 3000) * 80, money5);
        }
コード例 #3
0
        public void SetUp()
        {
            // Make a fake implementation of ICalcMethod which returns default values
            calcMethod = A.Fake <ICalcMethod>();

            // Make an instance of the real class under test
            calc = new IncomeCalculator();
        }
コード例 #4
0
ファイル: UnitTest1.cs プロジェクト: Jogwithaj/QAAgileCode
        public void testNoPosition()
        {
            var mockDep = new Mock <ICalcMethod>();

            mockDep.Setup(m => m.calc(Position.BOSS)).Returns(70000.0);

            calc            = new IncomeCalculator();
            calc.CalcMethod = mockDep.Object;
            Assert.Throws <Exception>(() => calc.Calc());
        }
        public EfcCalculator GetEfcCalculator()
        {
            EfcCalculatorConstants      constants      = GetEfcCalculatorConstants();
            IncomeCalculator            incomeCalc     = GetIncomeCalculator();
            AllowanceCalculator         allowanceCalc  = GetAllowanceCalculator();
            AssetContributionCalculator assetContrCalc = GetAssetContributionCalculator();
            AaiContributionCalculator   aaiContrCalc   = GetAaiContributionCalculator();

            return(new EfcCalculator(constants, incomeCalc, allowanceCalc, assetContrCalc, aaiContrCalc));
        }
コード例 #6
0
        public void TestResourcesPerWaveForBrutas(RoomNumber room, DifficultyLevel diff, double expectedMinerals, double expectedKills)
        {
            var loadout = TestHelper.GetTestLoadout();

            loadout.SetDifficulty(diff);
            loadout.SetFarmRoom(room);
            var calc = new IncomeCalculator(loadout);

            Assert.That(calc.GetMineralsPerMinute(), Is.EqualTo(expectedMinerals).Within(0.1));
            Assert.That(calc.GetKillsPerMinute(), Is.EqualTo(expectedKills).Within(0.1));
        }
コード例 #7
0
ファイル: UnitTest1.cs プロジェクト: Jogwithaj/QAAgileCode
        public void testCalc2()
        {
            var mockDep = new Mock <ICalcMethod>();

            mockDep.Setup(m => m.calc(Position.SURFER)).Throws <Exception>();

            calc            = new IncomeCalculator();
            calc.Position   = Position.SURFER;
            calc.CalcMethod = mockDep.Object;
            Assert.Throws <Exception>(() => calc.Calc());
        }
コード例 #8
0
        public void IncomeCalculator_ThrowsException_WhenExpected()
        {
            var mockDep = new Mock <ICalcMethod>();

            // TODO 6: Use a Setup to Throw an Exception when Position.SURFER is passed
            // HINT: Use Throws<>

            calc            = new IncomeCalculator();
            calc.Position   = Position.SURFER;
            calc.CalcMethod = mockDep.Object;
            Assert.Throws <Exception>(() => calc.Calc());
        }
コード例 #9
0
        public void Init()
        {
            EfcCalculatorConstants constants = TestConstantsFactory.GetEfcCalculatorConstants();

            IncomeCalculator incomeCalculator
                = new IncomeCalculator(TestConstantsFactory.GetIncomeCalculatorConstants());
            AllowanceCalculator allowanceCalculator
                = new AllowanceCalculator(TestConstantsFactory.GetAllowanceCalculatorConstants());
            AssetContributionCalculator assetContributionCalculator
                = new AssetContributionCalculator(TestConstantsFactory.GetAssetContributionCalculatorConstants());
            AaiContributionCalculator aaiContributionCalculator 
                = new AaiContributionCalculator(TestConstantsFactory.GetAaiContributionCalculatorConstants());

            _efcCalculator = new EfcCalculator(constants, 
                incomeCalculator, allowanceCalculator,
                assetContributionCalculator, aaiContributionCalculator);
        }
コード例 #10
0
        public void Init()
        {
            EfcCalculatorConstants constants = TestConstantsFactory.GetEfcCalculatorConstants();

            IncomeCalculator incomeCalculator
                = new IncomeCalculator(TestConstantsFactory.GetIncomeCalculatorConstants());
            AllowanceCalculator allowanceCalculator
                = new AllowanceCalculator(TestConstantsFactory.GetAllowanceCalculatorConstants());
            AssetContributionCalculator assetContributionCalculator
                = new AssetContributionCalculator(TestConstantsFactory.GetAssetContributionCalculatorConstants());
            AaiContributionCalculator aaiContributionCalculator
                = new AaiContributionCalculator(TestConstantsFactory.GetAaiContributionCalculatorConstants());

            _efcCalculator = new EfcCalculator(constants,
                                               incomeCalculator, allowanceCalculator,
                                               assetContributionCalculator, aaiContributionCalculator);
        }
コード例 #11
0
ファイル: UnitTest1.cs プロジェクト: Jogwithaj/QAAgileCode
        public void testCalc1()
        {
            var mockDep = new Mock <ICalcMethod>();

            mockDep.Setup(m => m.calc(Position.BOSS)).Returns(70000.0);
            mockDep.Setup(m => m.calc(Position.PROGRAMMER)).Returns(50000.0);

            calc            = new IncomeCalculator();
            calc.CalcMethod = mockDep.Object;
            Assert.Throws <Exception>(() => calc.Calc());

            calc.Position = Position.BOSS;
            Assert.Equal(70000.0, calc.Calc());

            calc.Position = Position.PROGRAMMER;
            Assert.Equal(50000.0, calc.Calc());
        }
コード例 #12
0
        public void IncomeCalculator_ReturnsExpectedResult_WhenPositionIsSupplied()
        {
            var mockDep = new Mock <ICalcMethod>();

            /* TODO 2
             * Use the Setup method with a lambda to mock the calc method of ICalclMethod
             * eg to mock an Add method of an ICalculate interface I might write :
             * mockDep.Setup(m=> m.Add("").Returns(0));
             * mockDep.Setup(m=> m.Add("1,2").Returns(3));
             */

            calc = new IncomeCalculator();
            // TODO 3: Inject your mock object
            //calc.CalcMethod = mockDep.Object;
            calc.Position = Position.BOSS;
            // TODO 4: Write an Assert to test

            calc.Position = Position.PROGRAMMER;
            // TODO 5: Write an Assert to test
        }
 public void Init()
 {
     IncomeCalculatorConstants constants = TestConstantsFactory.GetIncomeCalculatorConstants();
     _incomeCalculator = new IncomeCalculator(constants);
 }
コード例 #14
0
ファイル: UnitTest1.cs プロジェクト: Jogwithaj/QAAgileCode
 public IncomeCalculatorTest()
 {
     // NiceMocks return default values for unimplemented methods
     calc = new IncomeCalculator();
 }
コード例 #15
0
 public void IncomeCalculator_ThrowsException_WhenNoCalcMethodIsSet()
 {
     calc          = new IncomeCalculator();
     calc.Position = Position.SURFER;
     // TODO 1: Check calc.Calc() throws Exception when CalcMethod is not set
 }
コード例 #16
0
 public IncomeCalculatorTest()
 {
     calc = new IncomeCalculator();
 }
        public void Init()
        {
            IncomeCalculatorConstants constants = TestConstantsFactory.GetIncomeCalculatorConstants();

            _incomeCalculator = new IncomeCalculator(constants);
        }