public void SpfRecordsReferencedWithSameMessageTest()
        {
            SpfEntityState state =
                new SpfEntityState(Id, 1, SpfState.Evaluated, DateTime.Now)
            {
                SpfRecords = NotifierTestUtil.CreateSpfRecords("spf1", terms:
                                                               new List <Term>
                {
                    new Include(Qualifier.Fail, "spf2", "abc.com", NotifierTestUtil.CreateSpfRecords("spf2", terms:
                                                                                                     new List <Term>
                    {
                        new Include(Qualifier.Fail, "spf3", "abc.com", NotifierTestUtil.CreateSpfRecords("spf3"), false)
                    }), false)
                })
            };

            SpfRecordsEvaluated message =
                new SpfRecordsEvaluated(Id, NotifierTestUtil.CreateSpfRecords("spf1", terms:
                                                                              new List <Term>
            {
                new Include(Qualifier.Fail, "spf2", "abc.com", NotifierTestUtil.CreateSpfRecords("spf2", terms:
                                                                                                 new List <Term>
                {
                    new Include(Qualifier.Fail, "spf3", "abc.com", NotifierTestUtil.CreateSpfRecords("spf3"), false)
                }), false)
            }), 1, TimeSpan.MinValue, new List <Message>(), DateTime.UtcNow);

            _changeNotifier.Handle(state, message);

            NotifierTestUtil.VerifyResults(_dispatcher, referencedChange: true);
        }
        public void SpfRecordsAreDifferentTest()
        {
            SpfEntityState state =
                new SpfEntityState(Id, 1, SpfState.Evaluated, DateTime.Now)
            {
                SpfRecords = NotifierTestUtil.CreateSpfRecords("spf1")
            };
            SpfRecordsEvaluated message =
                new SpfRecordsEvaluated(Id, NotifierTestUtil.CreateSpfRecords("spf2"), 1, TimeSpan.MinValue, new List <Message>(), DateTime.UtcNow);


            _changeNotifier.Handle(state, message);

            NotifierTestUtil.VerifyResults(_dispatcher, record: true, added: true, removed: true);

            A.CallTo(() => _dispatcher.Dispatch(A <SpfRecordAdded> ._, A <string> ._)).MustHaveHappenedOnceExactly();
            A.CallTo(() => _dispatcher.Dispatch(A <SpfRecordRemoved> ._, A <string> ._)).MustHaveHappenedOnceExactly();

            A.CallTo(() => _dispatcher.Dispatch(A <SpfRecordAdded> .That.Matches(
                                                    _ => _.Records.Count == 1 && _.Records[0].Equals("spf2")),
                                                A <string> ._))
            .MustHaveHappenedOnceExactly();

            A.CallTo(() => _dispatcher.Dispatch(A <SpfRecordRemoved> .That.Matches(
                                                    _ => _.Records.Count == 1 && _.Records[0].Equals("spf1")),
                                                A <string> ._))
            .MustHaveHappenedOnceExactly();
        }
Ejemplo n.º 3
0
        public void SpfRecordsWithDifferentReferencesTest()
        {
            SpfEntityState state =
                new SpfEntityState(Id, 1, SpfState.Evaluated, DateTime.Now)
            {
                SpfRecords = NotifierTestUtil.CreateSpfRecords("spf1", terms:
                                                               new List <Term>
                {
                    new Include(Qualifier.Fail, "spf2", "abc.com", NotifierTestUtil.CreateSpfRecords("spf2", terms:
                                                                                                     new List <Term>
                    {
                        new Include(Qualifier.Fail, "spf3", "abc.com", NotifierTestUtil.CreateSpfRecords("spf3"), false)
                    }), false)
                })
            };
            SpfRecordsEvaluated message =
                new SpfRecordsEvaluated(Id, NotifierTestUtil.CreateSpfRecords("spf1", terms: new List <Term>
            {
                new Include(Qualifier.Fail, "spf2", "abc.com", NotifierTestUtil.CreateSpfRecords("spf2"), false)
            }), 1, TimeSpan.MinValue, new List <Message>(), DateTime.UtcNow);


            _changeNotifier.Handle(state, message);

            NotifierTestUtil.VerifyResults(_dispatcher, referencedChange: true, removed: true, record: true);

            FakeItEasy.A.CallTo(() => _dispatcher.Dispatch(A <SpfReferencedRecordAdded> ._, A <string> ._)).MustNotHaveHappened();

            FakeItEasy.A.CallTo(() => _dispatcher.Dispatch(A <SpfReferencedRecordRemoved> .That.Matches(
                                                               _ => _.Records.Count == 1 && _.Records[0].Equals("spf3")),
                                                           A <string> ._))
            .MustHaveHappenedOnceExactly();
        }
