コード例 #1
0
        public static void FakeOptionsBuilderAppliesConfigureFake(
            RobotActivatedEvent fake)
        {
            "Given a type that has an implicit options builder defined"
            .See <RobotActivatedEvent>();

            "And the options builder updates the options to configure the fake"
            .See <DomainEventFakeOptionsBuilder>(_ => _.BuildOptions);

            "And the options builder updates the options to add an attribute"
            .See <DomainEventFakeOptionsBuilder>(_ => _.BuildOptions);

            "And the options builder updates the options to implement an interface specified by parameter"
            .See <DomainEventFakeOptionsBuilder>(_ => _.BuildOptions);

            "And the options builder updates the options to implement an interface specified by type parameter"
            .See <DomainEventFakeOptionsBuilder>(_ => _.BuildOptions);

            "When I create a fake of the type"
            .x(() => fake = A.Fake <RobotActivatedEvent>());

            "Then the fake is configured"
            .x(() => fake.ID.Should().BeGreaterThan(0));

            "And the fake has the attribute"
            .x(() => fake.GetType().GetTypeInfo().GetCustomAttributes(inherit: false).Select(a => a.GetType())
               .Should().Contain(typeof(ForTestAttribute)));

            "And the fake implements the interface specified by parameter"
            .x(() => fake.Should().BeAssignableTo <IDisposable>());

            "And the fake implements the interface specified by type parameter"
            .x(() => fake.Should().BeAssignableTo <IComparable>());
        }
コード例 #2
0
        public static void DummyFactoryUsage(
            RobotActivatedEvent dummy)
        {
            "When I create a Dummy of a type that has a dummy factory defined"
            .x(() => dummy = A.Dummy <RobotActivatedEvent>());

            "Then it should be created by the factory"
            .x(() => dummy.ID.Should().BeGreaterThan(0));
        }
コード例 #3
0
        public static void DummyFactoryUsage(
            RobotActivatedEvent dummy)
        {
            "when a dummy factory is defined for a set of types"
            .x(() => dummy = A.Dummy <RobotActivatedEvent>());

            "it should create a dummy from the factory"
            .x(() => dummy.ID.Should().BeGreaterThan(0));
        }
コード例 #4
0
        public static void DefinedFakeConfigurator()
        {
            RobotActivatedEvent fake = null;

            "when a fake configurator is defined for a set of types"
            .x(() => fake = A.Fake <RobotActivatedEvent>());

            "it should configure the fake"
            .x(() => fake.ID.Should().BeGreaterThan(0));
        }
コード例 #5
0
        public static void DefinedFakeConfigurator(
            RobotActivatedEvent fake)
        {
            "when creating a fake that has a matching configurator"
            .x(() => fake = A.Fake <RobotActivatedEvent>());

            "then it should be configured"
            .x(() => fake.ID.Should().BeGreaterThan(0));

            "and it should be configured before its constructor is run"
            .x(() => fake.Timestamp.Should().Be(DomainEventFakeConfigurator.ConfiguredTimestamp));
        }
コード例 #6
0
        public void DefinedFakeOptionsBuilder(
            RobotActivatedEvent fake)
        {
            "When a fake is created for a type that has an options builder defined"
            .x(() => fake = A.Fake <RobotActivatedEvent>());

            "Then the builder will apply the fake options builder"
            .x(() => fake.ID.Should().BeGreaterThan(0));

            "And it will be passed the fake type"
            .x(() => fake.Name.Should().Be(typeof(RobotActivatedEvent).Name));

            "And it will add its extra attributes"
            .x(() => fake.GetType().GetCustomAttributes(typeof(ForTestAttribute), true).Should().HaveCount(1));

            "And it will make the fake implement its extra interface specified by parameter"
            .x(() => fake.Should().BeAssignableTo <IDisposable>());

            "And it will make the fake implement its extra interface specified by type parameter"
            .x(() => fake.Should().BeAssignableTo <ICloneable>());
        }