public void ThenConnectionStringIsProvidedAsParameter()
 {
     registration.AssertConstructor()
     .WithValueConstructorParameter("myConnectionString")
     .WithContainerResolvedParameter <IDataInstrumentationProvider>("myConnectionName")
     .VerifyConstructorParameters();
 }
예제 #2
0
 public void ThenModelContainsProperlyPrefixedNameForTheExceptionType()
 {
     registration.AssertConstructor()
     .WithValueConstructorParameter("policy")
     .WithContainerResolvedEnumerableConstructorParameter <ExceptionPolicyEntry>(new[] { "policy.type" })
     .VerifyConstructorParameters();
 }
예제 #3
0
        public void ThenRegistryEntryReturnsEmptyConstructor()
        {
            TypeRegistration registry =
                listenerData.GetRegistrations().Where(tr => tr.Name == "systemDiagnosticsTraceListener\u200Cimplementation").First();

            registry.AssertConstructor()
            .VerifyConstructorParameters();
        }
예제 #4
0
 public void ThenProviderAllConstructorParameter()
 {
     registration
     .AssertConstructor()
     .WithValueConstructorParameter("policy")
     .WithContainerResolvedEnumerableConstructorParameter <ExceptionPolicyEntry>(new string[0])
     .VerifyConstructorParameters();
 }
예제 #5
0
        public void ThenRegistrationTargetsConstructorWithInitialData()
        {
            TypeRegistration registry
                = listenerData.GetRegistrations().Where(tr => tr.Name == "systemDiagnosticsTraceListener\u200Cimplementation").First();

            registry.AssertConstructor()
            .WithValueConstructorParameter <string>("someInitData")
            .VerifyConstructorParameters();
        }
예제 #6
0
        public void TheRegistrationForTraceManagerHasExpectedConstructorParameters()
        {
            TypeRegistration registration = registrations.First(tr => tr.ServiceType == typeof(TraceManager));

            registration
            .AssertConstructor()
            .WithContainerResolvedParameter <LogWriter>(null)
            .WithContainerResolvedParameter <ITracerInstrumentationProvider>(null)
            .VerifyConstructorParameters();
        }
예제 #7
0
        public void TheRegistrationForILoggingUpdateCoordinatorHasExpectedConstructorParameters()
        {
            TypeRegistration registration = registrations.First(tr => tr.ServiceType == typeof(ILoggingUpdateCoordinator));

            registration
            .AssertConstructor()
            .WithContainerResolvedParameter <ConfigurationChangeEventSource>(null)
            .WithContainerResolvedParameter <ILoggingInstrumentationProvider>(null)
            .VerifyConstructorParameters();
        }
예제 #8
0
 public void ThenProviderAllConstructorParameters()
 {
     registration
     .AssertConstructor()
     .WithValueConstructorParameter(typeof(ArgumentNullException))
     .WithValueConstructorParameter(PostHandlingAction.None)
     .WithContainerResolvedEnumerableConstructorParameter <IExceptionHandler>(new[] { "prefix.name.replace", "prefix.name.wrap" })
     .WithContainerResolvedParameter <IExceptionHandlingInstrumentationProvider>("prefix")
     .VerifyConstructorParameters();
 }
예제 #9
0
 public void ThenProviderAllConstructorParameters()
 {
     registration
     .AssertConstructor()
     .WithValueConstructorParameter(typeof(ArgumentException))
     .WithValueConstructorParameter(PostHandlingAction.ThrowNewException)
     .WithContainerResolvedEnumerableConstructorParameter <IExceptionHandler>(new string[0])
     .WithContainerResolvedParameter <IExceptionHandlingInstrumentationProvider>("prefix")
     .VerifyConstructorParameters();
 }
예제 #10
0
        public void TheRegistrationForLogWriterHasExpectedConstructorParameters()
        {
            TypeRegistration registration = registrations.First(tr => tr.ServiceType == typeof(LogWriter));

            registration
            .AssertConstructor()
            .WithContainerResolvedParameter <LogWriterStructureHolder>(null)
            .WithContainerResolvedParameter <ILoggingInstrumentationProvider>(null)
            .WithContainerResolvedParameter <ILoggingUpdateCoordinator>(null)
            .VerifyConstructorParameters();
        }
