Esempio n. 1
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);
        }
Esempio n. 2
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);
        }
Esempio n. 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);
        }
Esempio n. 4
0
        public void ConfigurationXRemoveLastAssemblyFromListLeavesZeroLengthList()
        {
            WcfUnitConfiguration cfg = new WcfUnitConfiguration();

            cfg.AddAssembly("one");

            cfg.RemoveAssembly(0);

            Assert.AreEqual <int>(0, cfg.assembly.Length);
        }
Esempio n. 5
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);
        }
Esempio n. 6
0
        public void ConfigurationXRemoveAssemblyFromEmptyListThrowsInvalidOperationException()
        {
            WcfUnitConfiguration cfg = new WcfUnitConfiguration();

            cfg.AddAssembly("one");
            cfg.RemoveAssembly(0);

            try
            {
                cfg.RemoveAssembly(0);
                Assert.Fail("Expected exception not thrown");
            }
            catch (InvalidOperationException)
            {
            }
        }
    /// <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);
    }