public void ThenConnectionStringIsProvidedAsParameter() { registration.AssertConstructor() .WithValueConstructorParameter("myConnectionString") .WithContainerResolvedParameter <IDataInstrumentationProvider>("myConnectionName") .VerifyConstructorParameters(); }
public void ThenModelContainsProperlyPrefixedNameForTheExceptionType() { registration.AssertConstructor() .WithValueConstructorParameter("policy") .WithContainerResolvedEnumerableConstructorParameter <ExceptionPolicyEntry>(new[] { "policy.type" }) .VerifyConstructorParameters(); }
public void ThenRegistryEntryReturnsEmptyConstructor() { TypeRegistration registry = listenerData.GetRegistrations().Where(tr => tr.Name == "systemDiagnosticsTraceListener\u200Cimplementation").First(); registry.AssertConstructor() .VerifyConstructorParameters(); }
public void ThenProviderAllConstructorParameter() { registration .AssertConstructor() .WithValueConstructorParameter("policy") .WithContainerResolvedEnumerableConstructorParameter <ExceptionPolicyEntry>(new string[0]) .VerifyConstructorParameters(); }
public void ThenRegistrationTargetsConstructorWithInitialData() { TypeRegistration registry = listenerData.GetRegistrations().Where(tr => tr.Name == "systemDiagnosticsTraceListener\u200Cimplementation").First(); registry.AssertConstructor() .WithValueConstructorParameter <string>("someInitData") .VerifyConstructorParameters(); }
public void TheRegistrationForTraceManagerHasExpectedConstructorParameters() { TypeRegistration registration = registrations.First(tr => tr.ServiceType == typeof(TraceManager)); registration .AssertConstructor() .WithContainerResolvedParameter <LogWriter>(null) .WithContainerResolvedParameter <ITracerInstrumentationProvider>(null) .VerifyConstructorParameters(); }
public void TheRegistrationForILoggingUpdateCoordinatorHasExpectedConstructorParameters() { TypeRegistration registration = registrations.First(tr => tr.ServiceType == typeof(ILoggingUpdateCoordinator)); registration .AssertConstructor() .WithContainerResolvedParameter <ConfigurationChangeEventSource>(null) .WithContainerResolvedParameter <ILoggingInstrumentationProvider>(null) .VerifyConstructorParameters(); }
public void ThenProviderAllConstructorParameters() { registration .AssertConstructor() .WithValueConstructorParameter(typeof(ArgumentNullException)) .WithValueConstructorParameter(PostHandlingAction.None) .WithContainerResolvedEnumerableConstructorParameter <IExceptionHandler>(new[] { "prefix.name.replace", "prefix.name.wrap" }) .WithContainerResolvedParameter <IExceptionHandlingInstrumentationProvider>("prefix") .VerifyConstructorParameters(); }
public void ThenProviderAllConstructorParameters() { registration .AssertConstructor() .WithValueConstructorParameter(typeof(ArgumentException)) .WithValueConstructorParameter(PostHandlingAction.ThrowNewException) .WithContainerResolvedEnumerableConstructorParameter <IExceptionHandler>(new string[0]) .WithContainerResolvedParameter <IExceptionHandlingInstrumentationProvider>("prefix") .VerifyConstructorParameters(); }
public void TheRegistrationForLogWriterHasExpectedConstructorParameters() { TypeRegistration registration = registrations.First(tr => tr.ServiceType == typeof(LogWriter)); registration .AssertConstructor() .WithContainerResolvedParameter <LogWriterStructureHolder>(null) .WithContainerResolvedParameter <ILoggingInstrumentationProvider>(null) .WithContainerResolvedParameter <ILoggingUpdateCoordinator>(null) .VerifyConstructorParameters(); }
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()); }
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(); }
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(); }
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(); }
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()); }
public void ThenShouldProviderProperConstructorParameters() { registration.AssertConstructor() .WithValueConstructorParameter <string>(formatter.Template); }
public void ThenNoConstructorParametersSupplied() { registration.AssertConstructor().VerifyConstructorParameters(); }