示例#1
0
        public void NoNameSpecifiedAndRoleInstanceListWithMultipleRoleInstanceWithSingleWinRMInputEndpointInDeployment()
        {
            var deployment = new Deployment
            {
                Url = deploymentUrl,
                RoleInstanceList = new RoleInstanceList
                {
                    new RoleInstance
                    {
                        InstanceEndpoints = new InstanceEndpointList
                        {
                            new InstanceEndpoint
                            {
                                LocalPort  = WinRMConstants.HttpsListenerPort,
                                Name       = WinRMConstants.EndpointName,
                                PublicPort = publicPort
                            }
                        }
                    },
                    new RoleInstance
                    {
                        InstanceEndpoints = new InstanceEndpointList
                        {
                            new InstanceEndpoint
                            {
                                LocalPort  = WinRMConstants.HttpsListenerPort,
                                Name       = WinRMConstants.EndpointName,
                                PublicPort = secondRolesPublicPort
                            }
                        }
                    }
                }
            };
            var winRmUri = new GetAzureWinRMUriStub(deployment)
            {
                CommandRuntime = mockCommandRuntime
            };

            winRmUri.ExecuteCommandBody();

            Assert.AreEqual(1, mockCommandRuntime.OutputPipeline.Count, "One item should be in the output pipeline");

            var uris = mockCommandRuntime.OutputPipeline[0] as List <Uri>;

            Assert.IsNotNull(uris, "List<Uri> is expected");

            var expectedUris = new List <Uri>
            {
                new UriBuilder("https", deploymentUrl.Host, publicPort).Uri,
                new UriBuilder("https", deploymentUrl.Host, secondRolesPublicPort).Uri
            };

            var a = (from e in expectedUris
                     where !uris.Contains(e)
                     select e).Count();

            Assert.IsTrue(a == 0, "Expected count: {0}, Found count:{1}", expectedUris.Count(), uris.Count());
        }
示例#2
0
        public void NoCurrentDeployment()
        {
            var winRmUri = new GetAzureWinRMUriStub(null)
            {
                CommandRuntime = mockCommandRuntime
            };

            winRmUri.ExecuteCommandBody();
            Assert.AreEqual(0, mockCommandRuntime.OutputPipeline.Count, "Nothing should be written to output pipeline");
        }
        //[TestMethod]
        public void NoCurrentDeployment()
        {
            var winRmUri = new GetAzureWinRMUriStub(null)
            {
                CommandRuntime = mockCommandRuntime
            };

            winRmUri.ExecuteCommandBody();
            Assert.AreEqual(0, mockCommandRuntime.OutputPipeline.Count, "Nothing should be written to output pipeline");
        }
示例#4
0
        public void NoNameSpecifiedAndRoleInstanceListWithNullRoleInstanceInDeployment()
        {
            var deployment = new Deployment
            {
                Url = AnyUrl(),
                RoleInstanceList = new RoleInstanceList()
            };
            var winRmUri = new GetAzureWinRMUriStub(deployment)
            {
                CommandRuntime = mockCommandRuntime
            };

            winRmUri.ExecuteCommandBody();
            Assert.AreEqual(0, mockCommandRuntime.OutputPipeline.Count, "Nothing should be written to output pipeline");
        }
 //[TestMethod]
 public void NoUrlInDeployment()
 {
     var deployment = new Deployment();
     var winRmUri = new GetAzureWinRMUriStub(deployment)
     {
         CommandRuntime = mockCommandRuntime
     };
     try
     {
         winRmUri.ExecuteCommandBody();
         Assert.Fail("Should throw argument out of range exception");
     }
     catch (ArgumentOutOfRangeException)
     {
     }
 }
示例#6
0
        public void NoUrlInDeployment()
        {
            var deployment = new Deployment();
            var winRmUri   = new GetAzureWinRMUriStub(deployment)
            {
                CommandRuntime = mockCommandRuntime
            };

            try
            {
                winRmUri.ExecuteCommandBody();
                Assert.Fail("Should throw argument out of range exception");
            }
            catch (ArgumentOutOfRangeException)
            {
            }
        }
