示例#1
0
        public void ShouldThrowGetByIdNoResult()
        {
            var vmOperations = new VirtualMachineOperations(new WebClientFactory(
                                                                new Subscription(),
                                                                MockRequestChannel.Create()));

            Assert.Throws <WAPackOperationException>(() => vmOperations.Read(Guid.NewGuid()));
        }
示例#2
0
        public void ShouldReturnEmptyOnNoResult()
        {
            var vmOperations = new VirtualMachineOperations(new WebClientFactory(
                                                                new Subscription(),
                                                                MockRequestChannel.Create()));

            Assert.False(vmOperations.Read().Any());
        }
示例#3
0
        public void ShouldReturnOneVM()
        {
            var vmOperations = new VirtualMachineOperations(new WebClientFactory(
                                                                new Subscription(),
                                                                MockRequestChannel.Create()
                                                                .AddReturnObject(new VirtualMachine {
                Name = "vm1", ID = Guid.NewGuid()
            })));

            Assert.Equal(1, vmOperations.Read().Count);
        }
示例#4
0
        public void Initialize()
        {
            this.channel = MockRequestChannel.Create();

            var subscription = new Subscription
            {
                ServiceEndpoint = new Uri("http://localhost:8090/"),
                SubscriptionId  = Guid.NewGuid().ToString(),
            };

            this.client = new WAPackIaaSClient(subscription, channel);
        }
        public void ShouldReturnJobNotFoundOnNonexistantJob()
        {
            Guid jobId = Guid.NewGuid();

            MockRequestChannel mockChannel = MockRequestChannel.Create();

            var jobOperations = new JobOperations(new WebClientFactory(
                                                      new Subscription(),
                                                      mockChannel));

            var result = jobOperations.WaitOnJob(jobId);

            Assert.Equal(JobStatusEnum.JobNotFound, result.jobStatus);
        }
示例#6
0
        public void ShouldReturnOneVMGetById()
        {
            var expectedVmId = Guid.NewGuid();
            var vmOperations = new VirtualMachineOperations(new WebClientFactory(
                                                                new Subscription(),
                                                                MockRequestChannel.Create()
                                                                .AddReturnObject(new VirtualMachine {
                Name = "vm1", ID = expectedVmId
            })));

            var vm = vmOperations.Read(expectedVmId);

            Assert.Equal(expectedVmId, vm.ID);
        }
        public void WaitOnJobCompletesImmediately()
        {
            Guid jobId = Guid.NewGuid();

            MockRequestChannel mockChannel = MockRequestChannel.Create();

            mockChannel.AddReturnObject(new Job {
                Name = "TestJob", ID = jobId, IsCompleted = true
            });

            var jobOperations = new JobOperations(new WebClientFactory(
                                                      new Subscription(),
                                                      mockChannel));
            DateTime start = DateTime.Now;

            jobOperations.WaitOnJob(jobId);
            Assert.True((DateTime.Now - start).TotalMilliseconds < 500);
        }
        public void WaitOnJobTimeoutJobNotFinished()
        {
            Guid jobId = Guid.NewGuid();

            MockRequestChannel mockChannel = MockRequestChannel.Create();

            mockChannel.AddReturnObject(new Job {
                Name = "TestJob", ID = jobId, IsCompleted = false, Status = "Running"
            });
            mockChannel.AddReturnObject(new Job {
                Name = "TestJob", ID = jobId, IsCompleted = false, Status = "Running"
            });
            mockChannel.AddReturnObject(new Job {
                Name = "TestJob", ID = jobId, IsCompleted = false, Status = "Running"
            });
            mockChannel.AddReturnObject(new Job {
                Name = "TestJob", ID = jobId, IsCompleted = false, Status = "Running"
            });
            mockChannel.AddReturnObject(new Job {
                Name = "TestJob", ID = jobId, IsCompleted = false, Status = "Running"
            });
            mockChannel.AddReturnObject(new Job {
                Name = "TestJob", ID = jobId, IsCompleted = false, Status = "Running"
            });
            mockChannel.AddReturnObject(new Job {
                Name = "TestJob", ID = jobId, IsCompleted = false, Status = "Running"
            });

            var jobOperations = new JobOperations(new WebClientFactory(
                                                      new Subscription(),
                                                      mockChannel));
            DateTime start  = DateTime.Now;
            var      result = jobOperations.WaitOnJob(jobId, 6000);
            var      diff   = (DateTime.Now - start).TotalMilliseconds;

            Assert.True(diff > 6000);
            Assert.Equal(JobStatusEnum.OperationTimedOut, result.jobStatus);
        }
示例#9
0
        public void ShouldReturnEmptyOnNoResult()
        {
            var logicalNetworkOperations = new LogicalNetworkOperations(new WebClientFactory(new Subscription(), MockRequestChannel.Create()));

            Assert.False(logicalNetworkOperations.Read().Any());
        }
示例#10
0
        public void ShouldReturnEmptyOnNoResult()
        {
            var cloudServiceOperations = new CloudServiceOperations(new WebClientFactory(new Subscription(), MockRequestChannel.Create()));

            Assert.False(cloudServiceOperations.Read().Any());
        }