Пример #1
0
        public void ShouldReturnEventIdWithInitialId(int initialId, string eventName)
        {
            IEventIdCreationSource eventIdCreationSource = CreateInstance(initialId);
            EventId eventId = eventIdCreationSource.GetNextId(eventName);

            Assert.Equal(initialId, eventId.Id);
            Assert.Equal(eventName, eventId.Name);
        }
Пример #2
0
        public void ShouldReturnEventIdsWithIncrementalIdValues(int initialId, string eventName)
        {
            IEventIdCreationSource eventIdCreationSource = CreateInstance(initialId);

            foreach (int id in Enumerable.Range(initialId, 100))
            {
                EventId eventId = eventIdCreationSource.GetNextId(eventName);

                Assert.Equal(id, eventId.Id);
                Assert.Equal(eventName, eventId.Name);
            }
        }
        public void ShouldCreateUniqueIds_WithSameEventName(string eventName)
        {
            IEventIdCreationSource eventIdCreationSource = CreateInstance();

            HashSet <int> ids = new HashSet <int>();

            foreach (int i in Enumerable.Range(0, 100))
            {
                EventId eventId = eventIdCreationSource.GetNextId(eventName);

                Assert.True(ids.Add(eventId.Id));
                Assert.Equal(eventName, eventId.Name);
            }
        }
        public void ShouldCreateUniqueIds_WithDifferentEventName()
        {
            IEventIdCreationSource eventIdCreationSource = CreateInstance();

            HashSet <int> ids = new HashSet <int>();

            string eventNameTemplate = "EventName{0}";

            foreach (int i in Enumerable.Range(0, 100))
            {
                string  eventName = string.Format(eventNameTemplate, i);
                EventId eventId   = eventIdCreationSource.GetNextId(eventName);

                Assert.True(ids.Add(eventId.Id));
                Assert.Equal(eventName, eventId.Name);
            }
        }
Пример #5
0
 private EventId GetNextEventId(string?name = null) => _eventIdCreationSource.GetNextId(name);