Example #1
0
        public async Task RemoveAllBuildConfigs_WhenOtherConnectionIdsAreUsingIt_ShouldNotRemoveTheBuild()
        {
            var duplicateBuild = _fixture.Create<Models.BuildConfig>();
            var duplicateBuildId = duplicateBuild.CiExternalId;

            var connectionId = _fixture.Create<string>();
            var builds = _fixture
                .Build<Models.BuildConfig>()
                .CreateMany()
                .ToList();
            builds.Add(duplicateBuild);

            var otherConnectionId = _fixture.Create<string>();
            var otherBuilds = _fixture
                .Build<Models.BuildConfig>()
                .CreateMany()
                .ToList();
            otherBuilds.Add(duplicateBuild);
            var otherBuildsIds = otherBuilds
                .Select(b => b.CiExternalId)
                .ToList();

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

            await connManager.RemoveAllBuildConfigs(connectionId);

            connManager.BuildsPerConnId.Keys.Count.Should().Be(1);
            connManager.BuildsToBeRefreshed.Should().ContainKeys(otherBuildsIds.ToArray());
            connManager.BuildsToBeRefreshed.Should().ContainKey(duplicateBuildId);
        }
Example #2
0
        public void Setup()
        {
            Mapper.Configuration.AddProfile<ViewModelProfilers>();

            _fixture = new Fixture()
                .Customize(new AutoFakeItEasyCustomization());

            // clean any existing info in static dictionaties
            var connManager = new ConnectionsManager();
            var connIds = connManager.BuildsPerConnId.Keys;
            foreach(var connId in connIds)
            {
                connManager.RemoveAllBuildConfigs(connId).Wait(); 
            }
        }
Example #3
0
        public async Task RemoveAllBuildConfigs_ShouldRemoveAllBuildsForConnectionId()
        {
            var connectionId = _fixture.Create<string>();
            var builds = _fixture
                .Build<Models.BuildConfig>()
                .CreateMany();

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

            connManager.BuildsPerConnId.Keys.Should()
                .Contain(connectionId);

            await connManager.RemoveAllBuildConfigs(connectionId);

            connManager.BuildsPerConnId.Keys.Should().BeEmpty();
            connManager.BuildsToBeRefreshed.Keys.Should().BeEmpty();
        }