示例#1
0
        public override void ExecuteCmdlet()
        {
            ProfileWithDefinition profile = TrafficManagerProfile.GetInstance();

            if (string.IsNullOrEmpty(Name))
            {
                this.Name = profile.Name;
            }

            if (!profile.Name.Equals(Name))
            {
                throw new Exception(Resources.SetTrafficManagerProfileAmbiguous);
            }

            DefinitionCreateParameters updatedDefinitionAsParam =
                TrafficManagerClient.InstantiateTrafficManagerDefinition(
                    LoadBalancingMethod ?? profile.LoadBalancingMethod.ToString(),
                    MonitorPort.HasValue ? MonitorPort.Value : profile.MonitorPort,
                    MonitorProtocol ?? profile.MonitorProtocol.ToString(),
                    MonitorRelativePath ?? profile.MonitorRelativePath,
                    Ttl.HasValue ? Ttl.Value : profile.TimeToLiveInSeconds,
                    profile.Endpoints);

            ProfileWithDefinition newDefinition =
                TrafficManagerClient.AssignDefinitionToProfile(Name, updatedDefinitionAsParam);

            WriteObject(newDefinition);
        }
示例#2
0
        public void ProcessGetSingleProfile()
        {
            // Setup
            ProfileWithDefinition expected = GetProfileWithDefinition();

            clientMock
            .Setup(c => c.GetTrafficManagerProfileWithDefinition(ProfileName))
            .Returns(expected);

            cmdlet = new GetAzureTrafficManagerProfile
            {
                Name = ProfileName,
                TrafficManagerClient = clientMock.Object,
                CommandRuntime       = mockCommandRuntime,
            };

            // Action
            cmdlet.ExecuteCmdlet();

            // Test
            Assert.AreEqual(1, mockCommandRuntime.OutputPipeline.Count);

            var actual = mockCommandRuntime.OutputPipeline[0] as ProfileWithDefinition;

            Assert.IsNotNull(actual);
            Assert.AreEqual(expected.Name, actual.Name);

            // TODO: Override .Equals in ProfileDefinition and uncomment this line
            // Assert.AreEquals(expected, actual);

            clientMock.Verify(c => c.GetTrafficManagerProfileWithDefinition(ProfileName), Times.Once());
        }
        public void AddTrafficManagerEndpointWebsite()
        {
            ProfileWithDefinition original = GetProfileWithDefinition();

            // Setup
            cmdlet = new AddAzureTrafficManagerEndpoint
            {
                DomainName            = DomainName,
                Type                  = AzureWebsiteType,
                Weight                = Weight,
                TrafficManagerProfile = original,
                CommandRuntime        = mockCommandRuntime,
                Status                = "Enabled"
            };

            // 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" but not in "original"
            Assert.IsTrue(actual.Endpoints.Any(e => e.DomainName == DomainName));
        }
        public void AddTrafficManagerEndpointNoWeightNoLocationNoMinChildEndpoints()
        {
            // Setup
            ProfileWithDefinition original = GetProfileWithDefinition();

            cmdlet = new AddAzureTrafficManagerEndpoint
            {
                DomainName            = DomainName,
                Type                  = AnyType,
                TrafficManagerProfile = original,
                CommandRuntime        = mockCommandRuntime,
                Status                = "Enabled"
            };

            // Action
            cmdlet.ExecuteCmdlet();

            var actual = mockCommandRuntime.OutputPipeline[0] as ProfileWithDefinition;

            // Assert
            // All the properties stay the same except the endpoints
            AssertAllProfilePropertiesDontChangeExceptEndpoints(original, actual);

            // There is a new endpoint with the new domain name in "actual" but not in "original"
            Assert.IsTrue(actual.Endpoints.Any(e => e.DomainName == DomainName));
            TrafficManagerEndpoint endpoint = actual.Endpoints.First(e => e.DomainName == DomainName);

            Assert.AreEqual(null, endpoint.Weight);
            Assert.IsNull(endpoint.Location);
            Assert.AreEqual(null, endpoint.MinChildEndpoints);
        }
        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());
        }
        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 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 AddTrafficManagerEndpointAlreadyExistsFails()
        {
            // Setup
            ProfileWithDefinition original = GetProfileWithDefinition();

            var existingEndpoint = new TrafficManagerEndpoint
            {
                DomainName = DomainName,
                Type       = EndpointType.Any,
                Status     = EndpointStatus.Enabled
            };

            original.Endpoints.Add(existingEndpoint);

            cmdlet = new AddAzureTrafficManagerEndpoint
            {
                DomainName            = DomainName,
                Type                  = AnyType,
                TrafficManagerProfile = original,
                CommandRuntime        = mockCommandRuntime
            };

            // Action + Assert
            Testing.AssertThrows <Exception>(() => cmdlet.ExecuteCmdlet());
        }
 private void AssertAllProfilePropertiesDontChangeExceptEndpoints(
     ProfileWithDefinition original,
     ProfileWithDefinition actual)
 {
     Assert.AreEqual(original.DomainName, actual.DomainName);
     Assert.AreEqual(original.Name, actual.Name);
     Assert.AreEqual(original.LoadBalancingMethod, actual.LoadBalancingMethod);
     Assert.AreEqual(original.MonitorPort, actual.MonitorPort);
     Assert.AreEqual(original.Status, actual.Status);
     Assert.AreEqual(original.MonitorRelativePath, actual.MonitorRelativePath);
     Assert.AreEqual(original.TimeToLiveInSeconds, actual.TimeToLiveInSeconds);
 }
        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 override void ExecuteCmdlet()
        {
            ProfileWithDefinition profile = TrafficManagerProfile.GetInstance();

            if (!profile.Endpoints.Any(e => e.DomainName.Equals(DomainName, StringComparison.InvariantCultureIgnoreCase)))
            {
                throw new Exception(Resources.RemoveTrafficManagerEndpointMissing);
            }

            TrafficManagerEndpoint endpoint = profile.Endpoints.First(e => e.DomainName.Equals(DomainName, StringComparison.InvariantCultureIgnoreCase));

            profile.Endpoints.Remove(endpoint);

            WriteObject(profile);
        }
        public override void ExecuteCmdlet()
        {
            ProfileWithDefinition profile = TrafficManagerProfile.GetInstance();

            if (!profile.Endpoints.Any(e => e.DomainName == DomainName))
            {
                throw new Exception(Resources.RemoveTrafficManagerEndpointMissing);
            }

            TrafficManagerEndpoint endpoint = profile.Endpoints.First(e => e.DomainName == DomainName);

            profile.Endpoints.Remove(endpoint);

            WriteObject(profile);
        }
