コード例 #1
0
        public void GenerateFullSampleTestWithProxy()
        {
            this.config = new WcfUnitConfiguration();
            this.config.testMethodMode     = TestMethodMode.ScenarioMethodOnly;
            this.config.operationTimerMode = OperationTimerMode.IncludeOperationTimers;
            AssemblyType a1 = new AssemblyType();

            a1.fileName = "ClientProxies.dll";
            AssemblyType a2 = new AssemblyType();

            a2.fileName = "Contracts.Custom.dll";
            AssemblyType a3 = new AssemblyType();

            a3.fileName             = "ClientProxies.Custom.dll";
            this.config.assembly    = new AssemblyType[] { a1, a2, a3 };
            this.config.soapActions = new WcfUnitConfigurationSoapActions();
            this.config.soapActions.soapActionMode = SoapActionMode.Include;

            Collection <string> proxies = this.sut.ProcessTraceFile("GeneratedSampleTest", "FullSampleTest.svclog", null, this.config);

            Assert.AreEqual <int>(3, proxies.Count);
            Assert.AreEqual <string>("ClientProxies", Path.GetFileNameWithoutExtension(proxies[0]));
            Assert.AreEqual <string>("Contracts.Custom", Path.GetFileNameWithoutExtension(proxies[1]));
            Assert.AreEqual <string>("ClientProxies.Custom", Path.GetFileNameWithoutExtension(proxies[2]));

            File.Copy("GeneratedSampleTest.cs", "..\\..\\..\\Library.Test.Integration\\GeneratedSampleTest.cs", true);
            File.Copy("GeneratedSampleTest.stubs", "..\\..\\..\\Library.Test.Integration\\GeneratedSampleTest.stubs", true);
        }
コード例 #2
0
        /// <summary>
        /// Gets the configuration from a trace file
        /// </summary>
        /// <param name="fileName">The name of the file to parse.</param>
        /// <param name="config">Tells this method what type of trace file it is, the configuration is updated with the soap actions.</param>
        public void ParseTraceFile(string fileName, WcfUnitConfiguration config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            List <SoapActionType> soapActions = new List <SoapActionType>();
            Stream traceFile = null;

            try
            {
                traceFile = Parser.OpenTraceFile(fileName);
                using (Parser parser = Parser.CreateParser(config.parser, traceFile, fileName, config.clientTrace, config.serviceTrace, SoapActionMode.Include))
                {
                    traceFile = null;
                    ParsedMessage msg = null;
                    do
                    {
                        msg = parser.ReadNextRequest();
                        if (msg != null)
                        {
                            SoapActionType newSat = new SoapActionType();
                            newSat.action   = msg.SoapAction;
                            newSat.Selected = true;
                            if (!soapActions.Contains(newSat))
                            {
                                soapActions.Add(newSat);
                            }
                        }
                    }while (msg != null);
                }
            }
            finally
            {
                if (traceFile != null)
                {
                    traceFile.Dispose();
                }
            }

            config.soapActions = new WcfUnitConfigurationSoapActions();
            config.soapActions.soapActionMode = SoapActionMode.Include;
            config.soapActions.soapAction     = soapActions.ToArray();

            //// Set up the assemblies

            ////Trace.WriteLine(string.Format(CultureInfo.InvariantCulture, "Collecting information about referenced assemblies"));
            ////List<string> assemblies = new List<string>();
            ////GetReferencedAssemblies(_exeFileName, assemblies);
            ////Trace.WriteLine(string.Format(CultureInfo.InvariantCulture, "There are {0} referenced assemblies", assemblies.Count));
            ////config.assembly = new assemblyType[assemblies.Count];
            ////for (int i = 0; i < assemblies.Count; i++)
            ////{
            ////    config.assembly[i] = new assemblyType();
            ////    config.assembly[i].fileName = assemblies[i];
            ////}
        }
コード例 #3
0
        public void ConfigurationXAddAssemblyToEmptyConfigurationNewAssemblyAppearsInAssemblyList()
        {
            WcfUnitConfiguration cfg = new WcfUnitConfiguration();

            cfg.AddAssembly("one");

            Assert.AreEqual <int>(1, cfg.assembly.Length);
            Assert.AreEqual <string>("one", cfg.assembly[0].fileName);
        }
