Exemplo n.º 1
0
        public async Task ShouldReturnProperMode()
        {
            RepositoryDatabase service         = new RepositoryDatabase(Settings);
            string             organizationOne = MethodBase.GetCurrentMethod().Name;
            string             repoOne         = Guid.NewGuid().ToString();

            //first add a new repository to a new organization
            RepositoryInfo repo = await service.UpsertUpdate(
                new RepositoryInfo()
            {
                OrganizationName = organizationOne,
                RepositoryName   = repoOne
            }).ConfigureAwait(false);

            repo.RepositoryMode.Should().Be(RepositoryMode.Default);

            //then add it again
            RepositoryInfo repo2 = await service.UpsertUpdate(new RepositoryInfo()
            {
                OrganizationName = organizationOne,
                RepositoryName   = repoOne
            }).ConfigureAwait(false);

            repo2.RepositoryMode.Should().Be(RepositoryMode.Default);

            //then change the repo mode (ensure that change worked OK)
            repo.RepositoryMode = RepositoryMode.Snapshot;
            await service.UpsertReplace(repo).ConfigureAwait(false);

            repo = await service.GetRepository(organizationOne, repoOne);

            repo.RepositoryMode.Should().Be(RepositoryMode.Snapshot);

            //now perform upsert again and ensure that mode is not overwritten
            repo = await service.UpsertUpdate(new RepositoryInfo()
            {
                OrganizationName = organizationOne,
                RepositoryName   = repoOne
            }).ConfigureAwait(false);

            repo.RepositoryMode.Should().Be(RepositoryMode.Snapshot);

            //even if added multiple times
            repo = await service.UpsertUpdate(new RepositoryInfo()
            {
                OrganizationName = organizationOne,
                RepositoryName   = repoOne
            }).ConfigureAwait(false);

            repo.RepositoryMode.Should().Be(RepositoryMode.Snapshot);
        }