// C'tor
 public ConventionConfiguration()
 {
     this.Lifestyle = Lifestyle.Transient;
     this.AssemblyFilter = DefaultAssemblyFilter;
     this.ImplementationFilter = DefaultImplementationFilter;
     this.DecoratorFilter = DefaultDecoratorFilter;
 }
Beispiel #2
0
 public void Generic_Properties_throws_on_invalid_type()
 {
     var convention = new Convention();
     Assert.Equal(
         Strings.ModelBuilder_PropertyFilterTypeMustBePrimitive(typeof(object)),
         Assert.Throws<InvalidOperationException>(() => convention.Properties<object>()).Message);
 }
Beispiel #3
0
        protected LifecycleTests()
        {
            FailingMembers = null;

            Convention = new Convention();
            Convention.Classes.Where(testClass => testClass == typeof(SampleTestClass));
            Convention.Methods.Where(method => method.Name == "Pass" || method.Name == "Fail");
        }
Beispiel #4
0
        public void Generic_Entities_returns_a_new_object()
        {
            var convention = new Convention();
            var entities = convention.Types<object>();

            Assert.NotNull(entities);
            Assert.NotSame(entities, convention.Types<object>());
        }
 public SingleAuthTokenRetriever(IHoldProfilingInformation profilingInfo, HttpJsonRequestFactory factory, Convention convention, NameValueCollection operationHeaders, OperationMetadata operationMetadata)
 {
     this.profilingInfo = profilingInfo;
     this.factory = factory;
     this.convention = convention;
     this.operationHeaders = operationHeaders;
     this.operationMetadata = operationMetadata;
 }
Beispiel #6
0
        public void Generic_Properties_returns_a_new_object()
        {
            var convention = new Convention();
            var properties = convention.Properties<int>();

            Assert.NotNull(properties);
            Assert.NotSame(properties, convention.Properties<int>());
        }
Beispiel #7
0
 private static void StoreConvDays(ConventionWrapper convention, Convention convData, IDocumentSession session)
 {
     convData.DayIds = new List <string>();
     foreach (var day in convention.Days)
     {
         session.Store(day);
         convData.DayIds.Add(day.Id);
     }
 }
        public void WhenWarnWithinIsSupplied_ButDoomsdayIsNot_ThrowsException()
        {
            Action action = () => new[] { typeof(OffenderOne), typeof(OffenderTwo) }
            .WithKnownOffenders(1)
            .WithWarningWithin(TimeSpan.FromDays(3))
            .MustConformTo(Convention.NameMustEndWith("Esquire"));

            action.ShouldThrow <Exception>();
        }
Beispiel #9
0
 private void StoreGeneralInformation(ConventionWrapper wrapperData, Convention conventionData)
 {
     conventionData.Name            = wrapperData.Inner.Name;
     conventionData.CreateTimeStamp = wrapperData.Inner.CreateTimeStamp;
     conventionData.UpdateTimeStamp = wrapperData.Inner.UpdateTimeStamp;
     conventionData.TimeStrategy    = wrapperData.Inner.TimeStrategy;
     conventionData.Location        = wrapperData.Inner.Location;
     conventionData.TagLine         = wrapperData.Inner.TagLine;
 }
Beispiel #10
0
        public void String_type_should_return_provided_default_string()
        {
            var          person       = new { Name = "stringvalue" };
            PropertyInfo propertyInfo = person.GetType().GetProperty("Name");

            LambdaConvention convention = Convention.ByType <string>(p => "test");

            convention.DefaultValue(propertyInfo).should_be_equal_to("test");
        }
Beispiel #11
0
        public void String_type_should_apply()
        {
            var          person       = new { Name = "stringvalue" };
            PropertyInfo propertyInfo = person.GetType().GetProperty("Name");

            LambdaConvention convention = Convention.ByType <string>(p => ARandom.String(10));

            convention.AppliesTo(propertyInfo).should_be_true();
        }
Beispiel #12
0
        public void Incorrect_type_should_not_apply()
        {
            var          person       = new { BoolVal = false };
            PropertyInfo propertyInfo = person.GetType().GetProperty("BoolVal");

            LambdaConvention convention = Convention.ByType <string>(p => ARandom.String(10));

            convention.AppliesTo(propertyInfo).should_be_false();
        }
        public void api_controller_conventions()
        {
            var types      = Types.InAssemblyOf <TestController>();
            var convention = new ApiControllerNamingAndBaseClassConvention();

            var failures = Convention.GetFailures(convention, types);

            failures.ShouldMatchApproved();
        }
