public void GetAzureSBLocationSuccessfull() { // Setup Mock<ServiceBusClientExtensions> client = new Mock<ServiceBusClientExtensions>(); MockCommandRuntime mockCommandRuntime = new MockCommandRuntime(); string name = "test"; GetAzureSBLocationCommand cmdlet = new GetAzureSBLocationCommand() { CommandRuntime = mockCommandRuntime, Client = client.Object }; List<ServiceBusLocation> expected = new List<ServiceBusLocation>(); expected.Add(new ServiceBusLocation { Code = name, FullName = name }); client.Setup(f => f.GetServiceBusRegions()).Returns(expected); // Test cmdlet.ExecuteCmdlet(); // Assert IEnumerable<ServiceBusLocation> actual = System.Management.Automation.LanguagePrimitives.GetEnumerable(mockCommandRuntime.OutputPipeline).Cast<ServiceBusLocation>(); Assert.Equal<int>(expected.Count, actual.Count()); for (int i = 0; i < expected.Count; i++) { Assert.True(actual.Any((account) => account.Code == expected[i].Code)); Assert.True(actual.Any((account) => account.FullName == expected[i].FullName)); } }
public void GetAzureSBLocationSuccessfull() { // Setup Mock<ServiceBusClientExtensions> client = new Mock<ServiceBusClientExtensions>(); MockCommandRuntime mockCommandRuntime = new MockCommandRuntime(); string name = "test"; GetAzureSBLocationCommand cmdlet = new GetAzureSBLocationCommand() { CommandRuntime = mockCommandRuntime, Client = client.Object }; List<ServiceBusLocation> expected = new List<ServiceBusLocation>(); expected.Add(new ServiceBusLocation { Code = name, FullName = name }); client.Setup(f => f.GetServiceBusRegions()).Returns(expected); // Test cmdlet.ExecuteCmdlet(); // Assert List<ServiceBusLocation> actual = mockCommandRuntime.OutputPipeline[0] as List<ServiceBusLocation>; Assert.Equal<int>(expected.Count, actual.Count); for (int i = 0; i < expected.Count; i++) { Assert.Equal<string>(expected[i].Code, actual[i].Code); Assert.Equal<string>(expected[i].FullName, actual[i].FullName); } }