public void ShouldThrowGetByIdNoResult() { var vmOperations = new VirtualMachineOperations(new WebClientFactory( new Subscription(), MockRequestChannel.Create())); Assert.Throws <WAPackOperationException>(() => vmOperations.Read(Guid.NewGuid())); }
public void ShouldReturnEmptyOnNoResult() { var vmOperations = new VirtualMachineOperations(new WebClientFactory( new Subscription(), MockRequestChannel.Create())); Assert.False(vmOperations.Read().Any()); }
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); }
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); }
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); }
public void ShouldReturnEmptyOnNoResult() { var logicalNetworkOperations = new LogicalNetworkOperations(new WebClientFactory(new Subscription(), MockRequestChannel.Create())); Assert.False(logicalNetworkOperations.Read().Any()); }
public void ShouldReturnEmptyOnNoResult() { var cloudServiceOperations = new CloudServiceOperations(new WebClientFactory(new Subscription(), MockRequestChannel.Create())); Assert.False(cloudServiceOperations.Read().Any()); }