Beispiel #1
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());
        }
Beispiel #2
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());
        }