コード例 #1
0
        public void Can_Add_New_Mementos_To_Caretaker()
        {
            var careTaker = new HastingsCareTaker();

            var stack = new Stack <IHastingsMemento>();

            stack.Push(DiscoveryHelper.SubMemento(_ownNode));

            var history = DiscoveryHelper.MockMementoHistory(stack);

            history.ToList().ForEach(m => careTaker.Add(m));

            careTaker.HastingMementoList.Should().Contain(history);
        }
コード例 #2
0
        public void Taking_From_Memento_List_Takes_LIFO()
        {
            var careTaker = new HastingsCareTaker();

            var stack = new Stack <IHastingsMemento>();

            stack.Push(DiscoveryHelper.SubMemento(_ownNode));

            var history = DiscoveryHelper.MockMementoHistory(stack);

            history.ToList().ForEach(m => careTaker.Add(m));

            careTaker.Get().Should().Be(history.Last());
            careTaker.HastingMementoList.First().Should().Be(history.First());
            careTaker.HastingMementoList.Count.Should().Be(history.Count - 1);
        }
コード例 #3
0
        public void Evicted_Known_Ping_Message_Sets_Contacted_Neighbour_As_UnReachable_And_Can_RollBack_State()
        {
            var cacheEntriesByRequest = new Dictionary <ByteString, ICacheEntry>();

            var seedState  = DiscoveryHelper.MockSeedState(_ownNode, _settings);
            var seedOrigin = HastingsOriginator.Default;

            seedOrigin.RestoreMemento(seedState);
            var stateCareTaker = new HastingsCareTaker();
            var stateHistory   = new Stack <IHastingsMemento>();

            stateHistory.Push(seedState);

            stateHistory =
                DiscoveryHelper.MockMementoHistory(stateHistory, 5); //this isn't an angry pirate this is just 5

            stateHistory.Last().Neighbours.First().StateTypes = NeighbourStateTypes.Responsive;

            stateHistory.ToList().ForEach(i => stateCareTaker.Add(i));

            var stateCandidate = DiscoveryHelper.MockOriginator(default,