Beispiel #14
0
        AllPropertiesMustBeAssignedDuringConstructionConventionSpecification_FailsWhenNoConstructorsExists
            ()
        {
            var result = typeof(HasNoConstructors)
                         .MustConformTo(Convention.AllPropertiesMustBeAssignedDuringConstruction());

            result.IsSatisfied.Should().BeFalse();
            result.Failures.Should().HaveCount(1);
        }
Beispiel #15
0
        AllPropertiesMustBeAssignedDuringConstructionConventionSpecification_FailsWhenNoParameterizedConstructorExists
            ()
        {
            var result = typeof(DoesNotHaveAParametereizedConstructor)
                         .MustConformTo(Convention.AllPropertiesMustBeAssignedDuringConstruction());

            result.IsSatisfied.Should().BeFalse();
            result.Failures.Should().HaveCount(1);
        }
Beispiel #16
0
 public void UtilityAssemblyMustNotTakeADependancyOn()
 {
     typeof(UtilityAssembly).MustConformTo(Convention.MustNotTakeADependencyOn(typeof(AppAssembly), "TODO"));
     typeof(UtilityAssembly).MustConformTo(Convention.MustNotTakeADependencyOn(typeof(ServicesAssembly), "TODO"));
     typeof(UtilityAssembly).MustConformTo(Convention.MustNotTakeADependencyOn(typeof(ServicesConnectedAssembly), "TODO"));
     typeof(UtilityAssembly).MustConformTo(Convention.MustNotTakeADependencyOn(typeof(ServicesDisconnectedAssembly), "TODO"));
     typeof(UtilityAssembly).MustConformTo(Convention.MustNotTakeADependencyOn(typeof(FeaturesAssembly), "TODO"));
     typeof(UtilityAssembly).MustConformTo(Convention.MustNotTakeADependencyOn(typeof(TestsAssembly), "TODO"));
 }
        public void MustIncludeAllMatchingFilesInFolder_ProducesAppropriateErrorMessage()
        {
            var result      = _testAssembly.MustConformTo(Convention.MustIncludeAllMatchingFilesInFolder("*.js"));
            var failureText = result.Failures.Single();

            failureText.Should().Contain("TestSolution.TestProject");
            failureText.Should().Contain("unincludedJsFile.js");
            failureText.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).Length.Should().Be(2);
        }
Beispiel #18
0
 private static void StoreConvHalls(ConventionWrapper convention, Convention convData, IDocumentSession session)
 {
     convData.HallIds = new List <string>();
     foreach (var hall in convention.Halls)
     {
         session.Store(hall);
         convData.HallIds.Add(hall.Id);
     }
 }
Beispiel #19
0
 private void StoreConvTickets(ConventionWrapper convention, Convention convData, IDocumentSession session)
 {
     convData.TicketIds = new List <string>();
     foreach (var ticket in convention.Tickets)
     {
         session.Store(ticket);
         convData.TicketIds.Add(ticket.Id);
     }
 }
Beispiel #20
0
        AllPropertiesMustBeAssignedDuringConstructionConventionSpecification_PassesWhenNoConstructorsExistsAndIsReopinionated
            ()
        {
            var result = typeof(HasNoConstructors)
                         .MustConformTo(Convention.AllPropertiesMustBeAssignedDuringConstruction(true));

            result.IsSatisfied.Should().BeTrue();
            result.Failures.Should().HaveCount(0);
        }
Beispiel #21
0
        public void TogglesInCorrectNamespace()
        {
            var typesToCheck = Types.InAssemblyOf <SimpleFeatureToggle>();

            Convention.Is(new ClassTypeHasSpecificNamespace(
                              x => x.Name.EndsWith("Toggle"),
                              TogglesNamespace,
                              "Toggle Base Classes"), typesToCheck);
        }
        public void ConventionSpecifications_MustHaveNameThatEndsWithConventionSpecification()
        {
            var baseAssembly = typeof(Convention).Assembly;

            new[] { baseAssembly }
            .WhereTypes(x => ConventionTypes.Any(c => c.IsAssignableFrom(x)) && x.IsAbstract == false)
            .MustConformTo(Convention.NameMustEndWith("ConventionSpecification"))
            .WithFailureAssertion(Assert.Fail);
        }
