public void TestInitialize() { fixture = new Fixture().Customize(new AutoMoqCustomization()); filter = Mock.Of <IStreamFilter <FakeModel> >(); Mock.Get(filter) .Setup(x => x.Execute(It.IsAny <FakeModel>(), It.IsAny <FakeModel>())) .Returns <FakeModel, FakeModel>((newValue, lastValue) => newValue); sut = new StreamStore <string, FakeModel>(filter); }
public void Emit_relays_observable_with_future() { var model = new FakeModel(); var store = new StreamStore <Guid, FakeModel>(); var functor = Mock.Of <IFunctor>(); store.Connect(model.Id).Stream.Subscribe(functor.Action); IConnection <Guid, FakeModel> connection = store.Connect(model.Id); connection.Emit(Task.FromResult(model)); Mock.Get(functor).Verify(x => x.Action(model), Times.Once()); }
public Stream( StreamStore <TIdentifier, TModel> store, TIdentifier modelId) { _store = store; _modelId = modelId; _observer = new Subject <IObservable <TModel> >(); _observable = new BehaviorSubject <TModel>(default(TModel)); _observer.Switch() .Where(value => value != null) .Select(Filter) .Subscribe(_observable); }