Ejemplo n.º 1
0
        public void WriteWarning_ShouldWriteCorrectSourceToTraceListener()
        {
            using (var context = new TraceContext(SourceLevels.Warning))
            {
                CompositionTraceSource.WriteWarning(0, "format", "arguments");

                Assert.AreEqual("System.ComponentModel.Composition", context.LastTraceEvent.Source);
            }
        }
Ejemplo n.º 2
0
        public void WriteWarning_ShouldWriteTraceEventTypeWarningToTraceListener()
        {
            using (var context = new TraceContext(SourceLevels.Warning))
            {
                CompositionTraceSource.WriteWarning(0, "format", "arguments");

                Assert.AreEqual(TraceEventType.Warning, context.LastTraceEvent.EventType);
            }
        }
Ejemplo n.º 3
0
        internal static void Registration_ParameterImportConventionOverridden(ParameterInfo parameter, ConstructorInfo constructor)
        {
            Assumes.NotNull(parameter, constructor);

            if (CompositionTraceSource.CanWriteWarning)
            {
                CompositionTraceSource.WriteWarning(CompositionTraceId.Registration_ParameterImportConventionOverridden,
                                                    Strings.Registration_ParameterImportConventionOverridden,
                                                    parameter.Name, constructor.Name);
            }
        }
Ejemplo n.º 4
0
        internal static void Registration_PartMetadataConventionOverridden(Type type)
        {
            Assumes.NotNull(type);

            if (CompositionTraceSource.CanWriteWarning)
            {
                CompositionTraceSource.WriteWarning(CompositionTraceId.Registration_PartMetadataConventionOverridden,
                                                    Strings.Registration_PartMetadataConventionOverridden,
                                                    type.FullName);
            }
        }
Ejemplo n.º 5
0
        internal static void Registration_MemberImportConventionMatchedTwice(Type type, MemberInfo member)
        {
            Assumes.NotNull(type, member);

            if (CompositionTraceSource.CanWriteWarning)
            {
                CompositionTraceSource.WriteWarning(CompositionTraceId.Registration_MemberImportConventionMatchedTwice,
                                                    Strings.Registration_MemberImportConventionMatchedTwice,
                                                    member.Name, type.FullName);
            }
        }
Ejemplo n.º 6
0
        internal static void PartDefinitionRejected(ComposablePartDefinition definition, ChangeRejectedException exception)
        {
            Assumes.NotNull(definition, exception);

            if (CompositionTraceSource.CanWriteWarning)
            {
                CompositionTraceSource.WriteWarning(CompositionTraceId.Rejection_DefinitionRejected,
                                                    Strings.CompositionTrace_Rejection_DefinitionRejected,
                                                    definition.GetDisplayName(),
                                                    exception.Message);
            }
        }
Ejemplo n.º 7
0
        public void WriteWarning_ValueAsArgs_ShouldWriteArgsToTraceListener()
        {
            using (var context = new TraceContext(SourceLevels.Warning))
            {
                var expectations = Expectations.GetObjectArraysWithNull();
                foreach (var e in expectations)
                {
                    CompositionTraceSource.WriteWarning(0, "format", e);

                    Assert.AreSame(e, context.LastTraceEvent.Args);
                }
            }
        }
Ejemplo n.º 8
0
        public void WriteWarning_ValueAsFormat_ShouldWriteFormatToTraceListener()
        {
            using (var context = new TraceContext(SourceLevels.Warning))
            {
                var expectations = Expectations.GetExceptionMessages();
                foreach (var e in expectations)
                {
                    CompositionTraceSource.WriteWarning(0, e, "arguments");

                    Assert.AreEqual(e, context.LastTraceEvent.Format);
                }
            }
        }
Ejemplo n.º 9
0
        public void WriteWarning_ValueAsTraceId_ShouldWriteIdToTraceListener()
        {
            using (var context = new TraceContext(SourceLevels.Warning))
            {
                var expectations = Expectations.GetEnumValues <CompositionTraceId>();
                foreach (var e in expectations)
                {
                    CompositionTraceSource.WriteWarning(e, "format", "arguments");

                    Assert.AreEqual(e, (CompositionTraceId)context.LastTraceEvent.Id);
                }
            }
        }
Ejemplo n.º 10
0
        internal static void AssemblyLoadFailed(DirectoryCatalog catalog, string fileName, Exception exception)
        {
            Assumes.NotNull(catalog, exception);
            Assumes.NotNullOrEmpty(fileName);

            if (CompositionTraceSource.CanWriteWarning)
            {
                CompositionTraceSource.WriteWarning(CompositionTraceId.Discovery_AssemblyLoadFailed,
                                                    Strings.CompositionTrace_Discovery_AssemblyLoadFailed,
                                                    catalog.GetDisplayName(),
                                                    fileName,
                                                    exception.Message);
            }
        }
Ejemplo n.º 11
0
        public void WriteWarning_WhenSwitchLevelGreaterThanOrEqualToWarning_ShouldWriteToTraceListener()
        {
            var levels = GetSourceLevelsGreaterThanOrEqualTo(SourceLevels.Information);

            foreach (var level in levels)
            {
                using (TraceContext context = new TraceContext(level))
                {
                    CompositionTraceSource.WriteWarning(0, "format", "arguments");

                    Assert.IsNotNull(context.LastTraceEvent);
                }
            }
        }
Ejemplo n.º 12
0
        internal static void Registration_MemberImportConventionMatchedTwice(Type type, MemberInfo member)
        {
            if (type == null || member == null)
            {
                throw new Exception(SR.Diagnostic_InternalExceptionMessage);
            }

            if (CompositionTraceSource.CanWriteWarning)
            {
                CompositionTraceSource.WriteWarning(CompositionTraceId.Registration_MemberImportConventionMatchedTwice,
                                                    SR.Registration_MemberImportConventionMatchedTwice,
                                                    member.Name, type.FullName);
            }
        }
Ejemplo n.º 13
0
        internal static void Registration_PartCreationConventionOverridden(Type type)
        {
            if (type == null)
            {
                throw new Exception(SR.Diagnostic_InternalExceptionMessage);
            }

            if (CompositionTraceSource.CanWriteWarning)
            {
                CompositionTraceSource.WriteWarning(CompositionTraceId.Registration_PartCreationConventionOverridden,
                                                    SR.Registration_PartCreationConventionOverridden,
                                                    type.FullName);
            }
        }
Ejemplo n.º 14
0
        internal static void Registration_ParameterImportConventionOverridden(ParameterInfo parameter, ConstructorInfo constructor)
        {
            if (parameter == null || constructor == null)
            {
                throw new Exception(SR.Diagnostic_InternalExceptionMessage);
            }

            if (CompositionTraceSource.CanWriteWarning)
            {
                CompositionTraceSource.WriteWarning(CompositionTraceId.Registration_ParameterImportConventionOverridden,
                                                    SR.Registration_ParameterImportConventionOverridden,
                                                    parameter.Name, constructor.Name);
            }
        }
Ejemplo n.º 15
0
        public void WriteWarning_WhenSwitchLevelLessThanWarning_ShouldThrowInternalError()
        {
            var levels = GetSourceLevelsLessThan(SourceLevels.Warning);

            foreach (var level in levels)
            {
                using (TraceContext context = new TraceContext(level))
                {
                    ThrowsInternalError(() =>
                    {
                        CompositionTraceSource.WriteWarning(0, "format", "arguments");
                    });
                }
            }
        }