Ejemplo n.º 4
0
        public void SpfRecordsWithSameMessageIdAndDifferentMessageTypeDoesNotRaiseANotificationTest()
        {
            Guid id = Guid.NewGuid();

            SpfRecords spfRecords =
                NotifierTestUtil.CreateSpfRecords(messages: new List <Message>
            {
                new Message(id, "SPF", MessageType.warning, "hello", "markdown")
            });

            SpfEntityState state =
                new SpfEntityState(Id, 1, SpfState.Evaluated, DateTime.Now)
            {
                SpfRecords =
                    NotifierTestUtil.CreateSpfRecords(messages: new List <Message>
                {
                    new Message(id, "SPF", MessageType.error, "world", "markdown")
                })
            };
            SpfRecordsEvaluated message = new SpfRecordsEvaluated(Id, spfRecords, 1, TimeSpan.MinValue, new List <Message>(), DateTime.UtcNow);

            _changeNotifier.Handle(state, message);

            NotifierTestUtil.VerifyResults(_dispatcher, removed: false, added: false);

            FakeItEasy.A.CallTo(() => _dispatcher.Dispatch(A <SpfAdvisoryAdded> ._, A <string> ._))
            .MustNotHaveHappened();
            FakeItEasy.A.CallTo(() => _dispatcher.Dispatch(A <SpfAdvisoryRemoved> ._, A <string> ._))
            .MustNotHaveHappened();
        }
        public void SpfRecordsAreSameTest()
        {
            SpfEntityState state =
                new SpfEntityState(Id, 1, SpfState.Evaluated, DateTime.Now)
            {
                SpfRecords = NotifierTestUtil.CreateSpfRecords()
            };
            SpfRecordsPolled message =
                new SpfRecordsPolled(Id, NotifierTestUtil.CreateSpfRecords(), 1, TimeSpan.FromSeconds(1));


            _changeNotifier.Handle(state, message);

            NotifierTestUtil.VerifyResults(_dispatcher);
        }
Ejemplo n.º 6
0
        public void SpfRecordsWithSameMessageTest()
        {
            SpfRecords spfRecords =
                NotifierTestUtil.CreateSpfRecords();

            SpfEntityState state =
                new SpfEntityState(Id, 1, SpfState.Evaluated, DateTime.Now)
            {
                SpfRecords = NotifierTestUtil.CreateSpfRecords()
            };
            SpfRecordsEvaluated message = new SpfRecordsEvaluated(Id, spfRecords, 1, TimeSpan.MinValue, new List <Message>(), DateTime.UtcNow);

            _changeNotifier.Handle(state, message);

            NotifierTestUtil.VerifyResults(_dispatcher);
        }
        public void SpfRecordsReferencedWithSameMessageIdAndDifferentMessageTypeDoesNotRaiseANotificationTest()
        {
            Guid id = Guid.NewGuid();

            SpfEntityState state =
                new SpfEntityState(Id, 1, SpfState.Evaluated, DateTime.Now)
            {
                SpfRecords = NotifierTestUtil.CreateSpfRecords("spf1", terms:
                                                               new List <Term>
                {
                    new Include(Qualifier.Fail, "spf2", "abc.com", NotifierTestUtil.CreateSpfRecords("spf2", terms:
                                                                                                     new List <Term>
                    {
                        new Include(Qualifier.Fail, "spf3", "abc.com",
                                    NotifierTestUtil.CreateSpfRecords("spf3",
                                                                      new List <Message>
                        {
                            new Message(id, "SPF", MessageType.warning, "hello world", "markdown")
                        }), false)
                    }), false)
                })
            };
            SpfRecordsEvaluated message =
                new SpfRecordsEvaluated(Id, NotifierTestUtil.CreateSpfRecords("spf1", terms:
                                                                              new List <Term>
            {
                new Include(Qualifier.Fail, "spf2", "abc.com", NotifierTestUtil.CreateSpfRecords("spf2", terms:
                                                                                                 new List <Term>
                {
                    new Include(Qualifier.Fail, "spf3", "abc.com",
                                NotifierTestUtil.CreateSpfRecords("spf3",
                                                                  new List <Message>
                    {
                        new Message(id, "SPF", MessageType.error, "hello world", "markdown")
                    }), false)
                }), false)
            }), 1, TimeSpan.MinValue, new List <Message>(), DateTime.UtcNow);


            _changeNotifier.Handle(state, message);

            NotifierTestUtil.VerifyResults(_dispatcher);

            FakeItEasy.A.CallTo(() => _dispatcher.Dispatch(A <SpfReferencedAdvisoryAdded> ._, A <string> ._)).MustNotHaveHappened();
            FakeItEasy.A.CallTo(() => _dispatcher.Dispatch(A <SpfReferencedAdvisoryRemoved> ._, A <string> ._)).MustNotHaveHappened();
        }
        public void SpfRecordsReferencedWithDifferentMessageTest()
        {
            SpfEntityState state =
                new SpfEntityState(Id, 1, SpfState.Evaluated, DateTime.Now)
            {
                SpfRecords = NotifierTestUtil.CreateSpfRecords("spf1", terms:
                                                               new List <Term>
                {
                    new Include(Qualifier.Fail, "spf2", "abc.com", NotifierTestUtil.CreateSpfRecords("spf2", terms:
                                                                                                     new List <Term>
                    {
                        new Include(Qualifier.Fail, "spf3", "abc.com", NotifierTestUtil.CreateSpfRecords("spf3"), false)
                    }), false)
                })
            };
            SpfRecordsEvaluated message =
                new SpfRecordsEvaluated(Id, NotifierTestUtil.CreateSpfRecords("spf1", terms:
                                                                              new List <Term>
            {
                new Include(Qualifier.Fail, "spf2", "abc.com", NotifierTestUtil.CreateSpfRecords("spf2", terms:
                                                                                                 new List <Term>
                {
                    new Include(Qualifier.Fail, "spf3", "abc.com",
                                NotifierTestUtil.CreateSpfRecords("spf3",
                                                                  new List <Message>
                    {
                        new Message(Guid.NewGuid(), "SPF", MessageType.info, "hello world", "markdown")
                    }), false)
                }), false)
            }), 1, TimeSpan.MinValue, new List <Message>(), DateTime.UtcNow);


            _changeNotifier.Handle(state, message);

            NotifierTestUtil.VerifyResults(_dispatcher, referencedChange: true, added: true);

            FakeItEasy.A.CallTo(() => _dispatcher.Dispatch(A <SpfReferencedAdvisoryAdded> ._, A <string> ._)).MustHaveHappenedOnceExactly();
            FakeItEasy.A.CallTo(() => _dispatcher.Dispatch(A <SpfReferencedAdvisoryRemoved> ._, A <string> ._)).MustNotHaveHappened();

            FakeItEasy.A.CallTo(() => _dispatcher.Dispatch(A <SpfReferencedAdvisoryAdded> .That.Matches(
                                                               _ => _.Messages.Count == 1 && _.Messages[0].Text.Equals("hello world") && _.Messages[0].MessageType.ToString().Equals("info")),
                                                           A <string> ._))
            .MustHaveHappenedOnceExactly();
        }
