public void Save_WithPreexistingKey_ThrowsArgumentException()
        {
            var store = new InMemoryJobStore(loggerMock.Object);

            Func <Task> act = async() => await store.Save(1, null);

            Func <Task> act2 = async() => await store.Save(1, null);

            act.Should().Throw <ArgumentException>();
        }
        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 Save_NullJob_ThrowsNullException()
        {
            var         store = new InMemoryJobStore(loggerMock.Object);
            Func <Task> act   = async() => await store.Save(1, null);

            act.Should().Throw <ArgumentNullException>();
        }
        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 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);
        }