Exemplo n.º 1
0
        public TestHarness()
        {
            FuncNow = () => Now;
            Config  = new BotConfig()
            {
                InvitesPerEvent = 5, PizzaRoom = new PizzaRoom()
                {
                    City = "city", Room = "testroom"
                }, BotRoom = "botroom"
            };
            Core    = new Mock <IPizzaCore>();
            Storage = new Mock <IFileStorage>();
            Storage.Setup(s => s.SaveArray <Invitation>(PizzaInviter.INVITESFILE, It.IsAny <Invitation[]>()))
            .Callback <string, Invitation[]>((s, invites) => InvitationList = invites);
            Storage.Setup(s => s.SaveArray <PizzaPlan>(PizzaPlanner.ACTIVEEVENTSFILE, It.IsAny <PizzaPlan[]>()))
            .Callback <string, PizzaPlan[]>((s, plans) => ActivePizzaPlans = plans);
            Storage.Setup(s => s.SaveArray <PizzaPlan>(PizzaPlanner.OLDEVENTSFILE, It.IsAny <PizzaPlan[]>()))
            .Callback <string, PizzaPlan[]>((s, plans) => OldPizzaPlans = plans);

            Logger      = new Mock <ILogger>();
            Activity    = new Mock <IActivityLog>();
            OptOutState = new Mock <IOptOutState>();
            //Connection = new Mock<SlackSocketClient>();
            //Core.SetupGet(c => c.SocketClient).Returns(Connection.Object);

            OptOut  = new OptOutHandler(Logger.Object, Config, OptOutState.Object, Core.Object, Activity.Object, FuncNow);
            Inviter = new PizzaInviter(Logger.Object, Config, Storage.Object, Core.Object, Activity.Object, FuncNow);
            Planner = new PizzaPlanner(Logger.Object, Config, Storage.Object, Inviter, Core.Object, OptOutState.Object, Activity.Object, FuncNow);
        }
Exemplo n.º 2
0
 public ApiController(IPizzaCore core, PizzaPlanner planner)
 {
     _core    = core ?? throw new ArgumentNullException(nameof(core));;
     _planner = planner ?? throw new ArgumentNullException(nameof(planner));;
 }
Exemplo n.º 3
0
        public PizzaServiceHost(ILogger logger, CancellationTokenSource cts, IPizzaCore pizzaCore, IPizzaInviter inviter, PizzaPlanner planner, IOptOutHandler optOutHandler, IAnnouncementHandler annoucementHandler, IActivityLog activityLog)
        {
            _activityLog = activityLog ?? throw new ArgumentNullException(nameof(activityLog));
            _logger      = logger ?? throw new ArgumentNullException(nameof(logger));
            _cts         = cts ?? throw new ArgumentNullException(nameof(cts));
            _pizzaCore   = pizzaCore ?? throw new ArgumentNullException(nameof(pizzaCore));

            _resources = new List <IMustBeInitialized>()
            {
                inviter, planner, optOutHandler, annoucementHandler
            };
            _handlers = new List <IMessageHandler>()
            {
                inviter, optOutHandler
            };
        }