Beispiel #23
0
        public void MustHaveFilesWithACertainExtensionBeResources_FailsWhenFilesAreNotResources_FileExtension()
        {
            var result = typeof(AssemblyConventionSpecificationTests).Assembly
                         .MustConformTo(Convention.MustHaveFilesBeResources("*.txt"));

            result.IsSatisfied.Should().BeFalse();
            result.Failures.Single().Should().Contain("non_embedded_text_file_first.txt");
            result.Failures.Single().Should().Contain("non_embedded_text_file_second.txt");
        }
        public void RequiresACorrespondingImplementationOfConventionSpecification_FailsIfImplementationDoesNotExist()
        {
            var result = typeof(SomeClassWithoutASomeGenericImpelemntation)
                         .MustConformTo(Convention.RequiresACorrespondingImplementationOf(typeof(SomeGeneric <,>),
                                                                                          new[] { typeof(SomeGenericImplementation) }));

            result.IsSatisfied.Should().BeFalse();
            result.Failures.Should().HaveCount(1);
        }
Beispiel #25
0
        public void MustHaveMatchingEmbeddedResourcesConventionSpecification_FailsWhenFileNotEmbeddedResource_ResourceNameMatcher()
        {
            var result = typeof(HasMatchingNonEmbeddedResource)
                         .MustConformTo(Convention.MustHaveMatchingEmbeddedResources(t =>
                                                                                     t.FullName + ".testdata"));

            result.IsSatisfied.Should().BeFalse();
            result.Failures.Count().Should().Be(1);
        }
Beispiel #26
0
        public ExecutionPlan(Convention convention)
        {
            var config = convention.Config;

            classBehaviors =
                BuildClassBehaviorChain(config,
                    BuildFixtureBehaviorChain(config,
                        BuildCaseBehaviorChain(config)));
        }
Beispiel #27
0
        public ExecutionPlan(Convention convention)
        {
            var config = convention.Config;

            classBehaviors =
                BuildClassBehaviorChain(config,
                                        BuildFixtureBehaviorChain(config,
                                                                  BuildCaseBehaviorChain(config)));
        }
Beispiel #28
0
        public override void Merge(IConventionContext context, Convention convention)
        {
            if (convention is SortConvention sortConvention &&
                Definition is not null &&
                sortConvention.Definition is not null)
            {
                ExtensionHelpers.MergeDictionary(
                    Definition.Bindings,
                    sortConvention.Definition.Bindings);

                ExtensionHelpers.MergeListDictionary(
                    Definition.Configurations,
                    sortConvention.Definition.Configurations);

                ExtensionHelpers.MergeListDictionary(
                    Definition.EnumConfigurations,
                    sortConvention.Definition.EnumConfigurations);

                for (var i = 0; i < Definition.Operations.Count; i++)
                {
                    sortConvention.Definition.Operations.Add(Definition.Operations[i]);
                }

                for (var i = 0; i < Definition.ProviderExtensions.Count; i++)
                {
                    sortConvention.Definition.ProviderExtensions.Add(
                        Definition.ProviderExtensions[i]);
                }

                for (var i = 0; i < Definition.ProviderExtensionsTypes.Count; i++)
                {
                    sortConvention.Definition.ProviderExtensionsTypes.Add(
                        Definition.ProviderExtensionsTypes[i]);
                }

                if (Definition.ArgumentName != SortConventionDefinition.DefaultArgumentName)
                {
                    sortConvention.Definition.ArgumentName = Definition.ArgumentName;
                }

                if (Definition.Provider is not null)
                {
                    sortConvention.Definition.Provider = Definition.Provider;
                }

                if (Definition.ProviderInstance is not null)
                {
                    sortConvention.Definition.ProviderInstance = Definition.ProviderInstance;
                }

                if (Definition.DefaultBinding is not null)
                {
                    sortConvention.Definition.DefaultBinding = Definition.DefaultBinding;
                }
            }
        }