示例#13
0
        public override void ExecuteCmdlet()
        {
            ProfileWithDefinition profile = TrafficManagerProfile.GetInstance();

            TrafficManagerEndpoint endpoint = profile.Endpoints.FirstOrDefault(e => e.DomainName.Equals(DomainName, StringComparison.InvariantCultureIgnoreCase));

            if (endpoint == null)
            {
                if (String.IsNullOrEmpty(Type) ||
                    String.IsNullOrEmpty(Status) ||
                    String.IsNullOrEmpty(DomainName))
                {
                    throw new Exception(Resources.SetTrafficManagerEndpointNeedsParameters);
                }

                WriteVerboseWithTimestamp(Resources.SetInexistentTrafficManagerEndpointMessage, profile.Name, DomainName);
                endpoint                   = new TrafficManagerEndpoint();
                endpoint.DomainName        = DomainName;
                endpoint.Location          = Location;
                endpoint.Type              = (EndpointType)Enum.Parse(typeof(EndpointType), Type);
                endpoint.Weight            = Weight;
                endpoint.MinChildEndpoints = MinChildEndpoints;
                endpoint.Status            = (EndpointStatus)Enum.Parse(typeof(EndpointStatus), Status);

                // Add it because the endpoint didn't exist
                profile.Endpoints.Add(endpoint);
            }

            endpoint.Location = Location ?? endpoint.Location;

            endpoint.Type = !String.IsNullOrEmpty(Type)
                ? (EndpointType)Enum.Parse(typeof(EndpointType), Type)
                : endpoint.Type;

            endpoint.Weight            = Weight.HasValue ? Weight.Value : endpoint.Weight;
            endpoint.MinChildEndpoints = MinChildEndpoints.HasValue ? MinChildEndpoints.Value : endpoint.MinChildEndpoints;

            endpoint.Status = !String.IsNullOrEmpty(Status)
                ? (EndpointStatus)Enum.Parse(typeof(EndpointStatus), Status)
                : endpoint.Status;

            WriteObject(profile);
        }
        public void AddTrafficManagerEndpointTrafficManager()
        {
            ProfileWithDefinition nestedProfile   = GetProfileWithDefinition();
            ProfileWithDefinition topLevelProfile = GetProfileWithDefinition(TopLevelProfileDomainName);

            cmdlet = new AddAzureTrafficManagerEndpoint
            {
                DomainName            = DomainName,
                Type                  = AnyType,
                Weight                = Weight,
                TrafficManagerProfile = nestedProfile,
                CommandRuntime        = mockCommandRuntime,
                Status                = "Enabled"
            };

            var cmdletTopLevelEndpoint = new AddAzureTrafficManagerEndpoint
            {
                DomainName            = ProfileDomainName,
                Type                  = TrafficManagerType,
                Weight                = Weight,
                MinChildEndpoints     = MinChildEndpoints,
                TrafficManagerProfile = topLevelProfile,
                CommandRuntime        = mockCommandRuntime,
                Status                = "Enabled"
            };

            // Action
            cmdlet.ExecuteCmdlet();
            cmdletTopLevelEndpoint.ExecuteCmdlet();

            var actualNestedProfile   = mockCommandRuntime.OutputPipeline[0] as ProfileWithDefinition;
            var actualTopLevelProfile = mockCommandRuntime.OutputPipeline[1] as ProfileWithDefinition;

            // Assert
            // All the properties stay the same except the endpoints
            AssertAllProfilePropertiesDontChangeExceptEndpoints(nestedProfile, actualNestedProfile);
            AssertAllProfilePropertiesDontChangeExceptEndpoints(topLevelProfile, actualTopLevelProfile);

            // There is a new endpoint with the new domain name in "actual" but not in "nestedProfile"
            Assert.IsTrue(actualNestedProfile.Endpoints.Any(e => e.DomainName == DomainName));
            Assert.IsTrue(actualTopLevelProfile.Endpoints.Any(e => e.DomainName == ProfileDomainName));
        }
        public override void ExecuteCmdlet()
        {
            TrafficManagerEndpoint endpoint = new TrafficManagerEndpoint();

            endpoint.DomainName = DomainName;
            endpoint.Location   = Location;
            endpoint.Status     = (EndpointStatus)Enum.Parse(typeof(EndpointStatus), Status);
            endpoint.Type       = (EndpointType)Enum.Parse(typeof(EndpointType), Type);
            endpoint.Weight     = Weight.HasValue ? Weight.Value : 1;
            ProfileWithDefinition profile = TrafficManagerProfile.GetInstance();

            if (profile.Endpoints.Any(e => e.DomainName == endpoint.DomainName))
            {
                throw new Exception(
                          string.Format(Resources.AddTrafficManagerEndpointFailed, profile.Name, endpoint.DomainName));
            }

            profile.Endpoints.Add(endpoint);
            WriteObject(TrafficManagerProfile);
        }
        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);
        }