コード例 #4
0
        public void ProcessorWhenMoreThanOneTimedCommentBeforeAMessageLastOneOnlyIsInserted()
        {
            List <DateTime> messageTimeStamps = new List <DateTime>();

            // Get the timestamps of the messages in the trace file to be used.
            using (Parser parser = TestHelper.CreateWcfParserFromFile("FullSampleTest.svclog", true, false, SoapActionMode.Include))
            {
                ParsedMessage m;
                do
                {
                    m = parser.ReadNextRequest();
                    if (m != null)
                    {
                        messageTimeStamps.Add(m.Timestamp);
                    }
                }while (m != null);
            }

            // Build timedComments file to place a message before the first and third messages
            DateTime      time1 = messageTimeStamps[0] - new TimeSpan(2);
            DateTime      time2 = messageTimeStamps[0] - new TimeSpan(1);
            DateTime      time3 = messageTimeStamps[2] - new TimeSpan(2);
            StringBuilder sb    = new StringBuilder();

            sb.Append(time1.ToUniversalTime().ToString(@"yyyy-MM-dd\THH:mm:ss.ffffffK", CultureInfo.InvariantCulture));
            sb.Append("Comment1");
            sb.AppendLine();
            sb.Append(time2.ToUniversalTime().ToString(@"yyyy-MM-dd\THH:mm:ss.ffffffK", CultureInfo.InvariantCulture));
            sb.Append("Comment2");
            sb.AppendLine();
            sb.Append(time3.ToUniversalTime().ToString(@"yyyy-MM-dd\THH:mm:ss.ffffffK", CultureInfo.InvariantCulture));
            sb.Append("Comment3");
            sb.AppendLine();
            sb.Append(time3.ToUniversalTime().ToString(@"yyyy-MM-dd\THH:mm:ss.ffffffK", CultureInfo.InvariantCulture));
            sb.Append("Comment4");
            sb.AppendLine();

            string comment1 = time2.ToUniversalTime().ToString(CultureInfo.CurrentCulture) + " Comment2";
            string comment2 = time3.ToUniversalTime().ToString(CultureInfo.CurrentCulture) + " Comment4";

            using (Stream timedCommentsFile = TestHelper.BuildFile(sb.ToString()))
            {
                this.config = new WcfUnitConfiguration();
                this.config.testMethodMode     = TestMethodMode.ScenarioMethodOnly;
                this.config.operationTimerMode = OperationTimerMode.IncludeOperationTimers;
                AssemblyType a = new AssemblyType();
                a.fileName              = "ClientProxies.dll";
                this.config.assembly    = new AssemblyType[] { a };
                this.config.soapActions = new WcfUnitConfigurationSoapActions();
                this.config.soapActions.soapActionMode = SoapActionMode.Include;

                this.sut.ProcessTraceFile("Comment", "FullSampleTest.svclog", timedCommentsFile, this.config);

                TestHelper.CheckFileContains("Comment.cs", @"public void Comment\(\)\s*\{\s*// " + comment1 + @"\s*this.*this.*// " + comment2 + @"\s*this", 1);
            }
        }
コード例 #5
0
        public void ConfigurationXRemoveLastAssemblyFromListLeavesZeroLengthList()
        {
            WcfUnitConfiguration cfg = new WcfUnitConfiguration();

            cfg.AddAssembly("one");

            cfg.RemoveAssembly(0);

            Assert.AreEqual <int>(0, cfg.assembly.Length);
        }