Beispiel #29
0
        internal static void InitializeSecurity(Convention conventions, HttpJsonRequestFactory requestFactory, string serverUrl)
        {
            if (conventions.HandleUnauthorizedResponseAsync != null)
            {
                return; // already setup by the user
            }
            var basicAuthenticator   = new BasicAuthenticator(requestFactory.EnableBasicAuthenticationOverUnsecuredHttpEvenThoughPasswordsWouldBeSentOverTheWireInClearTextToBeStolenByHackers);
            var securedAuthenticator = new SecuredAuthenticator();

            requestFactory.ConfigureRequest += basicAuthenticator.ConfigureRequest;
            requestFactory.ConfigureRequest += securedAuthenticator.ConfigureRequest;

            conventions.HandleForbiddenResponseAsync = (forbiddenResponse, credentials) =>
            {
                if (credentials.ApiKey == null)
                {
                    AssertForbiddenCredentialSupportWindowsAuth(forbiddenResponse, credentials.Credentials);
                    return(null);
                }

                return(null);
            };

            conventions.HandleUnauthorizedResponseAsync = (unauthorizedResponse, credentials) =>
            {
                var oauthSource = unauthorizedResponse.Headers.GetFirstValue("OAuth-Source");

#if DEBUG && FIDDLER
                // Make sure to avoid a cross DNS security issue, when running with Fiddler
                if (string.IsNullOrEmpty(oauthSource) == false)
                {
                    oauthSource = oauthSource.Replace("localhost:", "localhost.fiddler:");
                }
#endif

                // Legacy support
                if (string.IsNullOrEmpty(oauthSource) == false &&
                    oauthSource.EndsWith("/OAuth/API-Key", StringComparison.CurrentCultureIgnoreCase) == false)
                {
                    return(basicAuthenticator.HandleOAuthResponseAsync(oauthSource, credentials.ApiKey));
                }

                if (credentials.ApiKey == null)
                {
                    AssertUnauthorizedCredentialSupportWindowsAuth(unauthorizedResponse, credentials.Credentials);
                    return(null);
                }

                if (string.IsNullOrEmpty(oauthSource))
                {
                    oauthSource = serverUrl + "/OAuth/API-Key";
                }

                return(securedAuthenticator.DoOAuthRequestAsync(serverUrl, oauthSource, credentials.ApiKey));
            };
        }
Beispiel #30
0
 public CreateHttpJsonRequestParams(IHoldProfilingInformation self, string url, string method, RavenJObject metadata, OperationCredentials credentials, Convention convention)
 {
     Owner       = self;
     Url         = url;
     Method      = method;
     Metadata    = metadata;
     Credentials = credentials;
     Convention  = convention;
     operationsHeadersCollection = new NameValueCollection();
 }
        public void WhenDoomsdayIsSupplied_FailsIfThereAreAnyOffendersAfterDoomsday()
        {
            var doomsday = new DateTime(2015, 11, 16);

            new[] { typeof(OffenderOne), typeof(OffenderTwo) }
            .ByDoomsday(doomsday)
            .MustConformTo(Convention.NameMustEndWith("One"));

            _failure.Should().Be("Doomsday is upon us! \r\nConventional.Tests.DoomsdayScenarios+OffenderTwo\r\n---------------------------------------------------\r\nType name does not end with One\r\n\r\n");
        }
        public void WhenDoomsdayIsSupplied_SucceedsIfThereAreNoOffendersAfterDoomsday()
        {
            var doomsday = new DateTime(2015, 11, 16);

            new[] { typeof(OffenderOne), typeof(OffenderTwo) }
            .ByDoomsday(doomsday)
            .MustConformTo(Convention.NameMustStartWith("Offender"));

            _failure.Should().BeNull();
        }
Beispiel #33
0
        public void MustHaveFilesWithACertainExtensionBeEmbeddedResources_Success_RegEx()
        {
            var matchSqlFiles = new Regex(@"\.SQL$", RegexOptions.IgnoreCase);

            typeof(AssemblyConventionSpecificationTests).Assembly
            .MustConformTo(Convention.MustHaveFilesBeEmbeddedResources(matchSqlFiles))
            .IsSatisfied
            .Should()
            .BeTrue();
        }
