Exemplo n.º 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();
                }
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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));
            }
        }
Exemplo n.º 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))
                {
                }
            });
        }
Exemplo n.º 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))
                {
                }
            });
        }
Exemplo n.º 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))
                {
                }
            });
        }
Exemplo n.º 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);
        }
Exemplo n.º 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;
 }
Exemplo n.º 12
0
 public extended()
 {
     this.typeField = typeType.extended;
 }
Exemplo n.º 13
0
 public arcType()
 {
     this.typeField = typeType.arc;
 }
Exemplo n.º 14
0
 public MetadataURLType()
 {
     this.typeField = typeType.simple;
 }
Exemplo n.º 15
0
 public RecordType_Type()
 {
     this.typeField = typeType.simple;
 }
Exemplo n.º 16
0
 public MemberPropertyType()
 {
     this.typeField = typeType.simple;
 }
 public arcType()
 {
     this.typeField = typeType.arc;
 }
Exemplo n.º 18
0
 public OnlineResourceType()
 {
     this.typeField = typeType.simple;
 }
Exemplo n.º 19
0
 public locatorType()
 {
     this.typeField = typeType.locator;
 }
 public extended()
 {
     this.typeField = typeType.extended;
 }
Exemplo n.º 21
0
 public RecordType_Type()
 {
     this.typeField = typeType.simple;
 }
Exemplo n.º 22
0
 public resourceType()
 {
     this.typeField = typeType.resource;
 }
 public locatorType()
 {
     this.typeField = typeType.locator;
 }
Exemplo n.º 24
0
 public titleEltType()
 {
     this.typeField = typeType.title;
 }
 public MetadataType()
 {
     this.typeField = typeType.simple;
 }
Exemplo n.º 26
0
 public simple()
 {
     this.typeField = typeType.simple;
 }
 public OnlineResourceType()
 {
     this.typeField = typeType.simple;
 }
Exemplo n.º 28
0
 public MetadataType()
 {
     this.type = typeType.simple;
 }
 public resourceType()
 {
     this.typeField = typeType.resource;
 }