コード例 #6
0
        public void ConfigurationXCloneMakesDeepCopy()
        {
            WcfUnitConfiguration cfg1 = new WcfUnitConfiguration();

            cfg1.clientTrace        = true;
            cfg1.serviceTrace       = false;
            cfg1.operationTimerMode = OperationTimerMode.IncludeOperationTimers;
            cfg1.testMethodMode     = TestMethodMode.IncludeIndividualOperations;
            cfg1.AddAssembly("abc.def");
            cfg1.soapActions = new WcfUnitConfigurationSoapActions();
            cfg1.soapActions.soapActionMode = SoapActionMode.Include;
            cfg1.soapActions.soapAction     = new SoapActionType[1] {
                new SoapActionType()
            };
            cfg1.soapActions.soapAction[0].action   = "action1";
            cfg1.soapActions.soapAction[0].Selected = true;
            cfg1.parser = null;

            WcfUnitConfiguration cfg2 = cfg1.Clone();

            Assert.AreNotSame(cfg1, cfg2);
            Assert.IsTrue(cfg2.clientTrace);
            Assert.IsFalse(cfg2.serviceTrace);
            Assert.AreEqual <OperationTimerMode>(OperationTimerMode.IncludeOperationTimers, cfg2.operationTimerMode);
            Assert.AreEqual <TestMethodMode>(TestMethodMode.IncludeIndividualOperations, cfg2.testMethodMode);
            Assert.AreNotSame(cfg1.assembly, cfg2.assembly);
            Assert.AreEqual <int>(1, cfg2.assembly.Length);
            Assert.AreNotSame(cfg1.assembly[0], cfg2.assembly[0]);
            Assert.AreEqual <string>("abc.def", cfg2.assembly[0].fileName);
            Assert.AreNotSame(cfg1.soapActions, cfg2.soapActions);
            Assert.AreEqual <SoapActionMode>(SoapActionMode.Include, cfg2.soapActions.soapActionMode);
            Assert.AreNotSame(cfg1.soapActions.soapAction, cfg2.soapActions.soapAction);
            Assert.AreEqual <int>(1, cfg2.soapActions.soapAction.Length);
            Assert.AreNotSame(cfg1.soapActions.soapAction[0], cfg2.soapActions.soapAction[0]);
            Assert.AreEqual <string>("action1", cfg2.soapActions.soapAction[0].action);
            Assert.IsTrue(cfg2.soapActions.soapAction[0].Selected);
            Assert.IsNull(cfg2.parser);

            // Now set different values for value types only and make sure these are cloned correctly
            cfg1.clientTrace                        = false;
            cfg1.serviceTrace                       = true;
            cfg1.operationTimerMode                 = OperationTimerMode.NoOperationTimers;
            cfg1.testMethodMode                     = TestMethodMode.ScenarioMethodOnly;
            cfg1.soapActions.soapActionMode         = SoapActionMode.Exclude;
            cfg1.soapActions.soapAction[0].Selected = false;

            cfg2 = cfg1.Clone();

            Assert.IsFalse(cfg2.clientTrace);
            Assert.IsTrue(cfg2.serviceTrace);
            Assert.AreEqual <OperationTimerMode>(OperationTimerMode.NoOperationTimers, cfg2.operationTimerMode);
            Assert.AreEqual <TestMethodMode>(TestMethodMode.ScenarioMethodOnly, cfg2.testMethodMode);
            Assert.AreEqual <SoapActionMode>(SoapActionMode.Exclude, cfg2.soapActions.soapActionMode);
            Assert.IsFalse(cfg2.soapActions.soapAction[0].Selected);
        }
コード例 #7
0
        public void ConfigurationXAddAssemblyToExistingListAppendsNewAssembly()
        {
            WcfUnitConfiguration cfg = new WcfUnitConfiguration();

            cfg.AddAssembly("one");

            cfg.AddAssembly("two");

            Assert.AreEqual <int>(2, cfg.assembly.Length);
            Assert.AreEqual <string>("one", cfg.assembly[0].fileName);
            Assert.AreEqual <string>("two", cfg.assembly[1].fileName);
        }
コード例 #8
0
        public void ConfigurationXRemoveFirstAssemblyFromListOfTwoAssembliesRemovesAssembly()
        {
            WcfUnitConfiguration cfg = new WcfUnitConfiguration();

            cfg.AddAssembly("one");
            cfg.AddAssembly("two");

            cfg.RemoveAssembly(0);

            Assert.AreEqual <int>(1, cfg.assembly.Length);
            Assert.AreEqual <string>("two", cfg.assembly[0].fileName);
        }