Beispiel #34
0
        public void WhenNumberOfOffendersExceedsKnownOffenders_AssertsFailure()
        {
            new [] { typeof(OffenderOne), typeof(OffenderTwo) }
            .WithKnownOffenders(1)
            .MustConformTo(Convention.NameMustEndWith("Esquire"));

            _failure.Should().Contain("Type name does not end with Esquire");
            _failure.Should().Contain("Conventional.Tests.DoomsdayScenarios+OffenderOne");
            _failure.Should().Contain("Conventional.Tests.DoomsdayScenarios+OffenderTwo");
        }
        public void should_use_provided_registrator()
        {
            var types = new[] { typeof(object) };
            var convention = new Convention();
            var container = new Container();

            container.Configure(x => x.Scan.Types(types).Using(convention));

            convention.ProcessedTypes.Should().BeEquivalentTo(types);
        }
		public CreateHttpJsonRequestParams(IHoldProfilingInformation self, string url, string method, RavenJObject metadata, OperationCredentials credentials, Convention convention)
		{
			Owner = self;
			Url = url;
			Method = method;
			Metadata = metadata;
			Credentials = credentials;
			Convention = convention;
			operationsHeadersCollection = new NameValueCollection();
		}
        public void ShouldPassWhenPassedAnAssemlyToWhichSourceHasNoReference()
        {
            var types = Types.InAssemblyOf <AssemblyIdType>();

            types = types.Without(typeof(ExceptionWithoutExceptionSuffix));
            var convention = new ExceptionsNamesMustEndWithException();

            //WHEN-THEN
            Convention.Is(convention, types);
        }
        public override Convention GetDefaultConvention()
        {
            this._defaultConvention = new Convention
            {
                TableName = type => type.Name.ToLower(),
                PrimaryKey = property => property.Name.ToLower()
            };

            return ( this._defaultConvention );
        }
        public void WhenUsingDoomsday_AndDefaultWarningAssertionIsNotSet_ThrowsException()
        {
            ConventionConfiguration.DefaultWarningAssertionCallback = null;

            Action action = () => new[] { typeof(OffenderOne), typeof(OffenderTwo) }
            .WithKnownOffenders(1)
            .MustConformTo(Convention.NameMustEndWith("Esquire"));

            action.ShouldThrow <Exception>();
        }
        public void RequestsMustHaveHandlers()
        {
            var handlers = typeof(ListAttendeesRequestHandler).Assembly
                           .GetAllTypesImplementingOpenGenericType(typeof(IRequestHandler <,>))
                           .ToArray();

            typeof(ListAttendeesRequest).Assembly
            .GetAllTypesImplementingOpenGenericType(typeof(IRequest <>))
            .MustConformTo(Convention.RequiresACorrespondingImplementationOf(typeof(IRequestHandler <,>), handlers));
        }
 public void configured_filter_should_be_used_in_conventional_registrations()
 {
     var types = new[] { typeof(object), typeof(int) };
     var convention = new Convention();
     new Container(x =>
                       {
                           x.Default.Filters.Add(t => !t.Name.Contains("n"));
                           x.Scan.Types(types).Using(convention);
                       });
     convention.Types.Should().BeEquivalentTo(new[] { typeof(object) });
 }
        public void should_filter_types_using_provided_lambda()
        {
            var convention = new Convention();
            var container = new Container();

            container.Configure(x => x.Scan
                                              .Types(new[] { typeof(object), typeof(int) })
                                              .Where(t => t.IsClass)
                                              .Using(convention));

            convention.ProcessedTypes.Should().BeEquivalentTo(new[] { typeof(object) });
        }
