public void GenerateNewID_IncrementsId() { var first = IDGenerator.GenerateNewId(); var second = IDGenerator.GenerateNewId(); first.Should().BeGreaterThan(0); first.Should().BeLessThan(second); }
public async Task Retreive_WithExistingKey_RetrievesAtSavedKey() { var store = new InMemoryJobStore(loggerMock.Object); var id = IDGenerator.GenerateNewId(); await store.Save(id, sortingJob); var job = await store.GetById(id); job.Should().NotBeNull(); job.Should().BeOfType(typeof(SortingJob)); job.Should().BeSameAs(sortingJob); }
public async Task GetAll_ReturnsAllAdded() { var store = new InMemoryJobStore(loggerMock.Object); await store.Save(IDGenerator.GenerateNewId(), sortingJob); await store.Save(IDGenerator.GenerateNewId(), sortingJob); var jobs = await store.GetAll(); jobs.Should().HaveCount(2); jobs.Should().NotContainNulls(); }
public void GenerateNewId_RespectsThreads() { // Best effort thread test for id generation. var numbers = new ConcurrentBag <int>(); Parallel.For(0, 100, i => { numbers.Add(IDGenerator.GenerateNewId()); }); numbers.Should().NotContainNulls(); numbers.Should().NotContain(0); numbers.Should().OnlyHaveUniqueItems(); numbers.Should().HaveCount(100); }
public async Task Save_RespectsThreads() { // Best effort thread test var store = new InMemoryJobStore(loggerMock.Object); Parallel.For(0, 100, async(i) => { await store.Save(IDGenerator.GenerateNewId(), sortingJob); }); var allItems = await store.GetAll(); allItems.Should().NotContainNulls(); allItems.Should().HaveCount(100); }