public void SRMModifyExistingServiceModelDiagnosticsSection()
        {
            string initialConfig  = @"<?xml version=""1.0"" encoding=""utf-8""?><configuration><system.serviceModel><diagnostics><messageLogging logEntireMessage=""false"" logMalformedMessages=""true"" logMessagesAtServiceLevel=""false"" logMessagesAtTransportLevel=""true"" /></diagnostics></system.serviceModel></configuration>";
            string expectedConfig = @"<?xml version=""1.0"" encoding=""utf-8""?><configuration>"
                                    +
                                    ExpectedDiagnosticsSectionTemplate
                                    +
                                    @"<system.serviceModel>"
                                    +
                                    this.expectedServiceModelSection
                                    +
                                    @"</system.serviceModel>"
                                    +
                                    @"</configuration>";

            this.CreateConfigFile(initialConfig);
            using (ScenarioRunManager mgr = new ScenarioRunManager())
            {
                mgr.Initialize(this.exeFileName);
                string logFileName = mgr.SetupForTrace();
                this.CompareConfig(expectedConfig, logFileName);
                mgr.RestoreOriginalConfiguration();
                this.CompareConfig(initialConfig, string.Empty);
            }
        }
        public void SRMModifyExistingSystemDiagnosticsSection()
        {
            string initialConfig  = @"<?xml version=""1.0"" encoding=""utf-8""?><configuration><system.diagnostics>stuff</system.diagnostics></configuration>";
            string expectedConfig = @"<?xml version=""1.0"" encoding=""utf-8""?><configuration>"
                                    +
                                    ExpectedDiagnosticsSectionTemplate
                                    +
                                    @"<system.serviceModel>"
                                    +
                                    this.expectedServiceModelSection
                                    +
                                    @"</system.serviceModel>"
                                    +
                                    @"</configuration>";

            this.CreateConfigFile(initialConfig);
            using (ScenarioRunManager mgr = new ScenarioRunManager())
            {
                mgr.Initialize(this.exeFileName);
                string logFileName = mgr.SetupForTrace();
                this.CompareConfig(expectedConfig, logFileName);
                mgr.RestoreOriginalConfiguration();
                this.CompareConfig(initialConfig, string.Empty);
            }
        }
 public void SRMNoSuchExecutable()
 {
     using (ScenarioRunManager mgr = new ScenarioRunManager())
     {
         TestHelper.TestForUserException(() => mgr.Initialize("NoSuch.exe"));
     }
 }
        public void SRMNoPermission()
        {
            // Don't use global variables for exe and config file as those files will get deleted at the end of the test
            string               exePath    = Path.GetFullPath(@"..\..\..\SampleClientAndService\Client\bin\debug\client.exe");
            string               configPath = exePath + ".config";
            string               dirName    = Path.GetDirectoryName(exePath);
            DirectorySecurity    acl        = Directory.GetAccessControl(dirName);
            FileSystemAccessRule rule       = new FileSystemAccessRule("Everyone", FileSystemRights.Modify, AccessControlType.Deny);

            try
            {
                acl.AddAccessRule(rule);
                Directory.SetAccessControl(dirName, acl);
                using (ScenarioRunManager mgr = new ScenarioRunManager())
                {
                    mgr.Initialize(exePath);
                    mgr.SetupForTrace();
                    Assert.Fail("Should have thrown a user exception here");
                }
            }
            catch (UserException)
            {
            }
            finally
            {
                acl.RemoveAccessRule(rule);
                Directory.SetAccessControl(dirName, acl);
            }

            Assert.IsTrue(File.Exists(configPath));
        }
        public bool RunWizard()
        {
            this.runCallCount++;
            Assert.AreEqual <int>(1, this.runCallCount, "Run form must only ever be called once");
            Assert.IsNotNull(this.WizardCompleting);
            if (this.runWizardThrowsException)
            {
                throw new UserException("RunWizard exception");
            }

            if (Executable != null)
            {
                dataToReturn = new WizardData();
                dataToReturn.Configuration = new WcfUnitConfiguration();
                UILogic uiLogic = new UILogic();
                using (ScenarioRunManager srm = new ScenarioRunManager())
                {
                    uiLogic.RunProgramAndGetWizardData(Executable, srm, dataToReturn);
                }
            }

            if (resultToReturn)
            {
                CancellableWizardEventArgs cancel = new CancellableWizardEventArgs(dataToReturn, false);
                this.WizardCompleting(this, cancel);
                if (cancel.Cancel)
                {
                    resultToReturn = false;
                }
            }

            return(resultToReturn);
        }
        public void SRMReferencedAssemblies()
        {
            string        tempDir        = TestHelper.CopyComplexSampleToTempFolder();
            string        path           = tempDir + @"\Microsoft.Sample.WCF.Client.exe";
            List <string> assembliesColl = new List <string>();

            ScenarioRunManager.GetReferencedAssemblies(path, assembliesColl);
            Assert.AreEqual <int>(11, assembliesColl.Count);
        }
        public void PMFindProxyMethodRequiringDynamicAssemblyResolution()
        {
            // Exercise the need of the proxy manager to
            // resolve assembly loads, by using assemblies that are not in the normal search path
            // as they are in a completely different folder.
            string tempDir = TestHelper.CopyComplexSampleToTempFolder();

            string        path           = tempDir + @"\Microsoft.Sample.WCF.Client.exe";
            List <string> assembliesColl = new List <string>();

            ScenarioRunManager.GetReferencedAssemblies(path, assembliesColl);
            this.assemblies = new string[assembliesColl.Count];
            assembliesColl.CopyTo(this.assemblies, 0);
            ProxyManager pm             = new ProxyManager(this.assemblies);
            MethodInfo   contractMethod = pm.GetContractMethod("http://microsoft.com/sample/wcf/ISampleService/Logon");

            pm.GetProxyMethod(contractMethod);
        }
        public void SRMNoConfigFileWithRestore()
        {
            string expectedConfig = @"<?xml version=""1.0"" encoding=""utf-8""?><configuration>"
                                    +
                                    ExpectedDiagnosticsSectionTemplate
                                    +
                                    @"<system.serviceModel>"
                                    +
                                    this.expectedServiceModelSection
                                    +
                                    @"</system.serviceModel>"
                                    +
                                    @"</configuration>";

            using (ScenarioRunManager mgr = new ScenarioRunManager())
            {
                mgr.Initialize(this.exeFileName);
                string logFileName = mgr.SetupForTrace();
                this.CompareConfig(expectedConfig, logFileName);
                mgr.RestoreOriginalConfiguration();
                Assert.IsFalse(File.Exists(this.configFileName));
            }
        }
