public static void MultipleWithAdditionalAttributesConfigurations(
            IInterfaceThatWeWillAddAttributesTo3 fake)
        {
            "When a fake is built with two sets of additional attributes"
            .x(() =>
            {
                var constructor1             = typeof(ScenarioAttribute).GetConstructor(new Type[0]);
                var attribute1               = new CustomAttributeBuilder(constructor1, new object[0]);
                var customAttributeBuilders1 = new List <CustomAttributeBuilder> {
                    attribute1
                };

                var constructor2             = typeof(ExampleAttribute).GetConstructor(new[] { typeof(object[]) });
                var attribute2               = new CustomAttributeBuilder(constructor2, new[] { new object[] { 1, null } });
                var constructor3             = typeof(DebuggerStepThroughAttribute).GetConstructor(new Type[0]);
                var attribute3               = new CustomAttributeBuilder(constructor3, new object[0]);
                var customAttributeBuilders2 = new List <CustomAttributeBuilder> {
                    attribute2, attribute3
                };

                fake = A.Fake <IInterfaceThatWeWillAddAttributesTo3>(options => options
                                                                     .WithAdditionalAttributes(customAttributeBuilders1)
                                                                     .WithAdditionalAttributes(customAttributeBuilders2));
            });

            "Then it should have all of the attributes"
            .x(() => fake.GetType().GetCustomAttributes(false)
               .Select(a => a.GetType()).Should()
               .Contain(typeof(ScenarioAttribute)).And
               .Contain(typeof(ExampleAttribute)).And
               .Contain(typeof(DebuggerStepThroughAttribute)));
        }
Exemplo n.º 2
0
        public void MultipleWithAttributesConfigurations(
            IInterfaceThatWeWillAddAttributesTo3 fake,
            Action <IFakeOptions <IInterfaceThatWeWillAddAttributesTo3> > optionsBuilder)
        {
            "Given an explicit options builder that adds multiple attributes to a fake"
            .x(() =>
            {
                optionsBuilder = options => options
                                 .WithAttributes(() => new ScenarioAttribute())
                                 .WithAttributes(() => new ExampleAttribute(), () => new DebuggerStepThroughAttribute());
            });

            "When I create a fake using the options builder"
            .x(() => fake = this.CreateFake(optionsBuilder));

            "Then it has all of the attributes"
            .x(() => fake.GetType().GetCustomAttributes(inherit: false)
               .Select(a => a.GetType()).Should()
               .Contain(typeof(ScenarioAttribute)).And
               .Contain(typeof(ExampleAttribute)).And
               .Contain(typeof(DebuggerStepThroughAttribute)));
        }
Exemplo n.º 3
0
        public void MultipleWithAdditionalAttributesConfigurations(
            IInterfaceThatWeWillAddAttributesTo3 fake,
            Action <IFakeOptions <IInterfaceThatWeWillAddAttributesTo3> > optionsBuilder)
        {
            "Given an explicit options builder that adds multiple attributes to a fake"
            .x(() =>
            {
                var constructor1             = typeof(ScenarioAttribute).GetConstructor(new Type[0]);
                var attribute1               = new CustomAttributeBuilder(constructor1, new object[0]);
                var customAttributeBuilders1 = new List <CustomAttributeBuilder> {
                    attribute1
                };

                var constructor2             = typeof(ExampleAttribute).GetConstructor(new[] { typeof(object[]) });
                var attribute2               = new CustomAttributeBuilder(constructor2, new object[] { new object[] { 1, null } });
                var constructor3             = typeof(DebuggerStepThroughAttribute).GetConstructor(new Type[0]);
                var attribute3               = new CustomAttributeBuilder(constructor3, new object[0]);
                var customAttributeBuilders2 = new List <CustomAttributeBuilder> {
                    attribute2, attribute3
                };

                optionsBuilder = options => options
                                 .WithAdditionalAttributes(customAttributeBuilders1)
                                 .WithAdditionalAttributes(customAttributeBuilders2);
            });

            "When I create a fake using the options builder"
            .x(() => fake = this.CreateFake(optionsBuilder));

            "Then it has all of the attributes"
            .x(() => fake.GetType().GetCustomAttributes(inherit: false)
               .Select(a => a.GetType()).Should()
               .Contain(typeof(ScenarioAttribute)).And
               .Contain(typeof(ExampleAttribute)).And
               .Contain(typeof(DebuggerStepThroughAttribute)));
        }
Exemplo n.º 4
0
        public static void MultipleWithAdditionalAttributesConfigurations(
            IInterfaceThatWeWillAddAttributesTo3 fake)
        {
            "When a fake is built with two sets of additional attributes"
                .x(() =>
                    {
                        var constructor1 = typeof(ScenarioAttribute).GetConstructor(new Type[0]);
                        var attribute1 = new CustomAttributeBuilder(constructor1, new object[0]);
                        var customAttributeBuilders1 = new List<CustomAttributeBuilder> { attribute1 };

                        var constructor2 = typeof(ExampleAttribute).GetConstructor(new[] { typeof(object[]) });
                        var attribute2 = new CustomAttributeBuilder(constructor2, new[] { new object[] { 1, null } });
                        var constructor3 = typeof(DebuggerStepThroughAttribute).GetConstructor(new Type[0]);
                        var attribute3 = new CustomAttributeBuilder(constructor3, new object[0]);
                        var customAttributeBuilders2 = new List<CustomAttributeBuilder> { attribute2, attribute3 };

                        fake = A.Fake<IInterfaceThatWeWillAddAttributesTo3>(options => options
                            .WithAdditionalAttributes(customAttributeBuilders1)
                            .WithAdditionalAttributes(customAttributeBuilders2));
                    });

            "Then it should have all of the attributes"
                .x(() => fake.GetType().GetCustomAttributes(false)
                             .Select(a => a.GetType()).Should()
                             .Contain(typeof(ScenarioAttribute)).And
                             .Contain(typeof(ExampleAttribute)).And
                             .Contain(typeof(DebuggerStepThroughAttribute)));
        }