Beispiel #1
0
        public async Task TestAddressCRUDOperations()
        {
            var resourceGroupName = Recording.GenerateAssetName("SdkRg");
            await EdgeOrderManagementTestUtilities.TryRegisterResourceGroupAsync(ResourceGroupsOperations,
                                                                                 EdgeOrderManagementTestUtilities.DefaultResourceLocation, resourceGroupName);

            var                       addressName               = Recording.GenerateAssetName("SdkAddress");
            ContactDetails            contactDetails            = GetDefaultContactDetails();
            ShippingAddress           shippingAddress           = GetDefaultShippingAddress();
            AddressResourceCollection addressResourceCollection = GetAddressResourceCollection(resourceGroupName);

            AddressResourceData addressResourceData = new(EdgeOrderManagementTestUtilities.DefaultResourceLocation, contactDetails)
            {
                ShippingAddress = shippingAddress
            };

            // Create
            var createAddressOperation = await addressResourceCollection.CreateOrUpdateAsync(true, addressName, addressResourceData);

            await createAddressOperation.WaitForCompletionAsync();

            Assert.IsTrue(createAddressOperation.HasCompleted);
            Assert.IsTrue(createAddressOperation.HasValue);

            // Get
            Response <AddressResource> getAddressResponse = await addressResourceCollection.GetAsync(addressName);

            AddressResource addressResource = getAddressResponse.Value;

            Assert.IsNotNull(addressResource);

            // Update
            contactDetails.ContactName = "Updated contact name";
            AddressUpdateParameter addressUpdateParameter = new()
            {
                ShippingAddress = shippingAddress,
                ContactDetails  = contactDetails
            };
            var updateAddressOperation = await addressResource.UpdateAsync(true, addressUpdateParameter);

            Assert.IsTrue(updateAddressOperation.HasCompleted);
            Assert.IsTrue(updateAddressOperation.HasValue);

            // Get
            getAddressResponse = await addressResourceCollection.GetAsync(addressName);

            addressResource = getAddressResponse.Value;
            Assert.IsNotNull(addressResource);
            Assert.IsTrue(string.Equals(addressResource.Data.ContactDetails.ContactName, "Updated contact name"));

            // Delete
            var deleteAddressOperation = await addressResource.DeleteAsync(true);

            await deleteAddressOperation.WaitForCompletionResponseAsync();

            Assert.IsTrue(deleteAddressOperation.HasCompleted);
        }
    }
}
Beispiel #2
0
        private async Task CreateAddress()
        {
            string resourceGroupName = Recording.GenerateAssetName("SdkRg");
            await EdgeOrderManagementTestUtilities.TryRegisterResourceGroupAsync(ResourceGroupsOperations,
                                                                                 EdgeOrderManagementTestUtilities.DefaultResourceLocation, resourceGroupName);

            var             addressName     = Recording.GenerateAssetName("SdkAddress");
            ContactDetails  contactDetails  = GetDefaultContactDetails();
            ShippingAddress shippingAddress = GetDefaultShippingAddress();

            _addressResourceCollection = await GetAddressResourceCollectionAsync(resourceGroupName);

            AddressResourceData addressResourceData = new(EdgeOrderManagementTestUtilities.DefaultResourceLocation,
                                                          contactDetails)
            {
                ShippingAddress = shippingAddress
            };

            // Create
            var createAddressOperation = await _addressResourceCollection.CreateOrUpdateAsync(WaitUntil.Completed, addressName, addressResourceData);

            await createAddressOperation.WaitForCompletionAsync();
        }