Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            // **** Registering
            var container = new WindsorContainer();

            container.Register(Component.For <DbContext>().ImplementedBy <DonationContext>());
            container.Register(Component.For <IRepository>().ImplementedBy <GiftAidRepository>());
            container.Register(Component.For <IDecimalHelper>().ImplementedBy <DecimalHelper>());
            container.Register(Component.For <IDonor>().ImplementedBy <Donor>());
            container.Register(Component.For <ISiteAdministrator>().ImplementedBy <SiteAdministrator>());
            container.Register(Component.For <IEventPromoterSwimming>().ImplementedBy <EventPromoterSwimming>());
            container.Register(Component.For <IEventPromoterRunning>().ImplementedBy <EventPromoterRunning>());
            container.Register(Component.For <IEventPromoterOther>().ImplementedBy <EventPromoterOther>());

            // **** Resolving

            _Repository            = container.Resolve <IRepository>();
            _DecimalHelper         = container.Resolve <IDecimalHelper>();
            _Doner                 = container.Resolve <IDonor>();
            _SiteAdministrator     = container.Resolve <ISiteAdministrator>();
            _EventPromoterRunning  = container.Resolve <IEventPromoterRunning>();
            _EventPromoterSwimming = container.Resolve <IEventPromoterSwimming>();
            _EventPromoterOther    = container.Resolve <IEventPromoterOther>();

            DefineRole();
        }
Ejemplo n.º 2
0
        public static void DonorCmds()
        {
            _Doner = new Donor();
            // I've commented out this line because it's trying to talk to a db that doesn't exist
            // In a live system I would use repository pattern to get the data

            //decimal tax = repository
            //              .GetTaxByCode("5RT6").TaxRate;
            decimal tax = 20.00M;

            ValidateInput validInput = new ValidateInput();

            Console.WriteLine("Please Enter donation amount:");
            string s = Console.ReadLine();
            if (validInput.IsDecimal(s))
            {
                _Doner.DonationAmount = validInput.RoundTwoDecimalPlaces(validInput.ConvertToDecimal(s));
                Console.WriteLine("Gift aid is: £" + _Doner.CalculateGiftAid(_Doner.DonationAmount, tax).ToString());
                QuitApp("donor");
            }
            else
            {
                Console.WriteLine("Unrecognised number. Please try again.");
                DonorCmds();
            }
        }
Ejemplo n.º 3
0
 public EventPromoterRunning(IRepository repository, IDonor donor)
 {
     _Repository = repository;
     _Donor      = donor;
 }
Ejemplo n.º 4
0
 public EventPromoterOther(IDonor donor)
 {
     _Donor = donor;
 }
Ejemplo n.º 5
0
 public void TearDown()
 {
     _Repository = null;
     _Donor      = null;
 }
Ejemplo n.º 6
0
 public void Setup()
 {
     _Repository = new Mock <IRepository>();
     _Donor      = new Donor(_Repository.Object);
 }
Ejemplo n.º 7
0
 public void Setup()
 {
     _ValidInput = new ValidateInput();
     _Donor = new Donor();
     _Repository = new Mock<IRepository>();
 }
Ejemplo n.º 8
0
        public void InitTestDate()
        {
            _giftAidCalculator = new Donor();

            _decTaxRate = 20;
            _strTaxRate = "20.4534";
            _strDonationAmount = "545.97645";
            _decGiftAidAmount = (_decDonationAmount / 100) * _decTaxRate;
        }
Ejemplo n.º 9
0
 public void Setup()
 {
     _RunningPromoter = new EventsPromoterRunning();
     _SwimmingPromoter = new EventsPromoterSwimming();
     _OtherPromoter = new EventsPromoterOther();
     _Donor = new Donor();
 }
 public BecomeADonorController(IDonor i)
 {
     o = i;
 }