示例#1
0
        public async Task returns_the_current_element_when_awaited()
        {
            // Given
            var src = new Subject<int>();
            var behave = src.CacheLast();
            var s1 = behave.Subscribe(_ => {});
            src.OnNext(11);

            // When
            var current = await behave.Take(1);

            // Then
            current.Should().Be(11);
        }
示例#2
0
        public void returns_the_current_element_when_a_new_subscription_is_made()
        {
            // Given
            var src = new Subject<int>();
            var behave = src.CacheLast();
            var s1Elements = new List<int>();
            var s2Elements = new List<int>();

            // When
            var s1 = behave.Subscribe(s1Elements.Add);
            src.OnNext(1);
            var s2 = behave.Subscribe(s2Elements.Add);

            // Then
            s1Elements.Should().Equal(1);
            s2Elements.Should().Equal(1);
        }