Exemplo n.º 1
0
        static void Main(string[] args)
        {
            MessageBody mb = new MessageBody();

            mb.Configure("Hello World");
            AbstractStrategyFactory asf      = DefaultFactory.GetInstance();
            MessageStrategy         strategy = asf.CreateStrategy(mb);

            mb.Send(strategy);
        }
Exemplo n.º 2
0
        public async Task ShouldGetLatestMessageFromConversation()
        {
            MessageStrategy facebookService = DependencyResolver.Resolve <MessageStrategy>();
            FbMessage       message         = await FacebookService.GetLastMessageFromConversationId
                                                  (TestFacebookAccount.Token, "t_mid.$cAAdZrm4k4UZh9X1vd1bxDgkg7Bo9");

            Assert.NotNull(message);
            Assert.NotEmpty(message.Id);
            Assert.NotEmpty(message.SenderId);
            Assert.NotEmpty(message.ReceiverId);
            //Assert.NotNull(message.SenderEmail);
            //Assert.NotNull(message.FacebookConversationId);
        }
Exemplo n.º 3
0
        public static byte[] GetMessage(object obj, Guid guid, MessageStrategy messageStrategy = MessageStrategy.NoHeader)
        {
            if (obj == null)
            {
                throw new ArgumentNullException($"Cannot convert null obj to message {nameof(obj)}");
            }

            if (messageStrategy == MessageStrategy.Header)
            {
                return(GetMessageWithHeader(obj, guid));
            }

            return(GetMessageWithoutHeader(obj, guid));
        }
Exemplo n.º 4
0
        public void TestShouldStore()
        {
            DateTime        now      = new DateTime(2021, 4, 21, 10, 0, 0);
            MessageStrategy strategy = new MessageStrategy(new TestTimeProvider(now));

            Message evenMessage = new Message()
            {
                Sent = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, 0)
            };
            Message oddMessage = new Message()
            {
                Sent = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, 1)
            };

            Assert.True(strategy.ShouldStore(evenMessage), "EVEN should be stored");
            Assert.False(strategy.ShouldStore(oddMessage), "ODD should not be stored");
        }
Exemplo n.º 5
0
        public void TestShoudProcess()
        {
            DateTime        now      = new DateTime(2021, 4, 21, 10, 0, 0);
            MessageStrategy strategy = new MessageStrategy(new TestTimeProvider(now));

            Message notTooOld = new Message()
            {
                Sent = now.AddSeconds(-59)
            };

            Assert.True(strategy.ShouldProcess(notTooOld), "not too old should be processed");

            Message tooOld = new Message()
            {
                Sent = now.AddMinutes(-1)
            };

            Assert.False(strategy.ShouldProcess(tooOld), "too old should not be processed");
        }
 public void Send(MessageStrategy ms)
 {
     ms.SendMessage();
 }