Created
November 11, 2009 15:58
-
-
Save cbilson/232064 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class when_a_benchmark_has_more_than_3_percent_assets_more_than_5_percent_change_in_weight | |
{ | |
Establish context = () => | |
{ | |
Input input; | |
given.input.for_account("XYZ123").called(out input) | |
.with_position().on(Clock.Today) | |
.with_an_asset_valued_at(10).cusip("1") | |
.with_an_asset_valued_at(90).cusip("2") | |
.called(out position) | |
.with_position().on(Clock.Yesterday) | |
.with_an_asset_valued_at(20).cusip("1") | |
.with_an_asset_valued_at(80).cusip("2") | |
.called(out previousPosition); | |
repo = MockRepository.GenerateStub<IHoldingsRepository>(); | |
repo.Stub(x => x.GetPriorPosition(input, Clock.Today)) | |
.Return(previousPosition); | |
validation = new BenchmarkPositionVolatilityValidation(repo); | |
}; | |
Because of = () => validation.Validate(position); | |
It flags_the_position = () => | |
position.Issues.ShouldContain( | |
x => x.Reason.Contains("Benchmark XYZ123 has > 3% positions with > 5% weight change")); | |
It flags_the_first_asset = () => | |
position.Issues[0].AffectedAssets | |
.Where(x => x.Cusip == "1").Count() | |
.ShouldEqual(1); | |
It flags_the_second_asset = () => | |
position.Issues[0].AffectedAssets | |
.Where(x => x.Cusip == "2").Count() | |
.ShouldEqual(1); | |
static Position position; | |
static Position previousPosition; | |
static IBenchmarkPositionVolatilityValidation validation; | |
static IHoldingsRepository repo; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment