Ejemplo n.º 1
0
        internal void EventIDTests(
            DateTime timestamp,
            BatchID batchID,
            EventID id,
            EventID next
            )
        {
            GIVEN["a BatchID"]       = () => batchID = new BatchID(timestamp = DateTime.UtcNow);
            WHEN["calling GetFirst"] = () => id = EventID.GetFirst(batchID);
            THEN["a new value with given batch ID is returned"] = () => id.BatchID.Should().Be(batchID);
            AND["its Sequence is 1"] = () => id.Sequence.Should().Be(1);

            WHEN["calling GetNext"]                = () => next = id.GetNext();
            THEN["a new EventID is returned"]      = () => next.Should().NotBeSameAs(id);
            AND["its BatchID is the original one"] = () => next.BatchID.Should().Be(batchID);
            AND["its Sequence is 2"]               = () => next.Sequence.Should().Be(2);

            GIVEN["a EventID with max sequence"] = () => {
                id = EventID.GetFirst(batchID);

                for (int i = 2; i <= 65535; i++)
                {
                    id = id.GetNext();
                }

                id.Sequence.Should().Be(65535);
            };
            WHEN["calling GetNext", ThenIsThrown <InvalidOperationException>()] = () => id.GetNext();
        }