示例#17
0
        public override void ExecuteCmdlet()
        {
            TrafficManagerEndpoint endpoint = new TrafficManagerEndpoint();

            endpoint.DomainName        = DomainName;
            endpoint.Location          = Location;
            endpoint.Status            = (EndpointStatus)Enum.Parse(typeof(EndpointStatus), Status);
            endpoint.Type              = (EndpointType)Enum.Parse(typeof(EndpointType), Type);
            endpoint.Weight            = Weight;
            endpoint.MinChildEndpoints = MinChildEndpoints;
            ProfileWithDefinition profile = TrafficManagerProfile.GetInstance();

            if (profile.Endpoints.Any(e => e.DomainName.Equals(endpoint.DomainName, StringComparison.InvariantCultureIgnoreCase)))
            {
                throw new Exception(
                          string.Format(Resources.AddTrafficManagerEndpointFailed, profile.Name, endpoint.DomainName));
            }

            profile.Endpoints.Add(endpoint);
            WriteObject(TrafficManagerProfile);
        }
        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 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,
                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));
        }
示例#20
0
        public void ProcessGetListProfiles()
        {
            // Setup
            ProfileWithDefinition expected1 = GetProfileWithDefinition();
            ProfileWithDefinition expected2 = GetProfileWithDefinition();

            expected2.Name       = "my-profile2";
            expected2.DomainName = "my-profile2.trafficmanager.net";

            IEnumerable <SimpleProfile> expected = new List <SimpleProfile> {
                expected1, expected2
            };

            clientMock.Setup(c => c.ListProfiles()).Returns(expected);

            cmdlet = new GetAzureTrafficManagerProfile
            {
                TrafficManagerClient = clientMock.Object,
                CommandRuntime       = mockCommandRuntime,
            };

            // Action
            cmdlet.ExecuteCmdlet();

            var actual = (IEnumerable <SimpleProfile>)mockCommandRuntime.OutputPipeline[0];

            // Assert
            Assert.IsNotNull(actual);
            Assert.AreEqual(expected.Count(), actual.Count());
            Assert.IsTrue(actual.Any(p => p.Name.Equals(expected1.Name)));
            Assert.IsTrue(actual.Any(p => p.Name.Equals(expected2.Name)));
            Assert.IsTrue(actual.Any(p => p.DomainName.Equals(expected1.DomainName)));
            Assert.IsTrue(actual.Any(p => p.DomainName.Equals(expected2.DomainName)));

            clientMock.Verify(c => c.ListProfiles(), Times.Once());
        }
        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());
        }
示例#22
0
        private void GetByName()
        {
            ProfileWithDefinition profile = TrafficManagerClient.GetTrafficManagerProfileWithDefinition(Name);

            WriteProfile(profile);
        }