Beispiel #1
0
        private async Task CreateOrderItem()
        {
            string resourceGroupName = Recording.GenerateAssetName("SdkRg");
            await EdgeOrderManagementTestUtilities.TryRegisterResourceGroupAsync(ResourceGroupsOperations,
                                                                                 EdgeOrderManagementTestUtilities.DefaultResourceLocation, resourceGroupName);

            _orderItemName = Recording.GenerateAssetName("Sdk-OrderItem");
            ContactDetails    contactDetails    = GetDefaultContactDetails();
            ShippingAddress   shippingAddress   = GetDefaultShippingAddress();
            AddressProperties addressProperties = new(contactDetails)
            {
                ShippingAddress = shippingAddress
            };
            AddressDetails addressDetails = new(addressProperties);
            string         orderId        = string.Format(EdgeOrderManagementTestUtilities.OrderArmIdFormat,
                                                          TestEnvironment.SubscriptionId, resourceGroupName, EdgeOrderManagementTestUtilities.DefaultResourceLocation, _orderItemName);

            _orderItemResourceCollection = await GetOrderItemResourceCollectionAsync(resourceGroupName);

            OrderItemResourceData orderItemResourceData = new(EdgeOrderManagementTestUtilities.DefaultResourceLocation,
                                                              GetDefaultOrderItemDetails(), addressDetails, orderId);

            // Create
            var createOrderItemOperation = await _orderItemResourceCollection.CreateOrUpdateAsync(WaitUntil.Completed, _orderItemName, orderItemResourceData);

            await createOrderItemOperation.WaitForCompletionAsync();
        }
Beispiel #2
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 #3
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();
        }
Beispiel #4
0
        public async Task TestOrderItemCRUDOperations()
        {
            var resourceGroupName = Recording.GenerateAssetName("SdkRg");
            await EdgeOrderManagementTestUtilities.TryRegisterResourceGroupAsync(ResourceGroupsOperations,
                                                                                 EdgeOrderManagementTestUtilities.DefaultResourceLocation, resourceGroupName);

            var               orderItemName     = Recording.GenerateAssetName("Sdk-OrderItem");
            ContactDetails    contactDetails    = GetDefaultContactDetails();
            ShippingAddress   shippingAddress   = GetDefaultShippingAddress();
            AddressProperties addressProperties = new(contactDetails)
            {
                ShippingAddress = shippingAddress
            };
            AddressDetails addressDetails = new(addressProperties);
            string         orderId        = string.Format(EdgeOrderManagementTestUtilities.OrderArmIdFormat,
                                                          TestEnvironment.SubscriptionId, resourceGroupName, EdgeOrderManagementTestUtilities.DefaultResourceLocation, orderItemName);

            OrderItemResourceCollection _orderItemResourceCollection = await GetOrderItemResourceCollectionAsync(resourceGroupName);

            OrderItemResourceData orderItemResourceData = new(EdgeOrderManagementTestUtilities.DefaultResourceLocation,
                                                              GetDefaultOrderItemDetails(), addressDetails, orderId);

            // Create
            var createOrderItemOperation = await _orderItemResourceCollection.CreateOrUpdateAsync(WaitUntil.Completed, orderItemName, orderItemResourceData);

            await createOrderItemOperation.WaitForCompletionAsync();

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

            // Get
            Response <OrderItemResource> getOrderItemResourceResponse = await _orderItemResourceCollection.GetAsync(orderItemName);

            OrderItemResource orderItemResource = getOrderItemResourceResponse.Value;

            Assert.IsNotNull(orderItemResource);

            // Update
            addressProperties.ContactDetails.ContactName = "Updated contact name";
            PatchableOrderItemResourceData orderItemUpdateParameter = new()
            {
                ForwardAddress = addressProperties
            };
            var updateOrderItemOperation = await orderItemResource.UpdateAsync(WaitUntil.Completed, orderItemUpdateParameter);

            await updateOrderItemOperation.WaitForCompletionAsync();

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

            // Get
            getOrderItemResourceResponse = await _orderItemResourceCollection.GetAsync(orderItemName);

            orderItemResource = getOrderItemResourceResponse.Value;
            Assert.IsNotNull(orderItemResource);

            //Cancel
            Response cancelOrderItemResponse = await orderItemResource.CancelOrderItemAsync(
                new CancellationReason("Order item cancelled"));

            Assert.AreEqual(cancelOrderItemResponse.Status, 204);

            // Get
            getOrderItemResourceResponse = await _orderItemResourceCollection.GetAsync(orderItemName);

            orderItemResource = getOrderItemResourceResponse.Value;
            Assert.IsNotNull(orderItemResource);

            // Delete
            var deleteOrderItemByNameOperation = await orderItemResource.DeleteAsync(WaitUntil.Completed);

            await deleteOrderItemByNameOperation.WaitForCompletionResponseAsync();

            Assert.IsTrue(deleteOrderItemByNameOperation.HasCompleted);
        }
    }
}