public static void DuringConstruction( RobotRunsAmokEvent fake) { "when configuring a method called by a constructor" .x(() => fake = A.Fake <RobotRunsAmokEvent>()); "it should use the configured behavior in the constructor" .x(() => fake.Timestamp.Should().Be(RobotRunsAmokEventFakeConfigurator.ConfiguredTimestamp)); }
public static void FakeConfiguratorPriority( RobotRunsAmokEvent fake) { "when creating a fake that has two matching configurators" .x(() => fake = A.Fake <RobotRunsAmokEvent>()); "then it should be configured by the one with higher priority" .x(() => fake.ID.Should().Be(-99)); }
public void DuringConstruction( RobotRunsAmokEvent fake) { "When a fake is created for a type that has an options builder defined" .x(() => fake = A.Fake <RobotRunsAmokEvent>()); "Then the builder will build options to be used during the fake's constructor" .x(() => fake.Timestamp.Should().Be(RobotRunsAmokEventFakeOptionsBuilder.ConfiguredTimestamp)); }
public static void DummyFactoryPriority( RobotRunsAmokEvent dummy) { "when two dummy factories apply to the same type" .x(() => dummy = A.Dummy <RobotRunsAmokEvent>()); "it should use the one with higher priority" .x(() => dummy.ID.Should().Be(-17)); }
public static void FakeConfiguratorPriority( RobotRunsAmokEvent fake) { "when two fake configurators apply to the same type" .x(() => fake = A.Fake <RobotRunsAmokEvent>()); "it should use the one with higher priority" .x(() => fake.ID.Should().Be(-99)); }
public void FakeOptionsBuilderPriority( RobotRunsAmokEvent fake) { "When a fake is created for a type that has two applicable fake options builders" .x(() => fake = A.Fake <RobotRunsAmokEvent>()); "Then the builder with the higher priority will build options for the fake" .x(() => fake.ID.Should().Be(-99)); }
public static void Wrapping( RobotRunsAmokEvent fake) { "When a fake that has a fake configurator is configured to wrap an object" .x(() => fake = A.Fake <RobotRunsAmokEvent>( options => options.Wrapping(new RobotRunsAmokEvent()))); "Then it should delegate to the wrapped object" .x(() => fake.Timestamp.Should().Be(DomainEvent.DefaultTimestamp)); }
public static void ConfigureFakeOverridesFakeConfigurator( RobotRunsAmokEvent fake) { "When configuring a fake to configure a method already configured by a fake configurator" .x(() => fake = A.Fake <RobotRunsAmokEvent>( options => options.ConfigureFake( f => A.CallTo(() => f.CalculateTimestamp()).Returns(new DateTime(2000, 1, 1, 0, 0, 0))))); "Then it should use the behavior configured in the creation options" .x(() => fake.Timestamp.Should().Be(new DateTime(2000, 1, 1, 0, 0, 0))); }
public static void ConfigureFakeOverridesFakeOptionsBuilder( RobotRunsAmokEvent fake) { "When configuring a fake to configure a method already configured by a fake options builder" .x(() => fake = A.Fake<RobotRunsAmokEvent>( options => options.ConfigureFake( f => A.CallTo(() => f.CalculateTimestamp()).Returns(new DateTime(2000, 1, 1, 0, 0, 0))))); "Then it should use the behavior configured in the creation options" .x(() => fake.Timestamp.Should().Be(new DateTime(2000, 1, 1, 0, 0, 0))); }
public static void DummyFactoryPriority( RobotRunsAmokEvent dummy) { "Given two dummy factories which apply to the same type" .x(() => { }); // see DomainEventDummyFactory and RobotRunsAmokEventDummyFactory "When I create a Dummy of the type" .x(() => dummy = A.Dummy <RobotRunsAmokEvent>()); "Then it should be created by the factory with the higher priority" .x(() => dummy.ID.Should().Be(-17)); }
public static void FakeOptionsBuilderPriority( RobotRunsAmokEvent fake) { "Given a type" .See <RobotRunsAmokEvent>(); "And the type has an applicable implicit option builder defined" .See <RobotRunsAmokEventFakeOptionsBuilder>(); "And the type has another applicable implicit option builder defined" .See <DomainEventFakeOptionsBuilder>(); "When I create a fake of the type" .x(() => fake = A.Fake <RobotRunsAmokEvent>()); "Then the configuration from the options builder with the higher priority is used" .x(() => fake.ID.Should().Be(-99)); }
public static void DuringConstruction( RobotRunsAmokEvent fake) { "Given a type with a parameterless constructor" .See <RobotRunsAmokEvent>(); "And the constructor calls a virtual method" .See(() => new RobotRunsAmokEvent()); "And the type has an implicit options builder defined" .See <RobotRunsAmokEventFakeOptionsBuilder>(); "And the options builder updates the options to configure the fake" .See("RobotRunsAmokEventFakeOptionsBuilder.BuildOptions"); // it's protected "When I create a fake of the type" .x(() => fake = A.Fake <RobotRunsAmokEvent>()); "Then the option builder's configuration is used during the constructor" .x(() => fake.Timestamp.Should().Be(RobotRunsAmokEventFakeOptionsBuilder.ConfiguredTimestamp)); }
public void WrappingViaImplicitOptionsBuilderOverridesConfigureFake( Action <IFakeOptions <RobotRunsAmokEvent> > optionsBuilder, RobotRunsAmokEvent fake) { "Given a type with a parameterless constructor" .See <RobotRunsAmokEvent>(); "And the constructor calls a virtual method" .See(() => new RobotRunsAmokEvent()); "And an implicit options builder that overrides the method" .See <RobotRunsAmokEventFakeOptionsBuilder>(); "And an explicit options builder that makes a fake wrap an object" .x(() => optionsBuilder = options => options.Wrapping(new RobotRunsAmokEvent())); "When I create a fake using the explicit options builder" .x(() => fake = this.CreateFake(optionsBuilder)); "Then the method delegates to the wrapped object" .x(() => fake.Timestamp.Should().Be(DomainEvent.DefaultTimestamp)); }
public void ConfigureFakeOverridesFakeOptionsBuilder( RobotRunsAmokEvent fake, Action <IFakeOptions <RobotRunsAmokEvent> > optionsBuilder) { "Given a type with a parameterless constructor" .See <RobotRunsAmokEvent>(); "And the constructor calls a virtual method" .See(() => new RobotRunsAmokEvent()); "And an implicit options builder that overrides the method" .See <RobotRunsAmokEventFakeOptionsBuilder>(); "And an explicit options builder that overrides the method" .x(() => optionsBuilder = options => options.ConfigureFake( f => A.CallTo(() => f.CalculateTimestamp()).Returns(new DateTime(2000, 1, 1, 0, 0, 0)))); "When I create a fake using the explicit options builder" .x(() => fake = this.CreateFake(optionsBuilder)); "Then it uses the explicitly configured behavior" .x(() => fake.Timestamp.Should().Be(new DateTime(2000, 1, 1, 0, 0, 0))); }
public static void Wrapping( RobotRunsAmokEvent fake) { "When a fake that has a fake configurator is configured to wrap an object" .x(() => fake = A.Fake<RobotRunsAmokEvent>( options => options.Wrapping(new RobotRunsAmokEvent()))); "Then it should delegate to the wrapped object" .x(() => fake.Timestamp.Should().Be(DomainEvent.DefaultTimestamp)); }
public void ConfigureFakeOverridesFakeConfigurator( RobotRunsAmokEvent fake) { "when ConfigureFake is used to configure a method also configured by a FakeConfigurator" .x(() => fake = A.Fake<RobotRunsAmokEvent>( options => options.ConfigureFake( f => A.CallTo(() => f.CalculateTimestamp()).Returns(new DateTime(2000, 1, 1, 0, 0, 0))))); "it should use the configured behavior from the ConfigureFake" .x(() => fake.Timestamp.Should().Be(new DateTime(2000, 1, 1, 0, 0, 0))); }
public void Wrapping( RobotRunsAmokEvent fake) { "when Wrapping is used to configure a fake that has a FakeConfigurator" .x(() => fake = A.Fake<RobotRunsAmokEvent>( options => options.Wrapping(new RobotRunsAmokEvent()))); "it should delegate to the wrapped object" .x(() => fake.Timestamp.Should().Be(DomainEvent.DefaultTimestamp)); }