Beispiel #43
0
        internal static void InitializeSecurity(Convention conventions, HttpJsonRequestFactory requestFactory, string serverUrl)
        {
            if (conventions.HandleUnauthorizedResponseAsync != null)
                return; // already setup by the user

            var basicAuthenticator = new BasicAuthenticator(requestFactory.EnableBasicAuthenticationOverUnsecuredHttpEvenThoughPasswordsWouldBeSentOverTheWireInClearTextToBeStolenByHackers);
            var securedAuthenticator = new SecuredAuthenticator(autoRefreshToken: true);

            requestFactory.OnDispose += (sender, args) => securedAuthenticator.Dispose();
            requestFactory.ConfigureRequest += basicAuthenticator.ConfigureRequest;
            requestFactory.ConfigureRequest += securedAuthenticator.ConfigureRequest;

            conventions.HandleForbiddenResponseAsync = (forbiddenResponse, credentials) =>
            {
                if (credentials.ApiKey == null)
                {
                    AssertForbiddenCredentialSupportWindowsAuth(forbiddenResponse, credentials.Credentials);
                    return null;
                }

                return null;
            };

            conventions.HandleUnauthorizedResponseAsync = (unauthorizedResponse, credentials) =>
            {
                var oauthSource = unauthorizedResponse.Headers.GetFirstValue("OAuth-Source");

#if DEBUG && FIDDLER
                // Make sure to avoid a cross DNS security issue, when running with Fiddler
                if (string.IsNullOrEmpty(oauthSource) == false)
                    oauthSource = oauthSource.Replace("localhost:", "localhost.fiddler:");
#endif

                // Legacy support
                if (string.IsNullOrEmpty(oauthSource) == false &&
                    oauthSource.EndsWith("/OAuth/API-Key", StringComparison.CurrentCultureIgnoreCase) == false)
                {
                    return basicAuthenticator.HandleOAuthResponseAsync(oauthSource, credentials.ApiKey);
                }

                if (credentials.ApiKey == null)
                {
                    AssertUnauthorizedCredentialSupportWindowsAuth(unauthorizedResponse, credentials.Credentials);
                    return null;
                }

                if (string.IsNullOrEmpty(oauthSource))
                    oauthSource = serverUrl + "/OAuth/API-Key";

                return securedAuthenticator.DoOAuthRequestAsync(serverUrl, oauthSource, credentials.ApiKey);
            };

        }
        public void type_should_match_all_filters_to_get_processed()
        {
            var convention = new Convention();
            var container = new Container();

            container.Configure(x => x.Scan
                                              .Types(new[] { typeof(object), typeof(int), typeof(string) })
                                              .Where(t => t.IsClass)
                                              .Where(t => t.Name.Contains("n"))
                                              .Using(convention));

            convention.ProcessedTypes.Should().BeEquivalentTo(new[] { typeof(string) });
        }
Beispiel #45
0
        public ClassRunner(Listener listener, Convention convention)
        {
            var config = convention.Config;

            this.listener = listener;
            executionPlan = new ExecutionPlan(convention);
            methodDiscoverer = new MethodDiscoverer(convention);
            parameterDiscoverer = new ParameterDiscoverer(convention);
            assertionLibraryFilter = new AssertionLibraryFilter(convention);

            skipBehaviors = config.SkipBehaviors;
            orderCases = config.OrderCases;
        }
Beispiel #46
0
        public static void RegisterTypes(IUnityContainer container) {
            container.LoadConfiguration();

            //对全局异常处理程序自注入
            //container.RegisterType<ExceptionLogAttribute, ExceptionLogAttribute>();

            var conv = new Convention(container,
                typeof(BaseBiz).Assembly,
                typeof(TemplateServiceImpl).Assembly,
                Assembly.GetExecutingAssembly()
                );

            container.RegisterTypes(conv);
        }
Beispiel #47
0
        public static Convention Build()
        {
            var selfTestConvention = new Convention();

            selfTestConvention
                .Classes
                    .Where(testClass => testClass.IsNestedPrivate)
                    .NameEndsWith("TestClass");

            selfTestConvention
                .ClassExecution
                    .SortCases((x, y) => String.Compare(x.Name, y.Name, StringComparison.Ordinal));

            return selfTestConvention;
        }
        public AssertionLibraryFilter(Convention convention)
        {
            exceptionTypes = new List<Type>();
            stackTraceTypes = new List<Type>();

            foreach (var type in convention.Config.AssertionLibraryTypes)
            {
                bool isExceptionType = type.IsSubclassOf(typeof(Exception));

                if (isExceptionType)
                    exceptionTypes.Add(type);
                else
                    stackTraceTypes.Add(type);
            }
        }
Beispiel #49
0
        public void Generic_Properties_filter_on_type()
        {
            var decimalProperty = new MockPropertyInfo(typeof(decimal), "Property1");
            var nullableDecimalProperty = new MockPropertyInfo(typeof(decimal?), "Property2");
            var nonDecimalProperty = new MockPropertyInfo(typeof(string), "Property3");

            var config = new Convention().Properties<decimal>();
            Assert.NotNull(config);
            Assert.Equal(1, config.Predicates.Count());

            var predicate = config.Predicates.Single();
            Assert.True(predicate(decimalProperty));
            Assert.True(predicate(nullableDecimalProperty));
            Assert.False(predicate(nonDecimalProperty));
        }