예제 #11
0
        public void WhenAskedForTypeRegistration_ThenReturnsTypeRegistrationConfiguringMockExceptionHandlerWithTheAttributesCollection()
        {
            TypeRegistration typeRegistration = handlerData.GetRegistrations("prefix").First();

            typeRegistration
            .AssertForServiceType(typeof(IExceptionHandler))
            .ForName("prefix.custom")
            .ForImplementationType(typeof(MockExceptionHandler));

            typeRegistration.AssertConstructor()
            .WithValueConstructorParameter(handlerData.Attributes)
            .VerifyConstructorParameters();
        }
        public void WhenGettingRegistrationMessageIsBroughtFromResource()
        {
            IStringResolver resolver;

            typeRegistration
            .AssertForServiceType(typeof(IExceptionHandler))
            .ForName("prefix.wcf")
            .ForImplementationType(typeof(FaultContractExceptionHandler));

            typeRegistration.AssertConstructor()
            .WithValueConstructorParameter(out resolver);

            Assert.AreEqual(Resources.WcfMessageResource, resolver.GetString());
        }
예제 #13
0
        public void ThenConstructorParametersProvideAttributes()
        {
            NameValueCollection attributes;

            registration.AssertConstructor()
            .WithValueConstructorParameter <NameValueCollection>(out attributes)
            .VerifyConstructorParameters();


            CollectionAssert.AreEquivalent(
                attributes,
                ((ConstantParameterValue)registration.ConstructorParameters.ElementAt(0)).Value as NameValueCollection
                );
        }
        public void ThenConnectionStringAndPackagesAreProvidedAsParameters()
        {
            IEnumerable <IOraclePackage> packages;

            registration.AssertConstructor()
            .WithValueConstructorParameter("myConnectionString")
            .WithValueConstructorParameter(out packages)
            .WithContainerResolvedParameter <IDataInstrumentationProvider>("myConnectionName")
            .VerifyConstructorParameters();

            Assert.AreEqual(1, packages.Count());
            Assert.AreEqual("foo", packages.ElementAt(0).Name);
            Assert.AreEqual("bar", packages.ElementAt(0).Prefix);
        }
        public void WhenCreatingRegistrations_ThenCreatedTypeRegistrationDescribingTheProvider()
        {
            var typeRegistrations = cryptographySettings.GetRegistrations(null);

            TypeRegistration registration = typeRegistrations.ElementAt(0);

            registration
            .AssertForServiceType(typeof(ISymmetricCryptoProvider))
            .ForName("dpapi")
            .ForImplementationType(typeof(DpapiSymmetricCryptoProvider))
            .IsPublicName();

            registration.AssertConstructor()
            .WithValueConstructorParameter(DataProtectionScope.LocalMachine)
            .VerifyConstructorParameters();
        }
        public void WhenCreatingRegistrations_ThenCreatedTypeRegistrationDescribingTheProvider()
        {
            var typeRegistrations = cryptographySettings.GetRegistrations(null);

            TypeRegistration registration = typeRegistrations.ElementAt(0);

            registration
            .AssertForServiceType(typeof(ISymmetricCryptoProvider))
            .ForName("custom")
            .ForImplementationType(typeof(MockCustomSymmetricProvider))
            .IsPublicName();

            registration.AssertConstructor()
            .WithValueConstructorParameter(customSymmetricCryptoProviderData.Attributes)
            .VerifyConstructorParameters();
        }
