Esempio n. 1
0
        public void UpdateSelectorWhenNewSelectorsAddsNewSelectors()
        {
            DkimEntityState state = CreateState(Domain, DkimState.Evaluated);

            DkimSelector selector1 = CreateSelector(Selector1);
            DkimSelector selector2 = CreateSelector(Selector2);
            DkimSelector selector3 = CreateSelector(Selector3);

            state.UpdateSelectors(new List <DkimSelector> {
                selector1, selector2
            }, out DkimSelectorsUpdated dkimSelectorsUpdated);

            bool updated = state.UpdateSelectors(new List <DkimSelector> {
                selector3
            }, out dkimSelectorsUpdated);

            Assert.That(updated, Is.True);

            Assert.That(state.Selectors.Count == 3);
            Assert.That(state.Selectors[0], Is.EqualTo(selector1));
            Assert.That(state.Selectors[1], Is.EqualTo(selector2));
            Assert.That(state.Selectors[2], Is.EqualTo(selector3));

            Assert.That(dkimSelectorsUpdated.Selectors.Count == 3);
            Assert.That(dkimSelectorsUpdated.Selectors[0] == selector1.Selector);
            Assert.That(dkimSelectorsUpdated.Selectors[1] == selector2.Selector);
            Assert.That(dkimSelectorsUpdated.Selectors[2] == selector3.Selector);
        }
Esempio n. 2
0
        public void UpdateSelectorsWhenNoNewSelectorsNothingChanges()
        {
            DkimEntityState state = CreateState(Domain, DkimState.Evaluated);

            DkimSelector selector1 = CreateSelector(Selector1);
            DkimSelector selector2 = CreateSelector(Selector2);

            state.UpdateSelectors(new List <DkimSelector> {
                selector1, selector2
            }, out DkimSelectorsUpdated _);

            bool updated = state.UpdateSelectors(new List <DkimSelector> {
                selector1, selector2
            }, out _);

            Assert.That(updated, Is.False);

            Assert.That(state.Selectors.Count == 2);
            Assert.That(state.Selectors[0], Is.EqualTo(selector1));
            Assert.That(state.Selectors[1], Is.EqualTo(selector2));
        }
        public async Task HandleAggregateReportDomainDkimSelectorsStateExistsAndEventCausesUpdate()
        {
            DkimEntityState dkimEntityState = A.Fake <DkimEntityState>();

            A.CallTo(() => dkimEntityState.Id).Returns(Id);
            A.CallTo(() => dkimEntityState.CanUpdate(A <string> ._, A <DateTime> ._)).Returns(true);

            DkimSelectorsUpdated dkimSelectorsUpdated;

            A.CallTo(() => dkimEntityState.UpdateSelectors(null, out dkimSelectorsUpdated)).WithAnyArguments().Returns(true);

            A.CallTo(() => _dkimEntityDao.Get(Id)).Returns(dkimEntityState);

            await _dkimEntity.Handle(new DkimSelectorsSeen("", "", Id, new List <string>()));

            A.CallTo(() => _dkimEntityDao.Save(A <DkimEntityState> ._)).MustHaveHappenedOnceExactly();
            A.CallTo(() => _dkimEntityDao.Save(A <DkimEntityState> ._)).MustHaveHappenedOnceExactly();
        }
        public async Task HandleAggregateReportDomainDkimSelectorsCantUpdateDoesNotContinue()
        {
            DkimEntityState dkimEntityState = A.Fake <DkimEntityState>();

            A.CallTo(() => dkimEntityState.Id).Returns(Id);
            A.CallTo(() => dkimEntityState.CanUpdate(A <string> ._, A <DateTime> ._)).Returns(false);

            DkimSelectorsUpdated dkimSelectorsUpdated;

            A.CallTo(() => dkimEntityState.UpdateSelectors(null, out dkimSelectorsUpdated)).WithAnyArguments().Returns(false);

            A.CallTo(() => _dkimEntityDao.Get(Id)).Returns(dkimEntityState);

            await _dkimEntity.Handle(new DkimSelectorsSeen("", "", Id, new List <string>()));

            A.CallTo(() => _dkimEntityDao.Save(A <DkimEntityState> ._)).MustNotHaveHappened();
            A.CallTo(() => _dispatcher.Dispatch(A <Common.Messaging.Abstractions.Message> ._, A <string> ._)).MustNotHaveHappened();
        }
        public async Task HandleDkimRecordsPolledCantUpdateDoesNotContinue()
        {
            DkimEntityState dkimEntityState = A.Fake <DkimEntityState>();

            A.CallTo(() => dkimEntityState.Id).Returns(Id);
            A.CallTo(() => dkimEntityState.CanUpdate(A <string> ._, A <DateTime> ._)).Returns(false);

            DkimSelectorsUpdated dkimSelectorsUpdated;

            A.CallTo(() => dkimEntityState.UpdateSelectors(null, out dkimSelectorsUpdated)).WithAnyArguments().Returns(false);

            A.CallTo(() => _dkimEntityDao.Get(Id)).Returns(dkimEntityState);

            await _dkimEntity.Handle(new DkimRecordEvaluationResult(Id, new List <DkimSelectorResult>()));

            A.CallTo(() => _changeNotifierComposite.Handle(A <DkimEntityState> ._, A <Message> ._)).MustNotHaveHappened();
            A.CallTo(() => _domainStatusPublisher.Publish(A <DkimRecordEvaluationResult> ._)).MustNotHaveHappened();
            A.CallTo(() => _dkimEntityDao.Save(A <DkimEntityState> ._)).MustNotHaveHappened();
            A.CallTo(() => _dispatcher.Dispatch(A <Common.Messaging.Abstractions.Message> ._, A <string> ._)).MustNotHaveHappened();
        }