Example #9
0
        public void SRMRunClient()
        {
            Assert.Inconclusive("Disabled because this test requires web service to be running and will otherwise fail");

            // Don't use global variables for exe and config file as those files will get deleted at the end of the test
            string exePath = Path.GetFullPath(@"..\..\..\SampleClientAndService\Client\bin\debug\client.exe");
            string libPath = Path.GetFullPath(@"..\..\..\SampleClientAndService\Client\bin\debug\ClientProxies.dll");

            using (ScenarioRunManager mgr = new ScenarioRunManager())
            {
                mgr.Initialize(exePath);
                string logFileName = null;
                try
                {
                    logFileName = mgr.SetupForTrace();
                    WcfUnitConfiguration config = new WcfUnitConfiguration();
                    mgr.Run(config);
                    Assert.IsTrue(File.Exists(logFileName));
                    Assert.AreEqual <int>(39, config.soapActions.soapAction.Length);
                    Assert.AreEqual <string>("http://contoso.com/service/test/IArithmetic/Add", config.soapActions.soapAction[0].action);
                    Assert.AreEqual <string>("http://contoso.com/service/test/IArithmetic/Add2", config.soapActions.soapAction[1].action);
                    Assert.AreEqual <string>("http://contoso.com/service/test/IArithmetic/Add3", config.soapActions.soapAction[2].action);
                    Assert.AreEqual <string>("http://contoso.com/service/test/IArithmetic/WrappedAdd", config.soapActions.soapAction[3].action);
                    Assert.AreEqual <string>("http://contoso.com/service/test/IArithmetic/WrappednoCustomNamesAdd", config.soapActions.soapAction[4].action);
                    Assert.AreEqual <string>("http://contoso.com/service/test/IArithmetic/WrappedMessageWithHeaderAndBodyNamespaceOverrides", config.soapActions.soapAction[5].action);
                    Assert.AreEqual <string>("http://contoso.com/service/test/IArithmetic/UnwrappedAdd", config.soapActions.soapAction[6].action);
                    Assert.AreEqual <string>("http://contoso.com/service/test/IArithmetic/NoParameters", config.soapActions.soapAction[7].action);
                    Assert.AreEqual <string>("http://contoso.com/service/test/IArithmetic/RefParameter", config.soapActions.soapAction[8].action);
                    Assert.AreEqual <string>("http://contoso.com/service/test/IArithmetic/OutParameter", config.soapActions.soapAction[9].action);
                    Assert.AreEqual <string>("http://contoso.com/service/test/IArithmetic/MixedDirectionParameters", config.soapActions.soapAction[10].action);
                    Assert.AreEqual <string>("http://contoso.com/service/test/ICollections/ProcessCollection", config.soapActions.soapAction[11].action);
                    Assert.AreEqual <string>("http://tempuri.org/ICustomContracts/Overload", config.soapActions.soapAction[12].action);
                    Assert.AreEqual <string>("http://tempuri.org/ICustomContracts/Overload2", config.soapActions.soapAction[13].action);
                    Assert.AreEqual <string>("http://tempuri.org/ICustomContracts/Hidden", config.soapActions.soapAction[14].action);
                    Assert.AreEqual <string>("http://tempuri.org/ICustomContracts2/Contract2Method", config.soapActions.soapAction[15].action);
                    Assert.AreEqual <string>("http://contoso.com/service/test/IBufferedStreamService/BufferedStreamOperation", config.soapActions.soapAction[16].action);
                    Assert.AreEqual <string>("http://contoso.com/service/test/IBufferedStreamService/BufferedMemoryStreamOperation", config.soapActions.soapAction[17].action);
                    Assert.AreEqual <string>("http://contoso.com/service/test/IStreamedStreamService/StreamedStreamOperation", config.soapActions.soapAction[18].action);
                    Assert.AreEqual <string>("http://contoso.com/service/test/IStreamedStreamService/StreamedMemoryStreamOperation", config.soapActions.soapAction[19].action);
                    Assert.AreEqual <string>("http://contoso.com/service/test/IStreamedStreamService/StreamedWithNonStreamParametersOperation", config.soapActions.soapAction[20].action);
                    Assert.AreEqual <string>("http://contoso.com/service/test/IBufferedStreamService/BufferedUnwrappedMessageWithMemoryStream", config.soapActions.soapAction[21].action);
                    Assert.AreEqual <string>("http://contoso.com/service/test/IBufferedStreamService/BufferedUnwrappedMessageWithStream", config.soapActions.soapAction[22].action);
                    Assert.AreEqual <string>("http://contoso.com/service/test/IBufferedStreamService/BufferedWrappedMessageWithMemoryStream", config.soapActions.soapAction[23].action);
                    Assert.AreEqual <string>("http://contoso.com/service/test/IBufferedStreamService/BufferedWrappedMessageWithStream", config.soapActions.soapAction[24].action);
                    Assert.AreEqual <string>("http://contoso.com/service/test/IStreamedStreamService/StreamedUnwrappedMessageWithMemoryStream", config.soapActions.soapAction[25].action);
                    Assert.AreEqual <string>("http://contoso.com/service/test/IStreamedStreamService/StreamedUnwrappedMessageWithStream", config.soapActions.soapAction[26].action);
                    Assert.AreEqual <string>("http://contoso.com/service/test/IStreamedStreamService/StreamedWrappedMessageWithMemoryStream", config.soapActions.soapAction[27].action);
                    Assert.AreEqual <string>("http://contoso.com/service/test/IStreamedStreamService/StreamedWrappedMessageWithStream", config.soapActions.soapAction[28].action);
                    Assert.AreEqual <string>("http://contoso.com/service/test/IShapeService/DoSomething", config.soapActions.soapAction[29].action);
                    Assert.AreEqual <string>("http://contoso.com/asmxservice/test/ProcessSimpleAsmxRequestWrapped", config.soapActions.soapAction[30].action);
                    Assert.AreEqual <string>("http://contoso.com/asmxservice/test/ProcessSimpleAsmxRequestBare", config.soapActions.soapAction[31].action);
                    Assert.AreEqual <string>("http://contoso.com/asmxservice/test/ProcessMultipleParametersWrapped", config.soapActions.soapAction[32].action);
                    Assert.AreEqual <string>("http://contoso.com/asmxservice/test/WithNullableInt", config.soapActions.soapAction[33].action);
                    Assert.AreEqual <string>("http://contoso.com/asmxservice/test/SimpleTypes", config.soapActions.soapAction[34].action);
                    Assert.AreEqual <string>("http://contoso.com/asmxservice/test/ScalarArray", config.soapActions.soapAction[35].action);
                    Assert.AreEqual <string>("http://contoso.com/asmxservice/test/XmlRequestMethod", config.soapActions.soapAction[36].action);
                    Assert.AreEqual <string>("http://contoso.com/asmxservice/test/CollectionMethod", config.soapActions.soapAction[37].action);
                    Assert.AreEqual <string>("http://contoso.com/asmxservice/test/ProcessShape", config.soapActions.soapAction[38].action);

                    foreach (SoapActionType sat in config.soapActions.soapAction)
                    {
                        Assert.IsTrue(sat.Selected);
                    }

                    Assert.Inconclusive("The rest of this test is currently disabled because the functionality to autodiscover the referenced assemblies has been temporarily removed to make sure the user specifies the proxy assembly, because the tool cannot yet cope with proxy-less clients");
                    List <string> assemblies = new List <string>();
                    foreach (AssemblyType a in config.assembly)
                    {
                        assemblies.Add(a.fileName);
                    }

                    Assert.AreEqual <int>(2, assemblies.Count);
                    Assert.IsTrue(assemblies.Contains(exePath));
                    Assert.IsTrue(assemblies.Contains(libPath));
                }
                finally
                {
                    mgr.RestoreOriginalConfiguration();
                    if (logFileName != null)
                    {
                        File.Delete(logFileName);
                    }
                }
            }
        }
