Exemplo n.º 1
0
        public async Task DoesNotOldIfSearchReturnsEventMessage()
        {
            var newMessage = new Event
            {
                Channel = "CGWGZ90KV", // private channel #bottestsmore
                Text    = "SomeMessage containing an URL http://db.no",
                Ts      = "1552671375.000200"
            };
            var payload = new SlackEventAPIPayload
            {
                Event = newMessage
            };

            var body = JsonConvert.SerializeObject(payload, JsonSettings.SlackSettings);

            var request = new APIGatewayProxyRequest
            {
                Body = body
            };

            var mockClient = new MockClient();

            mockClient.SetSearchResponse(newMessage);

            var validateOldness = new OldnessValidator(mockClient);

            var response = await validateOldness.Validate(request, new TestLambdaContext());

            Assert.Equal(200, response.StatusCode);
            Assert.Equal("NEW", response.Body);
        }
Exemplo n.º 2
0
        public async Task DoesNotOldIfIsSameAuthor()
        {
            var mockClient = new MockClient();

            var existingMessage = new Event
            {
                Text = "A historic tale. I told you about http://db.no some time ago",
                User = "******",
                Ts   = "1550000000.000000" //
            };

            mockClient.SetSearchResponse(existingMessage);

            var newMessage = new SlackEventAPIPayload
            {
                Event = new Event
                {
                    Text = "Woot, me, U0F3P72QM, is repeating the url http://db.no some time later",
                    User = "******",
                    Ts   = "1660000000.000000"
                }
            };

            var body = JsonConvert.SerializeObject(newMessage, JsonSettings.SlackSettings);

            var request = new APIGatewayProxyRequest
            {
                Body = body
            };

            var validateOldness = new OldnessValidator(mockClient);

            var response = await validateOldness.Validate(request, new TestLambdaContext());

            Assert.Equal(200, response.StatusCode);
            Assert.Equal("OLD-BUT-SAME-USER-SO-IGNORING", response.Body);
        }