public void SetTrafficManagerEndpointMissingLocationSucceeds() { // Setup ProfileWithDefinition original = GetProfileWithDefinition(); cmdlet = new SetAzureTrafficManagerEndpoint { DomainName = DomainName, TrafficManagerProfile = original, Weight = Weight, Type = EndpointType.Any.ToString(), Status = EndpointStatus.Enabled.ToString(), CommandRuntime = mockCommandRuntime }; // Assert the endpoint doesn't exist Assert.IsFalse(original.Endpoints.Any(e => e.DomainName == DomainName)); // Action cmdlet.ExecuteCmdlet(); // Assert var actual = mockCommandRuntime.OutputPipeline[0] as ProfileWithDefinition; // There is a new endpoint with the domain name in "actual" Assert.IsNotNull(actual); Assert.IsTrue(actual.Endpoints.Any(e => e.DomainName == DomainName)); TrafficManagerEndpoint newEndpoint = actual.Endpoints.First(e => e.DomainName == DomainName); Assert.AreEqual(EndpointType.Any, newEndpoint.Type); Assert.AreEqual(EndpointStatus.Enabled, newEndpoint.Status); Assert.AreEqual(Weight, newEndpoint.Weight); Assert.AreEqual(null, newEndpoint.Location); }
public void SetTrafficManagerEndpointSucceeds() { // Setup ProfileWithDefinition original = GetProfileWithDefinition(); var existingEndpoint = new TrafficManagerEndpoint { DomainName = DomainName, Type = EndpointType.Any, Status = EndpointStatus.Enabled, Weight = 10, MinChildEndpoints = 2 }; original.Endpoints.Add(existingEndpoint); // Assert the endpoint exists Assert.IsTrue(original.Endpoints.Any(e => e.DomainName == DomainName)); cmdlet = new SetAzureTrafficManagerEndpoint { DomainName = DomainName, TrafficManagerProfile = original, Weight = Weight, MinChildEndpoints = MinChildEndpoints, Location = Location, CommandRuntime = mockCommandRuntime }; // Action cmdlet.ExecuteCmdlet(); // Assert var actual = mockCommandRuntime.OutputPipeline[0] as ProfileWithDefinition; // All the properties stay the same except the endpoints AssertAllProfilePropertiesDontChangeExceptEndpoints(original, actual); // There is an endpoint with the domain name in "actual" Assert.IsNotNull(actual); Assert.IsTrue(actual.Endpoints.Any(e => e.DomainName == DomainName)); TrafficManagerEndpoint updatedEndpoint = actual.Endpoints.First(e => e.DomainName == DomainName); // Unchanged properties Assert.AreEqual(EndpointType.Any, updatedEndpoint.Type); Assert.AreEqual(EndpointStatus.Enabled, updatedEndpoint.Status); // Updated properties Assert.AreEqual(Weight, updatedEndpoint.Weight); Assert.AreEqual(Location, updatedEndpoint.Location); Assert.AreEqual(MinChildEndpoints, updatedEndpoint.MinChildEndpoints); }
public void SetTrafficManagerEndpointMissingStatusFails() { // Setup ProfileWithDefinition original = GetProfileWithDefinition(); cmdlet = new SetAzureTrafficManagerEndpoint { DomainName = DomainName, TrafficManagerProfile = original, Weight = Weight, Location = Location, Type = EndpointType.Any.ToString(), CommandRuntime = mockCommandRuntime }; // Assert the endpoint doesn't exist Assert.IsFalse(original.Endpoints.Any(e => e.DomainName == DomainName)); // Action + Assert Testing.AssertThrows<Exception>( () => cmdlet.ExecuteCmdlet(), Microsoft.WindowsAzure.Commands.Common.Properties.Resources.SetTrafficManagerEndpointNeedsParameters); }
public void SetTrafficManagerEndpointNotExisting() { // Setup ProfileWithDefinition original = GetProfileWithDefinition(); TrafficManagerEndpoint expectedEndpoint = new TrafficManagerEndpoint() { DomainName = DomainName, Type = EndpointType.Any, Status = EndpointStatus.Enabled, Weight = Weight, MinChildEndpoints = MinChildEndpoints, Location = Location }; cmdlet = new SetAzureTrafficManagerEndpoint { DomainName = DomainName, TrafficManagerProfile = original, Type = EndpointType.Any.ToString(), Weight = Weight, MinChildEndpoints = MinChildEndpoints, Location = Location, Status = EndpointStatus.Enabled.ToString(), CommandRuntime = mockCommandRuntime }; // Assert the endpoint doesn't exist Assert.IsFalse(original.Endpoints.Any(e => e.DomainName == DomainName)); // Action cmdlet.ExecuteCmdlet(); var actual = mockCommandRuntime.OutputPipeline[0] as ProfileWithDefinition; // There is a new endpoint with the domain name in "actual" Assert.IsNotNull(actual); Assert.IsTrue(actual.Endpoints.Any(e => e.DomainName == DomainName)); TrafficManagerEndpoint newEndpoint = actual.Endpoints.First(e => e.DomainName == DomainName); Assert.AreEqual(expectedEndpoint, newEndpoint); }
public void SetTrafficManagerEndpointNotExistingMissingStatusFails() { // Setup ProfileWithDefinition original = GetProfileWithDefinition(); cmdlet = new SetAzureTrafficManagerEndpoint { Name = ProfileName, DomainName = DomainName, TrafficManagerProfile = original, //Weight = weight, //Location = location, Type = EndpointType.Any.ToString(), CommandRuntime = mockCommandRuntime }; // Assert the endpoint doesn't exist Assert.IsFalse(original.Endpoints.Any(e => e.DomainName == DomainName)); // Action + Assert Testing.AssertThrows<Exception>(() => cmdlet.ExecuteCmdlet()); }