コード例 #9
0
        public void ConfigurationNoParserReturnsNullForParser()
        {
            this.CreateConfigFile(@"<?xml version='1.0' encoding='utf-8' ?>
<WcfUnitConfiguration xmlns='http://microsoft.com/wcfunit' testMethodMode='ScenarioMethodOnly' operationTimerMode='IncludeOperationTimers'>
  <assembly fileName='abc'/>
  <soapActions soapActionMode='Include'/>
</WcfUnitConfiguration>
");
            WcfUnitConfiguration config = ConfigurationReader.Read(this.configFileName);

            Assert.IsNull(config.parser);
        }
コード例 #10
0
        public void ProcessorWithMessageBodiesWrongProxy()
        {
            this.config = new WcfUnitConfiguration();
            AssemblyType a = new AssemblyType();

            a.fileName              = "Contracts.Custom.dll";
            this.config.assembly    = new AssemblyType[] { a };
            this.config.soapActions = new WcfUnitConfigurationSoapActions();
            this.config.soapActions.soapActionMode = SoapActionMode.Include;

            TestHelper.TestForUserException(() => this.sut.ProcessTraceFile("MessageContract", "MessageContract.svclog", null, this.config));
        }
コード例 #11
0
        /// <summary>
        /// Runs the program and gets the configuration information.
        /// </summary>
        /// <remarks>
        /// The assemblies found to add to the list to look for the proxy are limited to non-GAC assemblies.
        /// </remarks>
        /// <param name="configuration">The configuration that is to be updated with information from the trace.</param>
        public void Run(WcfUnitConfiguration configuration)
        {
            ////AppDomainSetup testAppSetup = new AppDomainSetup();
            ////testAppSetup.ApplicationBase = Path.GetDirectoryName(this._exeFileName);
            ////testAppSetup.ConfigurationFile = this._configFileName;
            ////testAppSetup.DisallowBindingRedirects = false;
            ////testAppSetup.DisallowCodeDownload = true;
            ////testAppSetup.LoaderOptimization = LoaderOptimization.MultiDomainHost;
            ////AppDomain testApp = AppDomain.CreateDomain("App Under Test", null, testAppSetup);
            ////try
            ////{
            ////    testApp.AssemblyLoad += new AssemblyLoadEventHandler(testApp_AssemblyLoad);
            ////    testApp.ExecuteAssembly(this._exeFileName);
            ////    Assembly[] assemblies = testApp.GetAssemblies();
            ////    config.assembly = new assemblyType[assemblies.Length];
            ////    for(int i=0; i<assemblies.Length; i++)
            ////    {
            ////        config.assembly[i] = new assemblyType();
            ////        config.assembly[i].fileName = assemblies[i].CodeBase;
            ////    }

            using (Process p = new Process())
            {
                p.StartInfo.FileName              = this.exeFileName;
                p.StartInfo.CreateNoWindow        = false;
                p.StartInfo.ErrorDialog           = true;
                p.StartInfo.UseShellExecute       = false;
                p.StartInfo.RedirectStandardError = true;
                Trace.WriteLine("Starting application under test");
                if (p.Start())
                {
                    Trace.WriteLine("Application under test started");
                    string error = p.StandardError.ReadToEnd();
                    Trace.WriteLine("Waiting for application under test to end");
                    p.WaitForExit();
                    Trace.WriteLine("Application under test has ended");
                    if (!string.IsNullOrEmpty(error))
                    {
                        throw new UserException(error);
                    }

                    UILogic uiLogic = new UILogic();
                    uiLogic.ParseTraceFile(this.traceFileName, configuration);
                }
                else
                {
                    Trace.WriteLine("Application under test failed to start");
                }
            }

            Trace.WriteLine("Finished running application under test");
        }
コード例 #12
0
        public void ConfigurationXRemoveAssemblyFromNullListThrowsInvalidOperationException()
        {
            WcfUnitConfiguration cfg = new WcfUnitConfiguration();

            try
            {
                cfg.RemoveAssembly(0);
                Assert.Fail("Expected exception not thrown");
            }
            catch (InvalidOperationException)
            {
            }
        }
コード例 #13
0
        public void ConfigurationServiceTraceSettingValueReadFromConfigurationFile()
        {
            this.CreateConfigFile(@"<?xml version='1.0' encoding='utf-8' ?>
<WcfUnitConfiguration xmlns='http://microsoft.com/wcfunit' testMethodMode='ScenarioMethodOnly' operationTimerMode='IncludeOperationTimers' serviceTrace='true'>
  <assembly fileName='abc'/>
  <soapActions soapActionMode='Include'>
    <soapAction action='http:/abc/def'/>
  </soapActions>
</WcfUnitConfiguration>
");
            WcfUnitConfiguration config = ConfigurationReader.Read(this.configFileName);

            Assert.IsTrue(config.serviceTrace);
        }
コード例 #14
0
        public void ProcessorRefParameters()
        {
            this.config = new WcfUnitConfiguration();
            this.config.testMethodMode     = TestMethodMode.ScenarioMethodOnly;
            this.config.operationTimerMode = OperationTimerMode.NoOperationTimers;
            AssemblyType a1 = new AssemblyType();

            a1.fileName             = "Contracts.dll";
            this.config.assembly    = new AssemblyType[] { a1 };
            this.config.soapActions = new WcfUnitConfigurationSoapActions();
            this.config.soapActions.soapActionMode = SoapActionMode.Include;
            this.sut.ProcessTraceFile("RefParameterScenario", "RefParameter.svclog", null, this.config);
            TestHelper.CheckFileContains("RefParameterScenario.cs", @"int a = 99;\s*this.CustomiseRefParameter\(ref a\);\s*arithmeticClient.RefParameter\(ref a\);", 1);
        }
コード例 #15
0
        public void InitConfig()
        {
            this.config = new WcfUnitConfiguration();
            this.config.testMethodMode     = TestMethodMode.ScenarioMethodOnly;
            this.config.operationTimerMode = OperationTimerMode.IncludeOperationTimers;
            AssemblyType a = new AssemblyType();

            a.fileName              = "ClientProxies.dll";
            this.config.assembly    = new AssemblyType[] { a };
            this.config.soapActions = new WcfUnitConfigurationSoapActions();
            this.config.soapActions.soapActionMode = SoapActionMode.Include;
            File.Delete("SampleWithNamespaces.cs");
            File.Delete("SampleWithNamespaces.stubs");
            this.sut = new TraceFileProcessor();
        }
コード例 #16
0
        public void UIParseServerTraceFileReturnsASoapActionList()
        {
            WcfUnitConfiguration config = new WcfUnitConfiguration();

            config.clientTrace  = false;
            config.serviceTrace = true;
            this.uiLogic.ParseTraceFile("ServiceSideLog.svclog", config);

            Assert.AreEqual <int>(2, config.soapActions.soapAction.Length);
            foreach (SoapActionType sat in config.soapActions.soapAction)
            {
                Assert.IsTrue(!string.IsNullOrEmpty(sat.action));
                Assert.IsTrue(sat.Selected);
            }
        }
コード例 #17
0
        public void ConfigurationXCloneCopiesParserSetting()
        {
            WcfUnitConfiguration cfg1 = new WcfUnitConfiguration();

            cfg1.parser          = new typeType();
            cfg1.parser.assembly = "abc";
            cfg1.parser.type     = "def";

            WcfUnitConfiguration cfg2 = cfg1.Clone();

            Assert.IsNotNull(cfg2.parser);
            Assert.AreNotSame(cfg1.parser, cfg2.parser);
            Assert.AreEqual <string>("abc", cfg2.parser.assembly);
            Assert.AreEqual <string>("def", cfg2.parser.type);
        }
コード例 #18
0
        public void ParseTraceFile(string fileName, WcfUnitConfiguration config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            if (this.throwExceptionForParse)
            {
                throw new UserException("Simulated exception for parse");
            }

            config.assembly    = this.configurationToReturn.assembly;
            config.soapActions = this.configurationToReturn.soapActions;
        }
コード例 #19
0
        public void ConfigurationNoListedSoapActions()
        {
            this.CreateConfigFile(@"<?xml version='1.0' encoding='utf-8' ?>
<WcfUnitConfiguration xmlns='http://microsoft.com/wcfunit' testMethodMode='ScenarioMethodOnly' operationTimerMode='IncludeOperationTimers'>
  <assembly fileName='abc'/>
  <soapActions soapActionMode='Include'>
  </soapActions>
</WcfUnitConfiguration>
");
            WcfUnitConfiguration config = ConfigurationReader.Read(this.configFileName);

            Assert.IsNotNull(config);
            Assert.AreEqual <int>(1, config.assembly.Length);
            Assert.AreEqual <string>("abc", config.assembly[0].fileName);
            Assert.IsNull(config.soapActions.soapAction);
        }
コード例 #20
0
        public void ConfigurationXCloneWithNullArraysMakesDeepCopy()
        {
            WcfUnitConfiguration cfg1 = new WcfUnitConfiguration();

            cfg1.clientTrace                = true;
            cfg1.serviceTrace               = false;
            cfg1.operationTimerMode         = OperationTimerMode.IncludeOperationTimers;
            cfg1.testMethodMode             = TestMethodMode.IncludeIndividualOperations;
            cfg1.soapActions                = new WcfUnitConfigurationSoapActions();
            cfg1.soapActions.soapActionMode = SoapActionMode.Include;

            WcfUnitConfiguration cfg2 = cfg1.Clone();

            Assert.IsNull(cfg2.assembly);
            Assert.IsNull(cfg2.soapActions.soapAction);
        }
コード例 #21
0
        public void ProcessorTimestampsUsedForCommentsWhenNoTimedCommentsFile()
        {
            this.config = new WcfUnitConfiguration();
            this.config.testMethodMode     = TestMethodMode.ScenarioMethodOnly;
            this.config.operationTimerMode = OperationTimerMode.IncludeOperationTimers;
            AssemblyType a = new AssemblyType();

            a.fileName              = "ClientProxies.dll";
            this.config.assembly    = new AssemblyType[] { a };
            this.config.soapActions = new WcfUnitConfigurationSoapActions();
            this.config.soapActions.soapActionMode = SoapActionMode.Include;

            this.sut.ProcessTraceFile("Comment", "FullSampleTest.svclog", null, this.config);

            TestHelper.CheckFileContains("Comment.cs", @"public void Comment\(\)\s*\{\s*// [0-9]{2}/[0-9]{2}/[0-9]{4} [0-9]{2}:[0-9]{2}:[0-9]{2}\s*this", 1);
        }
コード例 #22
0
        public void GenerateScenarioNameMatchesOperationName()
        {
            this.config = new WcfUnitConfiguration();
            this.config.testMethodMode     = TestMethodMode.ScenarioMethodOnly;
            this.config.operationTimerMode = OperationTimerMode.IncludeOperationTimers;
            AssemblyType a = new AssemblyType();

            a.fileName              = "ClientProxies.dll";
            this.config.assembly    = new AssemblyType[] { a };
            this.config.soapActions = new WcfUnitConfigurationSoapActions();
            this.config.soapActions.soapActionMode = SoapActionMode.Include;

            TestHelper.TestForUserException(() => this.sut.ProcessTraceFile("Add", "FullSampleTest.svclog", null, this.config));

            Assert.IsFalse(System.IO.File.Exists("Add.cs"));
            Assert.IsFalse(System.IO.File.Exists("Add.stubs"));
        }
コード例 #23
0
        public void ProcessorTempCollectionWithNoProxy()
        {
            this.config = new WcfUnitConfiguration();
            this.config.testMethodMode     = TestMethodMode.ScenarioMethodOnly;
            this.config.operationTimerMode = OperationTimerMode.IncludeOperationTimers;
            AssemblyType a1 = new AssemblyType();

            a1.fileName             = "Contracts.dll";
            this.config.assembly    = new AssemblyType[] { a1 };
            this.config.soapActions = new WcfUnitConfigurationSoapActions();
            this.config.soapActions.soapActionMode = SoapActionMode.Include;
            SoapActionType action1 = new SoapActionType();

            action1.action = "http://contoso.com/service/test/ICollections/ProcessCollection";
            this.config.soapActions.soapAction = new SoapActionType[] { action1 };

            this.sut.ProcessTraceFile("GeneratedSampleTest", "FullSampleTest.svclog", null, this.config);
        }
コード例 #24
0
        public void Run(WcfUnitConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            Assert.IsFalse(this.disposed, "Disposed ScenarioRunManager re-used");
            Assert.AreEqual <State>(State.Setup, this.state);
            this.state = State.Executed;
            if (this.throwExceptionForRun)
            {
                throw new UserException("Simulated exception for test run");
            }

            configuration.assembly    = this.configurationToReturn.assembly;
            configuration.soapActions = this.configurationToReturn.soapActions;
        }
コード例 #25
0
        public void ProcessorNoTimerNonVoidResult()
        {
            this.config = new WcfUnitConfiguration();
            this.config.testMethodMode     = TestMethodMode.ScenarioMethodOnly;
            this.config.operationTimerMode = OperationTimerMode.NoOperationTimers;
            AssemblyType a = new AssemblyType();

            a.fileName              = "ClientProxies.dll";
            this.config.assembly    = new AssemblyType[] { a };
            this.config.soapActions = new WcfUnitConfigurationSoapActions();
            this.config.soapActions.soapActionMode = SoapActionMode.Include;
            SoapActionType action = new SoapActionType();

            action.action = "http://contoso.com/service/test/IArithmetic/Add";
            this.config.soapActions.soapAction = new SoapActionType[] { action };

            this.sut.ProcessTraceFile("AddScenario", "FullSampleTest.svclog", null, this.config);
            TestHelper.CheckFileContains("AddScenario.cs", @"CustomiseAdd.*\n.*return.*Add.*\n.*\}", 1);
        }
コード例 #26
0
    /// <summary>
    /// Makes a deep copy of this instance.
    /// </summary>
    /// <returns>A deep copy of this instance.</returns>
    public WcfUnitConfiguration Clone()
    {
        WcfUnitConfiguration ans = new WcfUnitConfiguration();

        ans.clientTrace        = this.clientTrace;
        ans.serviceTrace       = this.serviceTrace;
        ans.operationTimerMode = this.operationTimerMode;
        ans.testMethodMode     = this.testMethodMode;
        if (this.assembly != null)
        {
            for (int i = 0; i < this.assembly.Length; i++)
            {
                ans.AddAssembly(this.assembly[i].fileName);
            }
        }

        if (this.soapActions != null)
        {
            ans.soapActions = new WcfUnitConfigurationSoapActions();
            ans.soapActions.soapActionMode = this.soapActions.soapActionMode;
            if (this.soapActions.soapAction != null)
            {
                ans.soapActions.soapAction = new SoapActionType[this.soapActions.soapAction.Length];
                for (int i = 0; i < this.soapActions.soapAction.Length; i++)
                {
                    ans.soapActions.soapAction[i]          = new SoapActionType();
                    ans.soapActions.soapAction[i].action   = this.soapActions.soapAction[i].action;
                    ans.soapActions.soapAction[i].Selected = this.soapActions.soapAction[i].Selected;
                }
            }
        }

        if (this.parser != null)
        {
            ans.parser          = new typeType();
            ans.parser.assembly = this.parser.assembly;
            ans.parser.type     = this.parser.type;
        }

        return(ans);
    }
コード例 #27
0
        public void GenerateFullAsmxSampleTestWithProxyFromFiddlerTrace()
        {
            this.config = new WcfUnitConfiguration();
            this.config.testMethodMode     = TestMethodMode.ScenarioMethodOnly;
            this.config.operationTimerMode = OperationTimerMode.IncludeOperationTimers;
            AssemblyType a1 = new AssemblyType();

            a1.fileName             = "ClientProxies.dll";
            this.config.assembly    = new AssemblyType[] { a1 };
            this.config.soapActions = new WcfUnitConfigurationSoapActions();
            this.config.soapActions.soapActionMode = SoapActionMode.Include;
            this.config.parser = TestHelper.CreateConfigTypeForFiddlerTextFormatParser();

            Collection <string> proxies = this.sut.ProcessTraceFile("GeneratedAsmxFiddlerSampleTest", "AsmxFiddlerIntegrationTest.txt", null, this.config);

            Assert.AreEqual <int>(1, proxies.Count);
            Assert.AreEqual <string>("ClientProxies", Path.GetFileNameWithoutExtension(proxies[0]));

            File.Copy("GeneratedAsmxFiddlerSampleTest.cs", "..\\..\\..\\Library.Test.Integration\\GeneratedAsmxFiddlerSampleTest.cs", true);
            File.Copy("GeneratedAsmxFiddlerSampleTest.stubs", "..\\..\\..\\Library.Test.Integration\\GeneratedAsmxFiddlerSampleTest.stubs", true);
        }
コード例 #28
0
        public void ProcessorExplicitInterfaceImplementation()
        {
            this.config = new WcfUnitConfiguration();
            this.config.testMethodMode     = TestMethodMode.ScenarioMethodOnly;
            this.config.operationTimerMode = OperationTimerMode.NoOperationTimers;
            AssemblyType a1 = new AssemblyType();

            a1.fileName = "ClientProxies.Custom.dll";
            AssemblyType a2 = new AssemblyType();

            a2.fileName             = "Contracts.Custom.dll";
            this.config.assembly    = new AssemblyType[] { a1, a2 };
            this.config.soapActions = new WcfUnitConfigurationSoapActions();
            this.config.soapActions.soapActionMode = SoapActionMode.Include;
            SoapActionType action1 = new SoapActionType();

            action1.action = "http://tempuri.org/ICustomContracts/Hidden";
            this.config.soapActions.soapAction = new SoapActionType[] { action1 };
            this.sut.ProcessTraceFile("SampleWithNamespaces", "ExplicitInterface.svclog", null, this.config);
            TestHelper.CheckFileContains("SampleWithNamespaces.cs", @"customContractsClient.Hidden\(a\);", 1);
        }
コード例 #29
0
        public void ProcessorInterfaceOnly()
        {
            this.config = new WcfUnitConfiguration();
            this.config.testMethodMode     = TestMethodMode.ScenarioMethodOnly;
            this.config.operationTimerMode = OperationTimerMode.NoOperationTimers;
            AssemblyType a1 = new AssemblyType();

            a1.fileName             = "Contracts.Custom.dll";
            this.config.assembly    = new AssemblyType[] { a1 };
            this.config.soapActions = new WcfUnitConfigurationSoapActions();
            this.config.soapActions.soapActionMode = SoapActionMode.Include;
            SoapActionType action1 = new SoapActionType();

            action1.action = "http://tempuri.org/ICustomContracts/Overload";
            SoapActionType action2 = new SoapActionType();

            action2.action = "http://tempuri.org/ICustomContracts/Overload2";
            this.config.soapActions.soapAction = new SoapActionType[] { action1, action2 };
            this.sut.ProcessTraceFile("SampleWithNamespaces", "OverloadedContractMethods.svclog", null, this.config);
            TestHelper.CheckFileContains("SampleWithNamespaces.stubs", @"\[TestInitialize\(\)\]\s*\[System\.Diagnostics\.CodeAnalysis\.SuppressMessage\(""Microsoft.Reliability""\, ""CA2000\:Dispose objects before losing scope""\, Justification\=""proxy should not be disposed""\)\]\s*public void InitializeTest\(\).*try\s*\{\s*customContractsProxyTable\.TryGetValue\(System\.Threading\.Thread\.CurrentThread\.ManagedThreadId, out customContractsClient\);\s*if \(\(\(customContractsClient == null\)\s*\|\|\s*\(\(\(System\.ServiceModel\.ICommunicationObject\)\(customContractsClient\)\)\.State == System\.ServiceModel\.CommunicationState\.Faulted\)\)\)\s*{.*System\.ServiceModel\.ChannelFactory<Contracts\.Custom\.ICustomContracts> customContractsFactory = new System\.ServiceModel\.ChannelFactory<Contracts\.Custom\.ICustomContracts>\(\);\s*customContractsClient = customContractsFactory\.CreateChannel\(\);\s*\(\(System\.ServiceModel\.ICommunicationObject\)\(customContractsClient\)\)\.Open\(\);\s*customContractsProxyTable\[System\.Threading\.Thread\.CurrentThread\.ManagedThreadId\] = customContractsClient;\s*\}\s*\}\s*finally", 1);
        }
コード例 #30
0
        public void ProcessorWithTimerNonVoidResult()
        {
            this.config = new WcfUnitConfiguration();
            this.config.testMethodMode     = TestMethodMode.ScenarioMethodOnly;
            this.config.operationTimerMode = OperationTimerMode.IncludeOperationTimers;
            AssemblyType a = new AssemblyType();

            a.fileName              = "ClientProxies.dll";
            this.config.assembly    = new AssemblyType[] { a };
            this.config.soapActions = new WcfUnitConfigurationSoapActions();
            this.config.soapActions.soapActionMode = SoapActionMode.Include;
            SoapActionType action = new SoapActionType();

            action.action = "http://contoso.com/service/test/IArithmetic/Add";
            this.config.soapActions.soapAction = new SoapActionType[] { action };

            Collection <string> proxies = this.sut.ProcessTraceFile("AddScenario", "FullSampleTest.svclog", null, this.config);

            Assert.AreEqual <int>(1, proxies.Count);
            Assert.AreEqual <string>("ClientProxies", Path.GetFileNameWithoutExtension(proxies[0]));

            TestHelper.CheckFileContains("AddScenario.cs", @"CustomiseAdd.*\n.*BeginTimer.*\n.*try.*\n.*\n.*return.*Add.*\n.*\n.*finally.*\n.*\n.*EndTimer", 1);
        }