public void GetFilter_HasOneFilter_ShouldReturnOneFilter() { var factory = new MessageFilterFactory(() => new[] { _firstFilter.Object }); var actual = factory.GetFilter(); Assert.AreEqual(_firstFilter.Object, actual); _firstFilter.Verify(x => x.SetNextFilter(It.IsAny <IMessageFilter>()), Times.Never); }
public void GetFilter_HasFilters_ShouldSetUpChainAndReturn() { var factory = new MessageFilterFactory( () => new[] { _firstFilter.Object, _secondFilter.Object, _thirdFilter.Object }); var actual = factory.GetFilter(); Assert.AreEqual(_firstFilter.Object, actual); _firstFilter.Verify(x => x.SetNextFilter(_secondFilter.Object), Times.Once); _secondFilter.Verify(x => x.SetNextFilter(_thirdFilter.Object), Times.Once); _thirdFilter.Verify(x => x.SetNextFilter(It.IsAny <IMessageFilter>()), Times.Never); }
public void GetFilter_NoFilters_ShouldThrowException() { var factory = new MessageFilterFactory(() => Array.Empty <IChainedMessageFilter>()); Assert.Throws <ArgumentException>(() => factory.GetFilter()); }