public void RemoveTrafficManagerEndpointNonExistingFails() { // Setup ProfileWithDefinition original = GetProfileWithDefinition(); var existingEndpoint = new TrafficManagerEndpoint { DomainName = DomainName, Type = EndpointType.Any, Status = EndpointStatus.Enabled }; original.Endpoints.Add(existingEndpoint); // Assert the endpoint exists Assert.IsTrue(original.Endpoints.Any(e => e.DomainName == DomainName)); cmdlet = new RemoveAzureTrafficManagerEndpoint { DomainName = DomainName, TrafficManagerProfile = original, CommandRuntime = mockCommandRuntime }; // Action + Assert Testing.AssertThrows<Exception>(() => cmdlet.ExecuteCmdlet()); }
public void RemoveTrafficManagerEndpointSucceeds() { // Setup ProfileWithDefinition original = GetProfileWithDefinition(); var existingEndpoint = new TrafficManagerEndpoint { DomainName = DomainName, Type = EndpointType.Any, Status = EndpointStatus.Enabled }; original.Endpoints.Add(existingEndpoint); // Assert the endpoint exists Assert.IsTrue(original.Endpoints.Any(e => e.DomainName == DomainName)); cmdlet = new RemoveAzureTrafficManagerEndpoint { DomainName = DomainName.ToUpper(), TrafficManagerProfile = original, 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 a new endpoint with the new domain name in "actual" Assert.IsNotNull(actual); Assert.IsFalse(actual.Endpoints.Any(e => e.DomainName == DomainName)); }