コード例 #1
0
        public async Task CreateUsesExplicitChangeToken()
        {
            DbContextDataProvider <DefaultDataProvider, TestContext> provider = CreateProvider();
            string changeToken = Guid.NewGuid().ToString("N");

            TestContextChangeTokenExRepository repository = CreateChangeTokenExRepository(provider, Substitute.For <ITokenGenerator>());

            EntityWithChangeTokenEx result = await repository.CreateAsync(
                new EntityWithChangeTokenEx { ChangeToken = changeToken },
                CancellationToken.None);

            result.ChangeToken.Should()
            .Be(changeToken);

            DbEntityWithChangeToken dbEntity =
                await provider.GetContext()
                .ChangeTokenEntities.FirstAsync(e => e.Id == result.Id);

            dbEntity.ChangeToken.Should()
            .Be(changeToken);
        }
コード例 #2
0
        public async Task CreateInitializesChangeTokenEx()
        {
            DbContextDataProvider <DefaultDataProvider, TestContext> provider = CreateProvider();
            string          changeToken = Guid.NewGuid().ToString("N");
            ITokenGenerator generator   = CreateTokenGenerator(changeToken);

            TestContextChangeTokenExRepository repository = CreateChangeTokenExRepository(provider, generator);

            EntityWithChangeTokenEx result = await repository.CreateAsync(
                new EntityWithChangeTokenEx(),
                CancellationToken.None);

            result.ChangeToken.Should()
            .Be(changeToken);

            DbEntityWithChangeToken dbEntity =
                await provider.GetContext()
                .ChangeTokenEntities.FirstAsync(e => e.Id == result.Id);

            dbEntity.ChangeToken.Should()
            .Be(changeToken);
        }