Example #1
0
        public async Task UpdateBuildConfigs_DontDuplicateBuildsToBeRefreshed()
        {
            var connectionId = _fixture.Create<string>();
            var builds = _fixture
                .Build<Models.BuildConfig>()
                .CreateMany()
                .ToList();

            var otherBuilds = _fixture
                .Build<Models.BuildConfig>()
                .CreateMany()
                .ToList();
            otherBuilds.Add(builds.First());

            var buildsIds = builds.Select(b => b.CiExternalId).ToList();
            buildsIds.AddRange(otherBuilds.Select(b => b.CiExternalId));
            buildsIds = buildsIds.Distinct().ToList();

            var connManager = new ConnectionsManager();
            await connManager.AddBuildConfigs(connectionId, builds);

            await connManager.UpdateBuildConfigs(connectionId, otherBuilds);

            connManager.BuildsPerConnId.ContainsKey(connectionId).Should().BeTrue();
            connManager.BuildsPerConnId[connectionId].ShouldAllBeEquivalentTo(buildsIds);
            connManager.BuildsToBeRefreshed.Should().ContainKeys(buildsIds.ToArray());
        }