Esempio n. 1
0
        protected override void PerformAdmin(Domain.IncomingSmsMessage message)
        {
            string newIdea;

            if (TryCrackMessage(message.Message, out newIdea))
            {
                IDataStore store = DataStore.GetInstance();
                DailyIdea  idea  = store.DailyIdeas.Where(i => i.Idea == newIdea).FirstOrDefault();

                if (idea == null)
                {
                    idea = new DailyIdea
                    {
                        Idea = newIdea,
                    };
                    store.Save(idea);

                    Say(message.From, SmsResponseStrings.Add_Success_AddedNewIdea(idea.Id));
                }
                else
                {
                    Say(message.From, SmsResponseStrings.Add_Failed_ExistingIdea(idea.Id));
                }
            }
            else
            {
                Say(message.From, SmsResponseStrings.Add_Help());
            }
        }
Esempio n. 2
0
        public void Perform_RealAdmin_Help()
        {
            string             destination = Configuration.GetInstance().AdminNumber;
            Add_Accessor       target      = new Add_Accessor(); // TODO: Initialize to an appropriate value
            IncomingSmsMessage message     = new IncomingSmsMessage
            {
                From    = destination,
                Message = "add",
            };

            target.Perform(message);

            IDataStore store = DataStore.GetInstance();

            Assert.AreEqual(0, store.DailyIdeas.Count());
            OutgoingMessageExists(destination, SmsResponseStrings.Add_Help());
        }