Пример #1
0
            public void SubjectFiresOffNextSubscription()
            {
                var nextCount      = 0;
                var errorCount     = 0;
                var completedCount = 0;
                var featureUsageTrackingManager = new FuncFeatureUsageTrackingManager(featureName => new DefaultFeatureUsageTrackingSession(featureName));
                var subFeatureName = "FeatureTwo";

                using (var observable = new Subject <int>())
                    using (var subscription = observable.SubscribeWithFeatureUsageTracking(
                               _ => nextCount++,
                               _ => errorCount++,
                               () => completedCount++,
                               featureUsageTrackingManager,
                               subFeatureName))
                    {
                        Assert.Equal(0, nextCount);
                        Assert.Equal(0, errorCount);
                        Assert.Equal(0, completedCount);

                        observable.OnNext(1);

                        Assert.Equal(1, nextCount);
                        Assert.Equal(0, errorCount);
                        Assert.Equal(0, completedCount);
                    }
            }
Пример #2
0
            public async Task ReactiveCommandFiresOffNextSubscription()
            {
                var nextCount = 0;
                var featureUsageTrackingManager = new FuncFeatureUsageTrackingManager(featureName => new DefaultFeatureUsageTrackingSession(featureName));
                var subFeatureName = "FeatureTwo";

                using (var observable = ReactiveCommand.CreateFromTask <Unit, Unit>(unit => Task.FromResult(unit)))
                    using (var subscription = observable.SubscribeWithFeatureUsageTracking(
                               _ => nextCount++,
                               featureUsageTrackingManager,
                               subFeatureName))
                    {
                        Assert.Equal(0, nextCount);

                        _ = await observable.Execute(Unit.Default);

                        Assert.Equal(1, nextCount);
                    }
            }