public void ClearTest()
        {
            //arrange

            var dateCalculatorView = MockRepository.GenerateMock<IDateCalculatorView>();
            var calculatorController = new DateCalculatorController(dateCalculatorView);
            //act
            calculatorController.Clear();
            //assert
            dateCalculatorView.AssertWasCalled(x => x.EndDay = "");
            dateCalculatorView.AssertWasCalled(x => x.EndMonth = "");
            dateCalculatorView.AssertWasCalled(x => x.EndYear = "");
            dateCalculatorView.AssertWasCalled(x => x.StartDay = "");
            dateCalculatorView.AssertWasCalled(x => x.StartMonth = "");
            dateCalculatorView.AssertWasCalled(x => x.StartYear = "");
        }
 public void Calculation_WithEmptyVasluesInBoxes_DisplayMessage()
 {
     //arrange
     var dateCalculatorView = MockRepository.GenerateMock<IDateCalculatorView>();
     var calculatorController = new DateCalculatorController(dateCalculatorView);
     dateCalculatorView.Expect(x => x.StartDay).Return("");
     dateCalculatorView.Expect(x => x.StartMonth).Return("");
     dateCalculatorView.Expect(x => x.StartYear).Return("");
     dateCalculatorView.Expect(x => x.EndDay).Return("");
     dateCalculatorView.Expect(x => x.EndMonth).Return("");
     dateCalculatorView.Expect(x => x.EndYear).Return("");
     //act
     calculatorController.Calculate();
     //assert
     dateCalculatorView.AssertWasCalled(x => x.DisplayCustomMessageInValidationSummary("Please Provide numeric values in boxes"));
 }
 public void Calculation_WithStartDateAfterEndDateDisplayMessage()
 {
     //arrange
     var dateCalculatorView = MockRepository.GenerateMock<IDateCalculatorView>();
     var calculatorController = new DateCalculatorController(dateCalculatorView);
     dateCalculatorView.Expect(x => x.StartDay).Return("2");
     dateCalculatorView.Expect(x => x.StartMonth).Return("1");
     dateCalculatorView.Expect(x => x.StartYear).Return("2009");
     dateCalculatorView.Expect(x => x.EndDay).Return("1");
     dateCalculatorView.Expect(x => x.EndMonth).Return("1");
     dateCalculatorView.Expect(x => x.EndYear).Return("2009");
     //act
     calculatorController.Calculate();
     //assert
     dateCalculatorView.AssertWasCalled(x => x.DisplayCustomMessageInValidationSummary("Start date after end date. Dates were Switched"));
 }
 public void CalculationTest()
 {
     //arrange
     var dateCalculatorView = MockRepository.GenerateMock<IDateCalculatorView>();
     var calculatorController = new DateCalculatorController(dateCalculatorView);
     dateCalculatorView.Expect(x => x.StartDay).Return("1");
     dateCalculatorView.Expect(x => x.StartMonth).Return("1");
     dateCalculatorView.Expect(x => x.StartYear).Return("2009");
     dateCalculatorView.Expect(x => x.EndDay).Return("2");
     dateCalculatorView.Expect(x => x.EndMonth).Return("1");
     dateCalculatorView.Expect(x => x.EndYear).Return("2009");
     //act
     calculatorController.Calculate();
     //assert
     dateCalculatorView.AssertWasCalled(x => x.Result = "1");
 }
Пример #5
0
 protected override void OnInit(EventArgs e)
 {
     base.OnInit(e);
     this.controller = new DateCalculatorController(this);
 }