コード例 #1
0
        public async Task When_DeleteByIdAsync()
        {
            // Arrange

            var cosmosDatabase =
                _cosmosClient.GetDatabase(
                    _configuration["AzureCosmosDocumentStoreOptions:DatabaseId"]);

            var cosmosContainer =
                cosmosDatabase.GetContainer("accounts");

            var accountData =
                new AccountData(
                    _faker.Random.Number(10000, 99999).ToString());

            accountData.SystemOfRecord =
                _faker.PickRandom(
                    AccountData.SYSTEMOFRECORD_AUTOSUITE,
                    AccountData.SYSTEMOFRECORD_FISERVE,
                    AccountData.SYSTEMOFRECORD_ISERIES,
                    AccountData.SYSTEMOFRECORD_LEASEMASTER);
            accountData.PhoneNumber =
                _faker.Person.Phone;

            await cosmosContainer.CreateItemAsync(
                accountData,
                new PartitionKey(accountData.AccountNumber));

            var accountDataStoreOptions =
                new AccountDataStoreOptions(
                    _configuration["AzureCosmosDocumentStoreOptions:DatabaseId"],
                    _cosmosClient);

            var accountDataStore =
                new AccountDataStore(
                    accountDataStoreOptions);

            // Act

            await accountDataStore.DeleteByIdAsync(
                accountData.Id,
                accountData.AccountNumber);

            // Assert

            Func <Task> action = async() =>
                                 await cosmosContainer.ReadItemAsync <AccountData>(
                accountData.Id.ToString(),
                new PartitionKey(accountData.AccountNumber));

            action.Should().Throw <CosmosException>()
            .WithMessage("*Resource Not Found*");;
        }