// C'tor
 public ConventionConfiguration()
 {
     this.Lifestyle = Lifestyle.Transient;
     this.AssemblyFilter = DefaultAssemblyFilter;
     this.ImplementationFilter = DefaultImplementationFilter;
     this.DecoratorFilter = DefaultDecoratorFilter;
 }
コード例 #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);
 }
コード例 #3
0
ファイル: LifecycleTests.cs プロジェクト: leijiancd/fixie
        protected LifecycleTests()
        {
            FailingMembers = null;

            Convention = new Convention();
            Convention.Classes.Where(testClass => testClass == typeof(SampleTestClass));
            Convention.Methods.Where(method => method.Name == "Pass" || method.Name == "Fail");
        }
コード例 #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>());
        }
コード例 #5
0
 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;
 }
コード例 #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>());
        }
コード例 #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);
     }
 }
コード例 #8
0
        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>();
        }
コード例 #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;
 }
コード例 #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");
        }
コード例 #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();
        }
コード例 #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();
        }
コード例 #13
0
        public void api_controller_conventions()
        {
            var types      = Types.InAssemblyOf <TestController>();
            var convention = new ApiControllerNamingAndBaseClassConvention();

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

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

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

            result.IsSatisfied.Should().BeFalse();
            result.Failures.Should().HaveCount(1);
        }
コード例 #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"));
 }
コード例 #17
0
        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);
        }
コード例 #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);
     }
 }
コード例 #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);
     }
 }
コード例 #20
0
        AllPropertiesMustBeAssignedDuringConstructionConventionSpecification_PassesWhenNoConstructorsExistsAndIsReopinionated
            ()
        {
            var result = typeof(HasNoConstructors)
                         .MustConformTo(Convention.AllPropertiesMustBeAssignedDuringConstruction(true));

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

            Convention.Is(new ClassTypeHasSpecificNamespace(
                              x => x.Name.EndsWith("Toggle"),
                              TogglesNamespace,
                              "Toggle Base Classes"), typesToCheck);
        }
コード例 #22
0
        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);
        }
コード例 #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");
        }
コード例 #24
0
        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);
        }
コード例 #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);
        }
コード例 #26
0
ファイル: ExecutionPlan.cs プロジェクト: jbogard/fixie
        public ExecutionPlan(Convention convention)
        {
            var config = convention.Config;

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

            classBehaviors =
                BuildClassBehaviorChain(config,
                                        BuildFixtureBehaviorChain(config,
                                                                  BuildCaseBehaviorChain(config)));
        }
コード例 #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;
                }
            }
        }
コード例 #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));
            };
        }
コード例 #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();
 }
コード例 #31
0
        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");
        }
コード例 #32
0
        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();
        }
コード例 #33
0
        public void MustHaveFilesWithACertainExtensionBeEmbeddedResources_Success_RegEx()
        {
            var matchSqlFiles = new Regex(@"\.SQL$", RegexOptions.IgnoreCase);

            typeof(AssemblyConventionSpecificationTests).Assembly
            .MustConformTo(Convention.MustHaveFilesBeEmbeddedResources(matchSqlFiles))
            .IsSatisfied
            .Should()
            .BeTrue();
        }
コード例 #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");
        }
コード例 #35
0
        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);
        }
コード例 #36
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 ShouldPassWhenPassedAnAssemlyToWhichSourceHasNoReference()
        {
            var types = Types.InAssemblyOf <AssemblyIdType>();

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

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

            return ( this._defaultConvention );
        }
コード例 #39
0
        public void WhenUsingDoomsday_AndDefaultWarningAssertionIsNotSet_ThrowsException()
        {
            ConventionConfiguration.DefaultWarningAssertionCallback = null;

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

            action.ShouldThrow <Exception>();
        }
コード例 #40
0
        public void RequestsMustHaveHandlers()
        {
            var handlers = typeof(ListAttendeesRequestHandler).Assembly
                           .GetAllTypesImplementingOpenGenericType(typeof(IRequestHandler <,>))
                           .ToArray();

            typeof(ListAttendeesRequest).Assembly
            .GetAllTypesImplementingOpenGenericType(typeof(IRequest <>))
            .MustConformTo(Convention.RequiresACorrespondingImplementationOf(typeof(IRequestHandler <,>), handlers));
        }
コード例 #41
0
 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) });
 }
コード例 #42
0
        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) });
        }
コード例 #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);
            };

        }
コード例 #44
0
        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) });
        }
コード例 #45
0
ファイル: ClassRunner.cs プロジェクト: jbogard/fixie
        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;
        }
コード例 #46
0
ファイル: UnityConfig.cs プロジェクト: gruan01/MessageCenter
        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);
        }
コード例 #47
0
ファイル: SelfTestConvention.cs プロジェクト: leijiancd/fixie
        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;
        }
コード例 #48
0
        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);
            }
        }
コード例 #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));
        }
コード例 #50
0
ファイル: ActualActual.cs プロジェクト: Yenyenx/qlnet
 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);
     }
 }
コード例 #51
0
        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 }
                });
        }
コード例 #52
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));

            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);
                }
            }
        }
コード例 #54
0
        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 }
                });
        }
コード例 #55
0
 public AssertionLibraryFilterTests()
 {
     convention = new Convention();
 }
コード例 #56
0
ファイル: Runner.cs プロジェクト: jrios/fixie
 private AssemblyResult RunTypes(RunContext runContext, Convention convention, params Type[] types)
 {
     return Run(runContext, new[] { convention }, types);
 }
コード例 #57
0
 public ParameterDiscoverer(Convention convention)
 {
     parameterSources = convention.Config.ParameterSources
         .Select(sourceType => sourceType())
         .ToArray();
 }
コード例 #58
0
ファイル: LinqPathProvider.cs プロジェクト: GorelH/ravendb
		public LinqPathProvider(Convention conventions)
		{
			this.conventions = conventions;
		}
コード例 #59
0
 public CreateHttpJsonRequestParams(IHoldProfilingInformation self, string url, string method, OperationCredentials credentials, Convention convention, TimeSpan? timeout = null)
     : this(self, url, method, new RavenJObject(), credentials, convention, timeout)
 {}
コード例 #60
0
ファイル: ClassDiscoverer.cs プロジェクト: leijiancd/fixie
 public ClassDiscoverer(Convention convention)
 {
     testClassConditions = convention.Config.TestClassConditions.ToArray();
 }