Exemplo n.º 1
0
 private IDisposable ShouldRemoveFullNameWhenDeleteInvoked()
 {
     return(_delete
            .WithLatestFrom(_selected, (obj, selected) => selected)
            .Where(selected => selected.HasValue)
            .WithLatestFrom(_allNames, (selected, allNames) => allNames.Except(new[] { selected.Value }).ToArray())
            .Subscribe(_allNames));
 }
Exemplo n.º 2
0
        private IDisposable ShouldDisplayMessageWhenBookInvoked()
        {
            var message = Observable.CombineLatest(_flightType, _outboundDate, _returnDate, MessageText);

            return(_book
                   .WithLatestFrom(message, (_, m) => m)
                   .Select(m => string.IsNullOrEmpty(m)
                    ? Observable.Return(string.Empty)
                    : Observable.Merge(Observable.Return(m), Observable.Return(string.Empty).Delay(TimeSpan.FromSeconds(5), _scheduler)))
                   .Switch()
                   .Subscribe(_message));
        }
Exemplo n.º 3
0
 private IDisposable ShouldUpdateFullNameWhenUpdatedInvoked()
 {
     return(_update
            .WithLatestFrom(_selected, (obj, selected) => selected)
            .WithLatestFrom(_fullName, (selected, fullName) => new { Selected = selected, FullName = fullName })
            .Where(tuple => tuple.Selected.HasValue && tuple.FullName.HasValue)
            .WithLatestFrom(_allNames, (tuple, allNames) => allNames
                            .TakeWhile(name => !name.Equals(tuple.Selected.Value))
                            .Concat(new[] { tuple.FullName.Value })
                            .Concat(allNames.SkipWhile(name => !name.Equals(tuple.Selected)).Skip(1))
                            .ToArray())
            .Subscribe(_allNames));
 }
Exemplo n.º 4
0
        private IDisposable ShouldAddFullNameWhenCreateInvoked()
        {
            var allNames = _create
                           .WithLatestFrom(_fullName, (obj, name) => name)
                           .Where(fullName => fullName.HasValue)
                           .WithLatestFrom(_allNames, (current, all) => all.Concat(new[] { current.Value }))
                           .Publish()
                           .RefCount();

            return(new CompositeDisposable(
                       allNames.Subscribe(_allNames),
                       allNames.Select(_ => (FullName?)null).Subscribe(_selected)
                       ));
        }