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

                Assert.AreEqual(TraceEventType.Information, context.LastTraceEvent.EventType);
            }
        }
Ejemplo n.º 2
0
        public void WriteInformation_ShouldWriteCorrectSourceToTraceListener()
        {
            using (var context = new TraceContext(SourceLevels.Information))
            {
                CompositionTraceSource.WriteInformation(0, "format", "arguments");

                Assert.AreEqual("System.ComponentModel.Composition", context.LastTraceEvent.Source);
            }
        }
Ejemplo n.º 3
0
        internal static void DefinitionContainsNoExports(Type type)
        {
            Assumes.NotNull(type);

            if (CompositionTraceSource.CanWriteInformation)
            {
                CompositionTraceSource.WriteInformation(CompositionTraceId.Discovery_DefinitionContainsNoExports,
                                                        Strings.CompositionTrace_Discovery_DefinitionContainsNoExports,
                                                        type.GetDisplayName());
            }
        }
Ejemplo n.º 4
0
        internal static void DefinitionMarkedWithPartNotDiscoverableAttribute(Type type)
        {
            Assumes.NotNull(type);

            if (CompositionTraceSource.CanWriteInformation)
            {
                CompositionTraceSource.WriteInformation(CompositionTraceId.Discovery_DefinitionMarkedWithPartNotDiscoverableAttribute,
                                                        Strings.CompositionTrace_Discovery_DefinitionMarkedWithPartNotDiscoverableAttribute,
                                                        type.GetDisplayName());
            }
        }
Ejemplo n.º 5
0
        internal static void PartDefinitionResurrected(ComposablePartDefinition definition)
        {
            Assumes.NotNull(definition);

            if (CompositionTraceSource.CanWriteInformation)
            {
                CompositionTraceSource.WriteInformation(CompositionTraceId.Rejection_DefinitionResurrected,
                                                        Strings.CompositionTrace_Rejection_DefinitionResurrected,
                                                        definition.GetDisplayName());
            }
        }
Ejemplo n.º 6
0
        internal static void Registration_ConstructorConventionOverridden(Type type)
        {
            Assumes.NotNull(type);

            if (CompositionTraceSource.CanWriteInformation)
            {
                CompositionTraceSource.WriteInformation(CompositionTraceId.Registration_ConstructorConventionOverridden,
                                                        Strings.Registration_ConstructorConventionOverridden,
                                                        type.FullName);
            }
        }
Ejemplo n.º 7
0
        internal static void DefinitionMismatchedExportArity(Type type, MemberInfo member)
        {
            Assumes.NotNull(type);
            Assumes.NotNull(member);

            if (CompositionTraceSource.CanWriteInformation)
            {
                CompositionTraceSource.WriteInformation(CompositionTraceId.Discovery_DefinitionMismatchedExportArity,
                                                        SR.CompositionTrace_Discovery_DefinitionMismatchedExportArity,
                                                        type.GetDisplayName(), member.GetDisplayName());
            }
        }
Ejemplo n.º 8
0
        public void WriteInformation_ValueAsArgs_ShouldWriteArgsToTraceListener()
        {
            using (var context = new TraceContext(SourceLevels.Information))
            {
                var expectations = Expectations.GetObjectArraysWithNull();
                foreach (var e in expectations)
                {
                    CompositionTraceSource.WriteInformation(0, "format", e);

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

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

                    Assert.AreEqual(e, (CompositionTraceId)context.LastTraceEvent.Id);
                }
            }
        }
Ejemplo n.º 11
0
        public void WriteInformation_WhenSwitchLevelGreaterThanOrEqualToInformation_ShouldWriteToTraceListener()
        {
            var levels = GetSourceLevelsGreaterThanOrEqualTo(SourceLevels.Information);

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

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

            if (CompositionTraceSource.CanWriteInformation)
            {
                CompositionTraceSource.WriteInformation(CompositionTraceId.Registration_ConstructorConventionOverridden,
                                                        SR.Registration_ConstructorConventionOverridden,
                                                        type.FullName);
            }
        }
Ejemplo n.º 13
0
        public void WriteInformation_WhenSwitchLevelLessThanInformation_ShouldThrowInternalError()
        {
            var levels = GetSourceLevelsLessThan(SourceLevels.Information);

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