예제 #17
0
        public void WhenAskedForTypeRegitration_ThenReturnsTypeRegistrationConfiguringReplaceHandler()
        {
            TypeRegistration typeRegistration = handlerData.GetRegistrations("prefix").First();
            IStringResolver  resolver;

            typeRegistration
            .AssertForServiceType(typeof(IExceptionHandler))
            .ForName("prefix.replace")
            .ForImplementationType(typeof(ReplaceHandler));

            typeRegistration.AssertConstructor()
            .WithValueConstructorParameter(out resolver)
            .WithValueConstructorParameter(typeof(Exception))
            .VerifyConstructorParameters();

            Assert.AreEqual(Resources.ExceptionMessage, resolver.GetString());
        }
        public void WhenCreatingRegistrations_ThenCreatedTypeRegistrationDescribingTheProvider()
        {
            var typeRegistrations = settings.GetRegistrations(configurationSource)
                                    .Where(r => r.ServiceType == typeof(Database));

            TypeRegistration registration = typeRegistrations.ElementAt(0);

            registration
            .AssertForServiceType(typeof(Database))
            .ForName("sql connection")
            .ForImplementationType(typeof(SqlDatabase))
            .IsPublicName();

            registration.AssertConstructor()
            .WithValueConstructorParameter("connection string")
            .WithContainerResolvedParameter <IDataInstrumentationProvider>("sql connection")
            .VerifyConstructorParameters();
        }
        public void WhenCreatingRegistrations_ThenCreatedTypeRegistrationDescribingTheProvider()
        {
            var typeRegistrations = cryptographySettings.GetRegistrations(null);

            TypeRegistration registration = typeRegistrations.Where(x => x.ServiceType == typeof(IHashProvider)).ElementAt(0);

            registration
            .AssertForServiceType(typeof(IHashProvider))
            .ForName("name")
            .ForImplementationType(typeof(HashAlgorithmProvider))
            .IsPublicName();

            registration.AssertConstructor()
            .WithValueConstructorParameter(typeof(RijndaelManaged))
            .WithValueConstructorParameter(true)
            .WithContainerResolvedParameter <IHashAlgorithmInstrumentationProvider>("name")
            .VerifyConstructorParameters();
        }
        public void WhenCreatingRegistrations_ThenShouldProvideOdbcRegistration()
        {
            var typeRegistrations = settings.GetRegistrations(configurationSource)
                                    .Where(r => r.ServiceType == typeof(Database));

            TypeRegistration registration = typeRegistrations.ElementAt(0);

            registration
            .AssertForServiceType(typeof(Database))
            .ForName("odbc connection")
            .ForImplementationType(typeof(GenericDatabase))
            .IsPublicName();

            registration.AssertConstructor()
            .WithValueConstructorParameter("connection string")
            .WithValueConstructorParameter <DbProviderFactory>(System.Data.Odbc.OdbcFactory.Instance)
            .WithContainerResolvedParameter <IDataInstrumentationProvider>("odbc connection")
            .VerifyConstructorParameters();
        }
        public void WhenCreatingRegistrations_ThenCreatedTypeRegistrationDescribingTheProvider()
        {
            var typeRegistrations = cryptographySettings.GetRegistrations(null).Where(x => x.ServiceType == typeof(ISymmetricCryptoProvider));

            TypeRegistration registration = typeRegistrations.ElementAt(0);

            registration
            .AssertForServiceType(typeof(ISymmetricCryptoProvider))
            .ForName("symmetric algorithm")
            .ForImplementationType(typeof(SymmetricAlgorithmProvider))
            .IsPublicName();

            registration.AssertConstructor()
            .WithValueConstructorParameter(typeof(RijndaelManaged))
            .WithValueConstructorParameter("protected key")
            .WithValueConstructorParameter(DataProtectionScope.LocalMachine)
            .WithContainerResolvedParameter <ISymmetricAlgorithmInstrumentationProvider>("symmetric algorithm")
            .VerifyConstructorParameters();
        }
예제 #22
0
        public void TheRegistrationForLogWriterStructureHolderInjectsTheFilters()
        {
            TypeRegistration     registration = registrations.First(tr => tr.ServiceType == typeof(LogWriterStructureHolder));
            IEnumerable <string> sourceNames;

            registration
            .AssertConstructor()
            .WithContainerResolvedEnumerableConstructorParameter <ILogFilter>(new[] { "priority", "enabled" })
            .WithValueConstructorParameter(out sourceNames)
            .WithContainerResolvedEnumerableConstructorParameter <LogSource>(new string[0])
            .WithContainerResolvedParameter <LogSource>("___ALL")
            .WithContainerResolvedParameter <LogSource>("___NO_MATCHES")
            .WithContainerResolvedParameter <LogSource>("___ERRORS")
            .WithValueConstructorParameter("")
            .WithValueConstructorParameter(true)
            .WithValueConstructorParameter(true)
            .WithValueConstructorParameter(true)
            .VerifyConstructorParameters();
        }
예제 #23
0
        public void TheRegistrationForLogWriterStructureHolderHasExpectedConstructorParameters()
        {
            TypeRegistration     registration = registrations.First(tr => tr.ServiceType == typeof(LogWriterStructureHolder));
            IEnumerable <string> traceSourceNames;

            registration
            .AssertConstructor()
            .WithContainerResolvedEnumerableConstructorParameter <ILogFilter>(new string[0])
            .WithValueConstructorParameter(out traceSourceNames)
            .WithContainerResolvedEnumerableConstructorParameter <LogSource>(new string[0])
            .WithContainerResolvedParameter <LogSource>("___ALL")
            .WithContainerResolvedParameter <LogSource>("___NO_MATCHES")
            .WithContainerResolvedParameter <LogSource>("___ERRORS")
            .WithValueConstructorParameter("")
            .WithValueConstructorParameter(true)
            .WithValueConstructorParameter(true)
            .WithValueConstructorParameter(true)
            .VerifyConstructorParameters();

            Assert.AreEqual(0, traceSourceNames.Count());
        }
예제 #24
0
 public void ThenShouldProviderProperConstructorParameters()
 {
     registration.AssertConstructor()
     .WithValueConstructorParameter <string>(formatter.Template);
 }
 public void ThenNoConstructorParametersSupplied()
 {
     registration.AssertConstructor().VerifyConstructorParameters();
 }