コード例 #1
0
        public void Constructor_FromEnumerable()
        {
            var lazy = new LazyCollection <int>(_Int32TestData);

            lazy.Should().NotBeNull();
            lazy.Count.Should().Be(5);
            lazy.IsReadOnly.Should().BeFalse();
        }
コード例 #2
0
        public void Constructor_ThreadSafetyMode()
        {
            // ReSharper disable once CollectionNeverUpdated.Local
            var lazy = new LazyCollection <int>(LazyThreadSafetyMode.ExecutionAndPublication);

            lazy.Should().NotBeNull();
            lazy.Count.Should().Be(0);
            lazy.IsReadOnly.Should().BeFalse();
        }
コード例 #3
0
        public void Constructor_FromFactory()
        {
            // ReSharper disable once CollectionNeverUpdated.Local
            var lazy = new LazyCollection <int>(() => _Int32TestData.ToList());

            lazy.Should().NotBeNull();
            lazy.Count.Should().Be(5);
            lazy.IsReadOnly.Should().BeFalse();
        }
コード例 #4
0
        public void Constructor()
        {
            // ReSharper disable once CollectionNeverUpdated.Local
            var lazy = new LazyCollection <int>();

            lazy.Should().NotBeNull();
            lazy.Count.Should().Be(0);
            lazy.IsReadOnly.Should().BeFalse();
        }
コード例 #5
0
        public void Contains()
        {
            // Arrange
            var lazy = new LazyCollection <int>(_Int32TestData);

            lazy.Should().NotBeNull();

            // Assert
            lazy.Contains(0).Should().BeTrue();
            lazy.Contains(101).Should().BeFalse();
        }
コード例 #6
0
        public void CopyTo()
        {
            // Arrange
            var buffer = new int[5];

            var lazy = new LazyCollection <int>(_Int32TestData);

            lazy.Should().NotBeNull();

            // Act
            lazy.CopyTo(buffer, 0);

            buffer.Should().BeEquivalentTo(_Int32TestData);
        }
コード例 #7
0
        public void Enumerate()
        {
            // Arrange
            var list = new List <object>(8);

            var lazy = new LazyCollection <int>(_Int32TestData);

            lazy.Should().NotBeNull();

            foreach (var i in (IEnumerable)lazy)
            {
                list.Add(i);
            }

            list.OfType <int>().Count().Should().Be(5);
            list.OfType <int>().Should().BeEquivalentTo(_Int32TestData);
        }
コード例 #8
0
        public void Add_Remove_Clear()
        {
            // Arrange
            var lazy = new LazyCollection <int>(_Int32TestData);

            lazy.Should().NotBeNull();
            lazy.Count.Should().Be(5);
            lazy.IsReadOnly.Should().BeFalse();

            lazy.Remove(Int32.MinValue);
            lazy.Count.Should().Be(4);

            lazy.Add(Int32.MinValue);
            lazy.Add(101);
            lazy.Count.Should().Be(6);

            lazy.Clear();
            lazy.Count.Should().Be(0);
        }