示例#1
0
        public void InternalValidation_PayloadConverter_SerializationListContainersResult_WithoutErrorWithExtendedError()
        {
            var storageAccount = new WabStorageAccountConfiguration(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
            var container1 = new ClusterDetails(GetRandomClusterName(), "ClusterStorageProvisioned")
            {
                CreatedDate = DateTime.Now,
                ConnectionUrl = @"https://some/long/uri/",
                HttpUserName = "******",
                Location = "West US",
                ClusterSizeInNodes = 10,
                Error = new ClusterErrorStatus(10, "error", "create"),
                Version = IntegrationTestBase.TestCredentials.WellKnownCluster.Version,
            };
            container1.DefaultStorageAccount = storageAccount;
            container1.AdditionalStorageAccounts = new List<WabStorageAccountConfiguration>() 
            { 
                new WabStorageAccountConfiguration(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString()),
                new WabStorageAccountConfiguration(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString()) 
            };

            var originalContainers = new Collection<ClusterDetails> { container1 };

            Guid subscriptionId = new Guid();
            var payload = ServerSerializer.SerializeListContainersResult(originalContainers, "namespace", false, true);
            var finalContainers = new PayloadConverter().DeserializeListContainersResult(payload, "namespace", subscriptionId);

            Assert.AreEqual(originalContainers.Count, finalContainers.Count);
            var deserializedCluster = finalContainers.FirstOrDefault(cluster => cluster.Name == container1.Name);
            Assert.IsNotNull(deserializedCluster);
            Assert.AreEqual(deserializedCluster.SubscriptionId, subscriptionId);
            Assert.AreEqual(deserializedCluster.Error.Message, "error");
            Assert.AreEqual(deserializedCluster.Error.HttpCode, 10);
            Assert.AreEqual(deserializedCluster.Error.OperationType, "create");
        }
示例#2
0
        public void InternalValidation_PayloadConverter_SerializationListContainersResult()
        {
            var storageAccount = new WabStorageAccountConfiguration(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
            // Creates two random containers
            var container1 = new ClusterDetails(GetRandomClusterName(), "Running")
            {
                CreatedDate = DateTime.Now,
                ConnectionUrl = @"https://some/long/uri/",
                HttpUserName = "******",
                Location = "East US",
                ClusterSizeInNodes = 20,
                Version = IntegrationTestBase.TestCredentials.WellKnownCluster.Version
            };
            container1.DefaultStorageAccount = storageAccount;
            container1.AdditionalStorageAccounts = new List<WabStorageAccountConfiguration>() 
            { 
                new WabStorageAccountConfiguration(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString()),
                new WabStorageAccountConfiguration(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString()) 
            };
            var container2 = new ClusterDetails(GetRandomClusterName(), "ClusterStorageProvisioned")
            {
                CreatedDate = DateTime.Now,
                ConnectionUrl = @"https://some/long/uri/",
                HttpUserName = "******",
                Location = "West US",
                ClusterSizeInNodes = 10,
                Error = new ClusterErrorStatus(10, "error", "create"),
                Version = IntegrationTestBase.TestCredentials.WellKnownCluster.Version
            };

            var originalContainers = new Collection<ClusterDetails> { container1, container2 };

            // Roundtrip serialize\deserialize
            Guid subscriptionId = new Guid();
            var payload = ServerSerializer.SerializeListContainersResult(originalContainers, "namespace", true, false);
            var finalContainers = new PayloadConverter().DeserializeListContainersResult(payload, "namespace", subscriptionId);

            // Compares the lists
            Assert.AreEqual(originalContainers.Count, finalContainers.Count);
            foreach (var expectedCluster in originalContainers)
            {
                var deserializedCluster = finalContainers.FirstOrDefault(cluster => cluster.Name == expectedCluster.Name);
                Assert.IsNotNull(deserializedCluster);
                Assert.AreEqual(deserializedCluster.SubscriptionId, subscriptionId);
                Assert.IsTrue(Equals(expectedCluster, deserializedCluster), "Failed to deserialize cluster pigJobCreateParameters {0}", expectedCluster.Name);
            }
        }