public void Execute_returns_new_value_if_no_filter() { var sut = new CompositeStreamFilter <FakeModel>(); var newValue = fixture.Create <FakeModel>(); var lastValue = fixture.Create <FakeModel>(); FakeModel actual = sut.Execute(newValue, lastValue); actual.Should().BeSameAs(newValue); }
public void Execute_has_guard_clause_for_newValue() { var sut = new CompositeStreamFilter <FakeModel>(); var newValue = default(FakeModel); var lastValue = fixture.Create <FakeModel>(); Action action = () => sut.Execute(newValue, lastValue); action.ShouldThrow <ArgumentNullException>() .Where(x => x.ParamName == "newValue"); }
public void Execute_relays_arguments_to_first_filter() { var filter = Mock.Of <IStreamFilter <FakeModel> >(); var sut = new CompositeStreamFilter <FakeModel>(filter); var newValue = fixture.Create <FakeModel>(); var lastValue = fixture.Create <FakeModel>(); sut.Execute(newValue, lastValue); Mock.Get(filter).Verify( x => x.Execute(newValue, lastValue), Times.Once()); }
public void Execute_returns_new_value_if_no_filter() { // Arrange var sut = new CompositeStreamFilter <Model>(); var newValue = _fixture.Create <Model>(); var lastValue = _fixture.Create <Model>(); // Act Model actual = sut.Execute(newValue, lastValue); // Assert actual.Should().BeSameAs(newValue); }
public void constructor_sets_filters_correctly() { // Arrange var filters = new List <IStreamFilter <FakeModel> >( from _ in Enumerable.Range(0, 3) select Mock.Of <IStreamFilter <FakeModel> >()); // Act var sut = new CompositeStreamFilter <FakeModel>(filters); IEnumerable <IStreamFilter <FakeModel> > actual = sut.Filters; // Assert actual.ShouldAllBeEquivalentTo( filters, opts => opts.WithStrictOrdering()); }
public void Execute_relays_arguments_to_first_filter() { // Arrange var filter = Mock.Of <IStreamFilter <Model> >(); var sut = new CompositeStreamFilter <Model>(filter); var newValue = _fixture.Create <Model>(); var lastValue = _fixture.Create <Model>(); // Act sut.Execute(newValue, lastValue); // Assert Mock.Get(filter).Verify( x => x.Execute(newValue, lastValue), Once()); }
public void Execute_passes_filter_result_to_next_filter_as_newValue() { // Arrange var newValue = fixture.Create <FakeModel>(); var lastValue = fixture.Create <FakeModel>(); var filterResult = fixture.Create <FakeModel>(); var firstFilter = Mock.Of <IStreamFilter <FakeModel> >( x => x.Execute(newValue, lastValue) == filterResult); var sut = new CompositeStreamFilter <FakeModel>( firstFilter, Mock.Of <IStreamFilter <FakeModel> >()); // Act sut.Execute(newValue, lastValue); // Assert Mock.Get(sut.Filters.Last()).Verify( x => x.Execute(filterResult, lastValue), Times.Once()); }
public void Execute_does_not_execue_filter_if_previous_filter_returns_null() { // Arrange var newValue = _fixture.Create <Model>(); var lastValue = _fixture.Create <Model>(); Model nullModel = null; var firstFilter = Mock.Of <IStreamFilter <Model> >( x => x.Execute(newValue, lastValue) == nullModel); var sut = new CompositeStreamFilter <Model>( firstFilter, Mock.Of <IStreamFilter <Model> >()); // Act sut.Execute(newValue, lastValue); // Assert Mock.Get(sut.Filters.Last()).Verify( x => x.Execute(IsAny <Model>(), IsAny <Model>()), Never()); }
public void Execute_uses_filter_result_as_new_value_argument_of_next_filter() { // Arrange var newValue = _fixture.Create <Model>(); var lastValue = _fixture.Create <Model>(); var filterResult = _fixture.Create <Model>(); var firstFilter = Mock.Of <IStreamFilter <Model> >( x => x.Execute(newValue, lastValue) == filterResult); var sut = new CompositeStreamFilter <Model>( firstFilter, Mock.Of <IStreamFilter <Model> >()); // Act sut.Execute(newValue, lastValue); // Assert Mock.Get(sut.Filters.Last()).Verify( x => x.Execute(filterResult, lastValue), Once()); }
public void Execute_returns_result_of_last_filter() { // Arrange var newValue = fixture.Create <FakeModel>(); var lastValue = fixture.Create <FakeModel>(); var firstResult = fixture.Create <FakeModel>(); var firstFilter = Mock.Of <IStreamFilter <FakeModel> >( x => x.Execute(newValue, lastValue) == firstResult); var secondResult = fixture.Create <FakeModel>(); var secondFilter = Mock.Of <IStreamFilter <FakeModel> >( x => x.Execute(firstResult, lastValue) == secondResult); var sut = new CompositeStreamFilter <FakeModel>( firstFilter, secondFilter); // Act FakeModel actual = sut.Execute(newValue, lastValue); // Assert actual.Should().BeSameAs(secondResult); }
public void sut_implements_IStreamFilter() { var sut = new CompositeStreamFilter <FakeModel>(); sut.Should().BeAssignableTo <IStreamFilter <FakeModel> >(); }