Ejemplo n.º 9
0
        public void SpfRecordsWithDifferentMessageTest()
        {
            SpfRecords spfRecords =
                NotifierTestUtil.CreateSpfRecords(messages: new List <Message>
            {
                new Message(Guid.NewGuid(), "SPF", MessageType.info, "hello", "markdown")
            });

            SpfEntityState state =
                new SpfEntityState(Id, 1, SpfState.Evaluated, DateTime.Now)
            {
                SpfRecords =
                    NotifierTestUtil.CreateSpfRecords(messages: new List <Message>
                {
                    new Message(Guid.NewGuid(), "SPF", MessageType.error, "world", "markdown")
                })
            };
            SpfRecordsEvaluated message = new SpfRecordsEvaluated(Id, spfRecords, 1, TimeSpan.MinValue, new List <Message>(), DateTime.UtcNow);

            _changeNotifier.Handle(state, message);

            NotifierTestUtil.VerifyResults(_dispatcher, removed: true, added: true);

            FakeItEasy.A.CallTo(() => _dispatcher.Dispatch(A <SpfAdvisoryAdded> ._, A <string> ._))
            .MustHaveHappenedOnceExactly();
            FakeItEasy.A.CallTo(() => _dispatcher.Dispatch(A <SpfAdvisoryRemoved> ._, A <string> ._))
            .MustHaveHappenedOnceExactly();

            FakeItEasy.A.CallTo(() => _dispatcher.Dispatch(A <SpfAdvisoryRemoved> .That.Matches(
                                                               _ => _.Messages.Count == 1 && _.Messages[0].Text.Equals("world") && _.Messages.Count == 1 &&
                                                               _.Messages[0].MessageType.ToString().Equals("error")),
                                                           A <string> ._))
            .MustHaveHappenedOnceExactly();

            FakeItEasy.A.CallTo(() => _dispatcher.Dispatch(A <SpfAdvisoryAdded> .That.Matches(
                                                               _ => _.Messages.Count == 1 && _.Messages[0].Text.Equals("hello") && _.Messages.Count == 1 &&
                                                               _.Messages[0].MessageType.ToString().Equals("info")),
                                                           A <string> ._))
            .MustHaveHappenedOnceExactly();
        }