public void TestGetTransportObjectDoesntMissProperties()
        {
            const int objectsToValidate = 100;
            //Use reflection to traverse the set of objects in the DLL, find those that implement ITransportObjectProvider, ensure that GetTransportObject works for all
            //properties of those objects.
            Type iTransportObjectProviderType = typeof(ITransportObjectProvider <>);

            IEnumerable <Type> types = GetTypesWhichImplementInterface(iTransportObjectProviderType.GetTypeInfo().Assembly, iTransportObjectProviderType, requirePublicConstructor: false);

            foreach (Type type in types)
            {
                this.testOutputHelper.WriteLine("Generating {0} objects of type {1}", objectsToValidate, type);
                for (int i = 0; i < objectsToValidate; i++)
                {
                    object o = this.customizedObjectFactory.GenerateNew(type);
                    Type   concreteInterfaceType = o.GetType().GetInterfaces().First(iFace =>
                                                                                     iFace.GetTypeInfo().IsGenericType&&
                                                                                     iFace.GetGenericTypeDefinition() == iTransportObjectProviderType);
                    //object protocolObject = concreteInterfaceType.GetMethod("GetTransportObject").Invoke(o, BindingFlags.Instance | BindingFlags.NonPublic, null, null, null);
                    object protocolObject = concreteInterfaceType.GetMethod("GetTransportObject").Invoke(o, null);

                    ObjectComparer.CheckEqualityResult result = this.objectComparer.CheckEquality(o, protocolObject);
                    Assert.True(result.Equal, result.Message);
                }
            }
        }
        public void TestRandomBoundImageInformationProperties()
        {
            using BatchClient client = ClientUnitTestCommon.CreateDummyClient();
            for (int i = 0; i < TestRunCount; i++)
            {
                Protocol.Models.ImageInformation imageModel =
                    this.customizedObjectFactory.GenerateNew <Protocol.Models.ImageInformation>();

                ImageInformation boundImageInfo           = new ImageInformation(imageModel);
                ObjectComparer.CheckEqualityResult result = this.objectComparer.CheckEquality(boundImageInfo, imageModel);
                Assert.True(result.Equal, result.Message);
            }
        }
        public void TestRandomBoundCloudTaskProperties()
        {
            using BatchClient client = ClientUnitTestCommon.CreateDummyClient();
            for (int i = 0; i < TestRunCount; i++)
            {
                Protocol.Models.CloudTask taskModel = this.customizedObjectFactory.GenerateNew <Protocol.Models.CloudTask>();

                CloudTask boundTask = new CloudTask(client, "Foo", taskModel, client.CustomBehaviors);

                ObjectComparer.CheckEqualityResult result = this.objectComparer.CheckEquality(boundTask, taskModel);
                Assert.True(result.Equal, result.Message);
            }
        }
        public void TestRandomBoundPrepReleaseTaskExecutionInformationProperties()
        {
            using BatchClient client = ClientUnitTestCommon.CreateDummyClient();
            for (int i = 0; i < TestRunCount; i++)
            {
                Protocol.Models.JobPreparationAndReleaseTaskExecutionInformation jobPrepReleaseExecutionInfo =
                    this.customizedObjectFactory.GenerateNew <Protocol.Models.JobPreparationAndReleaseTaskExecutionInformation>();

                JobPreparationAndReleaseTaskExecutionInformation boundJobPrepReleaseExecutionInfo =
                    new JobPreparationAndReleaseTaskExecutionInformation(jobPrepReleaseExecutionInfo);

                ObjectComparer.CheckEqualityResult result = this.objectComparer.CheckEquality(boundJobPrepReleaseExecutionInfo, jobPrepReleaseExecutionInfo);
                Assert.True(result.Equal, result.Message);
            }
        }
Exemplo n.º 5
0
        public void TestRandomBoundCloudPoolProperties()
        {
            using (BatchClient client = BatchClient.Open(ClientUnitTestCommon.CreateDummySharedKeyCredential()))
            {
                for (int i = 0; i < TestRunCount; i++)
                {
                    Protocol.Models.CloudPool poolModel =
                        this.customizedObjectFactory.GenerateNew <Protocol.Models.CloudPool>();

                    CloudPool boundPool = new CloudPool(client, poolModel, client.CustomBehaviors);
                    ObjectComparer.CheckEqualityResult result = this.objectComparer.CheckEquality(boundPool, poolModel);
                    Assert.True(result.Equal, result.Message);
                }
            }
        }
        public void TestRandomBoundCertificateProperties()
        {
            using (BatchClient client = ClientUnitTestCommon.CreateDummyClient())
            {
                for (int i = 0; i < TestRunCount; i++)
                {
                    Protocol.Models.Certificate certificateModel =
                        this.customizedObjectFactory.GenerateNew <Protocol.Models.Certificate>();

                    Certificate boundCertificate = new Certificate(client, certificateModel, client.CustomBehaviors);

                    ObjectComparer.CheckEqualityResult result = this.objectComparer.CheckEquality(boundCertificate, certificateModel);
                    Assert.True(result.Equal, result.Message);
                }
            }
        }
        public void TestRandomBoundCloudJobProperties()
        {
            using (BatchClient client = ClientUnitTestCommon.CreateDummyClient())
            {
                for (int i = 0; i < TestRunCount; i++)
                {
                    Protocol.Models.CloudJob jobModel =
                        this.customizedObjectFactory.GenerateNew <Protocol.Models.CloudJob>();

                    CloudJob boundJob = new CloudJob(client.JobOperations.ParentBatchClient, jobModel, client.CustomBehaviors);

                    ObjectComparer.CheckEqualityResult result = this.objectComparer.CheckEquality(boundJob, jobModel);
                    Assert.True(result.Equal, result.Message);
                }
            }
        }