Example #10
0
        public void UIRunClient()
        {
            Assert.Inconclusive("Disabled because this test requires web service to be running and will otherwise fail");

            string     exePath = Path.GetFullPath(@"..\..\..\SampleClientAndService\Client\bin\debug\client.exe");
            string     libPath = Path.GetFullPath(@"..\..\..\SampleClientAndService\Client\bin\debug\ClientProxies.dll");
            WizardData data    = new WizardData();

            data.Configuration = new WcfUnitConfiguration();
            UILogic uiLogic = new UILogic();

            using (ScenarioRunManager srm = new ScenarioRunManager())
            {
                uiLogic.RunProgramAndGetWizardData(exePath, srm, data);
                Assert.IsTrue(File.Exists(data.TraceFile));
                Assert.AreEqual <int>(39, data.Configuration.soapActions.soapAction.Length);
                Assert.AreEqual <string>("http://contoso.com/service/test/IArithmetic/Add", data.Configuration.soapActions.soapAction[0].action);
                Assert.AreEqual <string>("http://contoso.com/service/test/IArithmetic/Add2", data.Configuration.soapActions.soapAction[1].action);
                Assert.AreEqual <string>("http://contoso.com/service/test/IArithmetic/Add3", data.Configuration.soapActions.soapAction[2].action);
                Assert.AreEqual <string>("http://contoso.com/service/test/IArithmetic/WrappedAdd", data.Configuration.soapActions.soapAction[3].action);
                Assert.AreEqual <string>("http://contoso.com/service/test/IArithmetic/WrappednoCustomNamesAdd", data.Configuration.soapActions.soapAction[4].action);
                Assert.AreEqual <string>("http://contoso.com/service/test/IArithmetic/WrappedMessageWithHeaderAndBodyNamespaceOverrides", data.Configuration.soapActions.soapAction[5].action);
                Assert.AreEqual <string>("http://contoso.com/service/test/IArithmetic/UnwrappedAdd", data.Configuration.soapActions.soapAction[6].action);
                Assert.AreEqual <string>("http://contoso.com/service/test/IArithmetic/NoParameters", data.Configuration.soapActions.soapAction[7].action);
                Assert.AreEqual <string>("http://contoso.com/service/test/IArithmetic/RefParameter", data.Configuration.soapActions.soapAction[8].action);
                Assert.AreEqual <string>("http://contoso.com/service/test/IArithmetic/OutParameter", data.Configuration.soapActions.soapAction[9].action);
                Assert.AreEqual <string>("http://contoso.com/service/test/IArithmetic/MixedDirectionParameters", data.Configuration.soapActions.soapAction[10].action);
                Assert.AreEqual <string>("http://contoso.com/service/test/ICollections/ProcessCollection", data.Configuration.soapActions.soapAction[11].action);
                Assert.AreEqual <string>("http://tempuri.org/ICustomContracts/Overload", data.Configuration.soapActions.soapAction[12].action);
                Assert.AreEqual <string>("http://tempuri.org/ICustomContracts/Overload2", data.Configuration.soapActions.soapAction[13].action);
                Assert.AreEqual <string>("http://tempuri.org/ICustomContracts/Hidden", data.Configuration.soapActions.soapAction[14].action);
                Assert.AreEqual <string>("http://tempuri.org/ICustomContracts2/Contract2Method", data.Configuration.soapActions.soapAction[15].action);
                Assert.AreEqual <string>("http://contoso.com/service/test/IBufferedStreamService/BufferedStreamOperation", data.Configuration.soapActions.soapAction[16].action);
                Assert.AreEqual <string>("http://contoso.com/service/test/IBufferedStreamService/BufferedMemoryStreamOperation", data.Configuration.soapActions.soapAction[17].action);
                Assert.AreEqual <string>("http://contoso.com/service/test/IStreamedStreamService/StreamedStreamOperation", data.Configuration.soapActions.soapAction[18].action);
                Assert.AreEqual <string>("http://contoso.com/service/test/IStreamedStreamService/StreamedMemoryStreamOperation", data.Configuration.soapActions.soapAction[19].action);
                Assert.AreEqual <string>("http://contoso.com/service/test/IStreamedStreamService/StreamedWithNonStreamParametersOperation", data.Configuration.soapActions.soapAction[20].action);
                Assert.AreEqual <string>("http://contoso.com/service/test/IBufferedStreamService/BufferedUnwrappedMessageWithMemoryStream", data.Configuration.soapActions.soapAction[21].action);
                Assert.AreEqual <string>("http://contoso.com/service/test/IBufferedStreamService/BufferedUnwrappedMessageWithStream", data.Configuration.soapActions.soapAction[22].action);
                Assert.AreEqual <string>("http://contoso.com/service/test/IBufferedStreamService/BufferedWrappedMessageWithMemoryStream", data.Configuration.soapActions.soapAction[23].action);
                Assert.AreEqual <string>("http://contoso.com/service/test/IBufferedStreamService/BufferedWrappedMessageWithStream", data.Configuration.soapActions.soapAction[24].action);
                Assert.AreEqual <string>("http://contoso.com/service/test/IStreamedStreamService/StreamedUnwrappedMessageWithMemoryStream", data.Configuration.soapActions.soapAction[25].action);
                Assert.AreEqual <string>("http://contoso.com/service/test/IStreamedStreamService/StreamedUnwrappedMessageWithStream", data.Configuration.soapActions.soapAction[26].action);
                Assert.AreEqual <string>("http://contoso.com/service/test/IStreamedStreamService/StreamedWrappedMessageWithMemoryStream", data.Configuration.soapActions.soapAction[27].action);
                Assert.AreEqual <string>("http://contoso.com/service/test/IStreamedStreamService/StreamedWrappedMessageWithStream", data.Configuration.soapActions.soapAction[28].action);
                Assert.AreEqual <string>("http://contoso.com/service/test/IShapeService/DoSomething", data.Configuration.soapActions.soapAction[29].action);
                Assert.AreEqual <string>("http://contoso.com/asmxservice/test/ProcessSimpleAsmxRequestWrapped", data.Configuration.soapActions.soapAction[30].action);
                Assert.AreEqual <string>("http://contoso.com/asmxservice/test/ProcessSimpleAsmxRequestBare", data.Configuration.soapActions.soapAction[31].action);
                Assert.AreEqual <string>("http://contoso.com/asmxservice/test/ProcessMultipleParametersWrapped", data.Configuration.soapActions.soapAction[32].action);
                Assert.AreEqual <string>("http://contoso.com/asmxservice/test/WithNullableInt", data.Configuration.soapActions.soapAction[33].action);
                Assert.AreEqual <string>("http://contoso.com/asmxservice/test/SimpleTypes", data.Configuration.soapActions.soapAction[34].action);
                Assert.AreEqual <string>("http://contoso.com/asmxservice/test/ScalarArray", data.Configuration.soapActions.soapAction[35].action);
                Assert.AreEqual <string>("http://contoso.com/asmxservice/test/XmlRequestMethod", data.Configuration.soapActions.soapAction[36].action);
                Assert.AreEqual <string>("http://contoso.com/asmxservice/test/CollectionMethod", data.Configuration.soapActions.soapAction[37].action);
                Assert.AreEqual <string>("http://contoso.com/asmxservice/test/ProcessShape", data.Configuration.soapActions.soapAction[38].action);

                Assert.Inconclusive("The rest of this test is currently disabled because the functionality to autodiscover the referenced assemblies has been temporarily removed to make sure the user specifies the proxy assembly, because the tool cannot yet cope with proxy-less clients");
                List <string> assemblies = new List <string>();
                foreach (AssemblyType a in data.Configuration.assembly)
                {
                    assemblies.Add(a.fileName);
                }

                Assert.AreEqual <int>(2, assemblies.Count);
                Assert.IsTrue(assemblies.Contains(exePath));
                Assert.IsTrue(assemblies.Contains(libPath));
            }
        }