示例#7
0
        public void NoNameSpecifiedAndNoRoleInstanceListInDeployment()
        {
            var deployment = new Deployment
            {
                Url = AnyUrl()
            };
            var winRmUri = new GetAzureWinRMUriStub(deployment)
            {
                CommandRuntime = mockCommandRuntime
            };

            try
            {
                winRmUri.ExecuteCommandBody();
                Assert.Fail("Should throw argument out of range exception");
            }
            catch (ArgumentOutOfRangeException)
            {
            }
        }
 public void NameSpecifiedAndNoRoleInstanceListInDeployment()
 {
     var deployment = new Deployment
     {
         Url = AnyUrl()
     };
     var winRmUri = new GetAzureWinRMUriStub(deployment)
     {
         CommandRuntime = mockCommandRuntime,
         Name = AnyString()
     };
     try
     {
         winRmUri.ExecuteCommandBody();
         Assert.Fail("Should throw argument out of range exception");
     }
     catch (ArgumentOutOfRangeException)
     {
     }
 }
示例#9
0
        public void NameSpecifiedAndRoleInstanceListWithSingleRoleInstanceWithSingleWinRMInputEndpointInDeployment()
        {
            var deployment = new Deployment
            {
                Url = deploymentUrl,
                RoleInstanceList = new RoleInstanceList
                {
                    new RoleInstance
                    {
                        RoleName          = roleName,
                        InstanceEndpoints = new InstanceEndpointList
                        {
                            new InstanceEndpoint
                            {
                                LocalPort  = WinRMConstants.HttpsListenerPort,
                                Name       = WinRMConstants.EndpointName,
                                PublicPort = publicPort
                            }
                        }
                    }
                }
            };
            var winRmUri = new GetAzureWinRMUriStub(deployment)
            {
                Name           = roleName,
                CommandRuntime = mockCommandRuntime
            };

            winRmUri.ExecuteCommandBody();
            Assert.AreEqual(1, mockCommandRuntime.OutputPipeline.Count, "One item should be in the output pipeline");

            var uri = mockCommandRuntime.OutputPipeline[0] as Uri;

            Assert.IsNotNull(uri, "Uri is expected");

            var builder = new UriBuilder("https", deploymentUrl.Host, publicPort);

            Assert.AreEqual(builder.Uri, uri);
        }
 public void NameSpecifiedAndRoleInstanceListWithSingleRoleInstanceWithoutEndpointInDeployment()
 {
     var deployment = new Deployment
     {
         Url = deploymentUrl,
         RoleInstanceList = new RoleInstanceList
         {
             new RoleInstance
             {
                 RoleName = roleName,
             }
         }
     };
     var winRmUri = new GetAzureWinRMUriStub(deployment)
     {
         Name = roleName,
         CommandRuntime = mockCommandRuntime
     };
     try
     {
         winRmUri.ExecuteCommandBody();
     }
     catch (ArgumentOutOfRangeException)
     {
     }
     Assert.AreEqual(0, mockCommandRuntime.OutputPipeline.Count, "There should be no item in the output pipeline");
 }
 public void NameSpecifiedAndRoleInstanceListDoesNotHaveMatchingRoleInstanceInDeployment()
 {
     var deployment = new Deployment
     {
         Url = AnyUrl(),
         RoleInstanceList = new RoleInstanceList
         {
             new RoleInstance()
         }
     };
     var winRmUri = new GetAzureWinRMUriStub(deployment)
     {
         Name = AnyString(),
         CommandRuntime = mockCommandRuntime
     };
     try
     {
         winRmUri.ExecuteCommandBody();
         Assert.Fail("Should never reach here.");
     }
     catch (ArgumentOutOfRangeException)
     {
     }
     Assert.AreEqual(0, mockCommandRuntime.OutputPipeline.Count, "Nothing should be written to output pipeline");
 }
        public void NoNameSpecifiedAndRoleInstanceListWithSingleRoleInstanceWithSingleWinRMInputEndpointInDeployment()
        {
            var deployment = new Deployment
            {
                Url = deploymentUrl,
                RoleInstanceList = new RoleInstanceList
                {
                    new RoleInstance
                    {
                        InstanceEndpoints = new InstanceEndpointList
                        {
                            new InstanceEndpoint
                            {
                                LocalPort = WinRMConstants.HttpsListenerPort,
                                Name = WinRMConstants.EndpointName,
                                PublicPort = publicPort
                            }
                        }
                    }
                }
            };
            var winRmUri = new GetAzureWinRMUriStub(deployment)
            {
                CommandRuntime = mockCommandRuntime
            };
            winRmUri.ExecuteCommandBody();
            Assert.AreEqual(1, mockCommandRuntime.OutputPipeline.Count, "One item should be in the output pipeline");

            var uris = mockCommandRuntime.OutputPipeline[0] as List<Uri>;
            Assert.IsNotNull(uris, "List<Uri> is expected");

            Uri uri = uris[0];
            var builder = new UriBuilder("https", deploymentUrl.Host, publicPort);
            Assert.AreEqual(builder.Uri, uri);
        }
 public void NoNameSpecifiedAndRoleInstanceListWithSingleRoleInstanceWithSingleNonWinRMInputEndpointInDeployment()
 {
     var deployment = new Deployment
     {
         Url = AnyUrl(),
         RoleInstanceList = new RoleInstanceList
         {
             new RoleInstance
             {
                 InstanceEndpoints = new InstanceEndpointList
                 {
                     new InstanceEndpoint()
                 }
             }
         }
     };
     var winRmUri = new GetAzureWinRMUriStub(deployment)
     {
         CommandRuntime = mockCommandRuntime
     };
     winRmUri.ExecuteCommandBody();
     Assert.AreEqual(0, mockCommandRuntime.OutputPipeline.Count, "Nothing should be written to output pipeline");
 }
        public void NoNameSpecifiedAndRoleInstanceListWithMultipleRoleInstanceWithSingleWinRMInputEndpointInDeployment()
        {
            var deployment = new Deployment
            {
                Url = deploymentUrl,
                RoleInstanceList = new RoleInstanceList
                {
                    new RoleInstance
                    {
                        InstanceEndpoints = new InstanceEndpointList
                        {
                            new InstanceEndpoint
                            {
                                LocalPort = WinRMConstants.HttpsListenerPort,
                                Name = WinRMConstants.EndpointName,
                                PublicPort = publicPort
                            }
                        }
                    },
                    new RoleInstance
                    {
                        InstanceEndpoints = new InstanceEndpointList
                        {
                            new InstanceEndpoint
                            {
                                LocalPort = WinRMConstants.HttpsListenerPort,
                                Name = WinRMConstants.EndpointName,
                                PublicPort = secondRolesPublicPort
                            }
                        }
                    }
                }
            };
            var winRmUri = new GetAzureWinRMUriStub(deployment)
            {
                CommandRuntime = mockCommandRuntime
            };
            winRmUri.ExecuteCommandBody();

            Assert.AreEqual(1, mockCommandRuntime.OutputPipeline.Count, "One item should be in the output pipeline");

            var uris = mockCommandRuntime.OutputPipeline[0] as List<Uri>;
            Assert.IsNotNull(uris, "List<Uri> is expected");

            var expectedUris = new List<Uri>
            {
                new UriBuilder("https", deploymentUrl.Host, publicPort).Uri,
                new UriBuilder("https", deploymentUrl.Host, secondRolesPublicPort).Uri
            };

            var a = (from e in expectedUris
                    where !uris.Contains(e)
                    select e).Count();

            Assert.IsTrue(a == 0, "Expected count: {0}, Found count:{1}", expectedUris.Count(), uris.Count());
        }