Example #1
0
        public void ParserCreateParserCreatesAndSetsUpTheFormatSpecificParser()
        {
            // Arrange
            Stream s = null;

            try
            {
                s = Parser.OpenTraceFile("WithMessageBodies.svclog");

                // Act
                typeType wcfFormatParser = TestHelper.CreateConfigTypeForWcfFormatParser();
                using (Parser p = Parser.CreateParser(wcfFormatParser, s, "test", true, false, SoapActionMode.Include))
                {
                    s = null;

                    // Assert
                    Assert.IsNotNull(p); // checks it is created
                    // Check it is setup
                    p.ReadNextRequest();
                }
            }
            finally
            {
                if (s != null)
                {
                    s.Dispose();
                }
            }
        }
Example #2
0
        public static TConfigured CreateConfiguredType <TConfigured>(typeType configuredTypeName) where TConfigured : class
        {
            if (configuredTypeName == null)
            {
                throw new ArgumentNullException("configuredTypeName");
            }

            TConfigured ans = null;
            string      assemblyQualifiedName = configuredTypeName.type + "," + configuredTypeName.assembly;

            try
            {
                Type configuredType = Type.GetType(assemblyQualifiedName, true, false);
                ans = Activator.CreateInstance(configuredType) as TConfigured;
                if (ans == null)
                {
                    throw new UserException(string.Format(CultureInfo.CurrentCulture, Messages.ConfiguredTypeMismatch, assemblyQualifiedName, typeof(TConfigured).FullName));
                }
            }
            catch (IOException fle)
            {
                throw new UserException(string.Format(CultureInfo.CurrentCulture, Messages.ConfiguredTypeLoadError, assemblyQualifiedName, fle.Message));
            }
            catch (TypeLoadException tle)
            {
                throw new UserException(string.Format(CultureInfo.CurrentCulture, Messages.ConfiguredTypeLoadError, assemblyQualifiedName, tle.Message));
            }
            catch (MemberAccessException mae)
            {
                throw new UserException(string.Format(CultureInfo.CurrentCulture, Messages.ConfiguredTypeLoadError, assemblyQualifiedName, mae.Message));
            }

            return(ans);
        }
Example #3
0
        /// <summary>
        /// Creates the configuration type for the <see cref="FiddlerTextParser"/>.
        /// </summary>
        /// <returns>The configuration type for the <see cref="FiddlerTextParser"/></returns>
        internal static typeType CreateConfigTypeForFiddlerTextFormatParser()
        {
            typeType wcfFormatParser = new typeType();

            wcfFormatParser.assembly = TestHelper.LibraryAssembly;
            wcfFormatParser.type     = "Microsoft.WcfUnit.Library.FiddlerTextParser";
            return(wcfFormatParser);
        }
Example #4
0
        public void UTILCreateConfiguredType()
        {
            // Arrange
            typeType t = TestHelper.CreateConfigTypeForWcfFormatParser();

            // Act
            using (IFormatParser dummy = Utility.CreateConfiguredType <IFormatParser>(t))
            {
                // Assert
                Assert.IsNotNull(dummy);
                Assert.IsInstanceOfType(dummy, typeof(WcfParser));
            }
        }
Example #5
0
        public void UTILCreateConfiguredTypeThrowsExceptionIfTypeDoesNotHaveParameterlessConstructor()
        {
            // Arrange
            typeType t = new typeType();

            t.assembly = TestHelper.LibraryAssembly;
            t.type     = "Microsoft.WcfUnit.Library.Parser";

            // Act and assert
            TestHelper.TestForUserException(
                delegate
            {
                using (Parser dummy = Utility.CreateConfiguredType <Parser>(t))
                {
                }
            });
        }
Example #6
0
        public void UTILCreateConfiguredTypeThrowsExceptionIfTypeDoesNotMatch()
        {
            // Arrange
            typeType t = new typeType();

            t.assembly = TestHelper.LibraryAssembly;
            t.type     = "Microsoft.WcfUnit.Library.FiddlerTextParser";

            // Act and assert
            TestHelper.TestForUserException(
                delegate
            {
                using (WcfParser dummy = Utility.CreateConfiguredType <WcfParser>(t))
                {
                }
            });
        }
Example #7
0
        public void UTILCreateConfiguredTypeThrowsExceptionIfTypeNotFound()
        {
            // Arrange
            typeType t = new typeType();

            t.assembly = TestHelper.LibraryAssembly;
            t.type     = "NonExistent";

            // Act and assert
            TestHelper.TestForUserException(
                delegate
            {
                using (IFormatParser dummy = Utility.CreateConfiguredType <IFormatParser>(t))
                {
                }
            });
        }
Example #8
0
        public static Parser CreateParser(typeType formatParserType, Stream traceFile, string fileName, bool clientTrace, bool serviceTrace, SoapActionMode soapActionMode, params string[] soapActions)
        {
            IFormatParser formatParser = null;

            if (formatParserType == null)
            {
                formatParser = new WcfParser();
            }
            else
            {
                formatParser = Utility.CreateConfiguredType <IFormatParser>(formatParserType);
            }

            formatParser.Setup(traceFile, fileName, clientTrace, serviceTrace);
            Parser ans = new Parser(formatParser, soapActionMode, soapActions);

            return(ans);
        }
Example #9
0
        public void ParserIsDisposable()
        {
            // Arrange
            Stream s = null;

            try
            {
                s = Parser.OpenTraceFile("WithMessageBodies.svclog");

                // Act and assert
                typeType wcfFormatParser = TestHelper.CreateConfigTypeForWcfFormatParser();
                using (Parser p = Parser.CreateParser(wcfFormatParser, s, "test", true, false, SoapActionMode.Include))
                {
                    s = null;
                }
            }
            finally
            {
                if (s != null)
                {
                    s.Dispose();
                }
            }
        }
 public titleEltType()
 {
     this.typeField = typeType.title;
 }
 public simple()
 {
     this.typeField = typeType.simple;
 }
Example #12
0
 public extended()
 {
     this.typeField = typeType.extended;
 }
Example #13
0
 public arcType()
 {
     this.typeField = typeType.arc;
 }
Example #14
0
 public MetadataURLType()
 {
     this.typeField = typeType.simple;
 }
Example #15
0
 public RecordType_Type()
 {
     this.typeField = typeType.simple;
 }
Example #16
0
 public MemberPropertyType()
 {
     this.typeField = typeType.simple;
 }
 public arcType()
 {
     this.typeField = typeType.arc;
 }
Example #18
0
 public OnlineResourceType()
 {
     this.typeField = typeType.simple;
 }
Example #19
0
 public locatorType()
 {
     this.typeField = typeType.locator;
 }
 public extended()
 {
     this.typeField = typeType.extended;
 }
Example #21
0
 public RecordType_Type()
 {
     this.typeField = typeType.simple;
 }
Example #22
0
 public resourceType()
 {
     this.typeField = typeType.resource;
 }
 public locatorType()
 {
     this.typeField = typeType.locator;
 }
Example #24
0
 public titleEltType()
 {
     this.typeField = typeType.title;
 }
 public MetadataType()
 {
     this.typeField = typeType.simple;
 }
Example #26
0
 public simple()
 {
     this.typeField = typeType.simple;
 }
 public OnlineResourceType()
 {
     this.typeField = typeType.simple;
 }
Example #28
0
 public MetadataType()
 {
     this.type = typeType.simple;
 }
 public resourceType()
 {
     this.typeField = typeType.resource;
 }