Beispiel #50
0
 private static DayCounter conventions(Convention c)
 {
     switch (c)
     {
         case Convention.ISMA:
         case Convention.Bond:
             return ISMA_Impl.Singleton;
         case Convention.ISDA:
         case Convention.Historical:
         case Convention.Actual365:
             return ISDA_Impl.Singleton;
         case Convention.AFB:
         case Convention.Euro:
             return AFB_Impl.Singleton;
         default:
             throw new ArgumentException("Unknown day count convention: " + c);
     }
 }
        public void ShouldProvideSetsOfInputsGeneratedByInstantiatedParameterSources()
        {
            var customConvention = new Convention();

            customConvention
                .Parameters
                .Add(new FirstParameterSource())
                .Add(new SecondParameterSource());

            DiscoveredParameters(customConvention)
                .ShouldEqual(new[]
                {
                    new object[] { "ParameterizedMethod", 0, false },
                    new object[] { "ParameterizedMethod", 1, true },
                    new object[] { "ParameterizedMethod", 2, false },
                    new object[] { "ParameterizedMethod", 3, true }
                });
        }
        public static Convention Build()
        {
            var selfTestConvention = new Convention();

            selfTestConvention
                .Classes
                    .Where(testClass => testClass.IsNestedPrivate)
                    .NameEndsWith("TestClass");

            selfTestConvention
                .ClassExecution
                    .SortCases((x, y) => String.Compare(x.Name, y.Name, StringComparison.Ordinal));

            selfTestConvention
                .CaseExecution
                    .Skip(@case => @case.Method.Name.StartsWith("Skip"), GetSkipReason);

            return selfTestConvention;
        }
        // Private Helpers
        private static void RegisterByConvention(Container container, AssemblyFilter assemblyFilter, Convention implementationFilter, Convention decoratorFilter, Lifestyle lifestyle)
        {
            var types = GetAllLoadedTypes(assemblyFilter);

            var registrations = from service in types
                                let implementations = from implementation in types
                                                      where implementation.IsConcreteTypeThatImplements(service)
                                                         && implementationFilter(service, implementation)
                                                      select implementation
                                let decorators = from decorator in types
                                                 where decorator.IsConcreteTypeThatImplements(service)
                                                    && decoratorFilter(service, decorator)
                                                 select decorator
                                where service.IsInterface
                                   && !container.HasAlreadyRegistered(service)
                                select new
                                {
                                    Service = service,
                                    Implementations = implementations,
                                    Decorators = decorators
                                };

            foreach (var registration in registrations)
            {
                if (registration.Implementations.Count() == 1)
                {
                    container.Register(registration.Service, registration.Implementations.First(), lifestyle);
                }
                else if (registration.Implementations.Count() > 1)
                {
                    container.RegisterCollection(registration.Service, registration.Implementations);
                }

                foreach (var decorator in registration.Decorators)
                {
                    container.RegisterDecorator(registration.Service, decorator);
                }
            }
        }
        public void ShouldProvideSetsOfInputsGeneratedByFuncParameterSources()
        {
            var customConvention = new Convention();

            customConvention
                .Parameters
                .Add(m => new[]
                {
                    new object[] { m.Name, 0, false },
                })
                .Add(m => new[]
                {
                    new object[] { m.Name, 1, false },
                    new object[] { m.Name, 2, true }
                });

            DiscoveredParameters(customConvention)
                .ShouldEqual(new[]
                {
                    new object[] { "ParameterizedMethod", 0, false },
                    new object[] { "ParameterizedMethod", 1, false },
                    new object[] { "ParameterizedMethod", 2, true }
                });
        }
 public AssertionLibraryFilterTests()
 {
     convention = new Convention();
 }
Beispiel #56
0
 private AssemblyResult RunTypes(RunContext runContext, Convention convention, params Type[] types)
 {
     return Run(runContext, new[] { convention }, types);
 }
Beispiel #57
0
 public ParameterDiscoverer(Convention convention)
 {
     parameterSources = convention.Config.ParameterSources
         .Select(sourceType => sourceType())
         .ToArray();
 }
Beispiel #58
0
		public LinqPathProvider(Convention conventions)
		{
			this.conventions = conventions;
		}
 public CreateHttpJsonRequestParams(IHoldProfilingInformation self, string url, string method, OperationCredentials credentials, Convention convention, TimeSpan? timeout = null)
     : this(self, url, method, new RavenJObject(), credentials, convention, timeout)
 {}
Beispiel #60
0
 public ClassDiscoverer(Convention convention)
 {
     testClassConditions = convention.Config.TestClassConditions.ToArray();
 }