public void ProcessSetProfileTestAllArgs() { // Setup ProfileWithDefinition oldProfileWithDefinition = defaultProfileWithDefinition; var newProfileWithDefinition = new ProfileWithDefinition { DomainName = ProfileDomainName, Name = ProfileName, Endpoints = new List<TrafficManagerEndpoint>(), LoadBalancingMethod = NewLoadBalancingMethod, MonitorPort = NewMonitorPort, Status = ProfileDefinitionStatus.Enabled, MonitorRelativePath = NewMonitorRelativePath, MonitorProtocol = NewMonitorProtocol, TimeToLiveInSeconds = NewTtl }; var newMonitor = new DefinitionMonitor { HttpOptions = new DefinitionMonitorHTTPOptions { ExpectedStatusCode = MonitorExpectedStatusCode, RelativePath = NewMonitorRelativePath, Verb = Verb } }; var updateDefinitionCreateParameters = new DefinitionCreateParameters { DnsOptions = new DefinitionDnsOptions { TimeToLiveInSeconds = NewTtl }, Policy = new DefinitionPolicyCreateParameters { LoadBalancingMethod = NewLoadBalancingMethod, Endpoints = new DefinitionEndpointCreateParameters[0] }, Monitors = new[] { newMonitor } }; clientMock .Setup(c => c.AssignDefinitionToProfile(ProfileName, It.IsAny<DefinitionCreateParameters>())) .Returns(newProfileWithDefinition); clientMock .Setup(c => c.InstantiateTrafficManagerDefinition( NewLoadBalancingMethod.ToString(), NewMonitorPort, NewMonitorProtocol.ToString(), NewMonitorRelativePath, NewTtl, oldProfileWithDefinition.Endpoints)) .Returns(updateDefinitionCreateParameters); cmdlet = new SetAzureTrafficManagerProfile { Name = ProfileName, LoadBalancingMethod = NewLoadBalancingMethod.ToString(), MonitorPort = NewMonitorPort, MonitorProtocol = NewMonitorProtocol.ToString(), MonitorRelativePath = NewMonitorRelativePath, Ttl = NewTtl, TrafficManagerClient = clientMock.Object, CommandRuntime = mockCommandRuntime, TrafficManagerProfile = oldProfileWithDefinition }; // Action cmdlet.ExecuteCmdlet(); var actual = mockCommandRuntime.OutputPipeline[0] as ProfileWithDefinition; // Assert Assert.IsNotNull(actual); Assert.AreEqual(newProfileWithDefinition.Name, actual.Name); Assert.AreEqual(newProfileWithDefinition.DomainName, actual.DomainName); Assert.AreEqual(newProfileWithDefinition.LoadBalancingMethod, actual.LoadBalancingMethod); Assert.AreEqual(newProfileWithDefinition.MonitorPort, actual.MonitorPort); Assert.AreEqual(newProfileWithDefinition.MonitorProtocol, actual.MonitorProtocol); Assert.AreEqual(newProfileWithDefinition.MonitorRelativePath, actual.MonitorRelativePath); Assert.AreEqual(newProfileWithDefinition.TimeToLiveInSeconds, actual.TimeToLiveInSeconds); // Most important assert; the cmdlet is passing the right parameters clientMock.Verify(c => c.InstantiateTrafficManagerDefinition( NewLoadBalancingMethod.ToString(), NewMonitorPort, NewMonitorProtocol.ToString(), NewMonitorRelativePath, NewTtl, oldProfileWithDefinition.Endpoints), Times.Once()); }
public void ProcessSetProfileTestTtl() { ProfileWithDefinition oldProfileWithDefinition = defaultProfileWithDefinition; cmdlet = new SetAzureTrafficManagerProfile { Name = ProfileName, // We only change the ttl Ttl = NewTtl, TrafficManagerClient = clientMock.Object, CommandRuntime = mockCommandRuntime, TrafficManagerProfile = oldProfileWithDefinition }; // Action cmdlet.ExecuteCmdlet(); // Assert clientMock.Verify( c => c.InstantiateTrafficManagerDefinition( DefaultLoadBalancingMethod.ToString(), MonitorPort, MonitorProtocol.ToString(), MonitorRelativePath, // ttl is the new one NewTtl, oldProfileWithDefinition.Endpoints), Times.Once()); }