﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using FluentAssertions;

using LiveLinq.List;
using LiveLinq.Utility;
using Reactive.ViewModels;
using Xunit;

namespace LiveLinq.Tests.List
{
    public partial class ExtensionsTests
    {
        [Fact]
        public void ObservableCollection_Add()
        {
            var source = new ObservableCollection<string>();
            var snapshot = source.ToLiveLinq().ToObservableEnumerable().Snapshot();
            source.Add("A");
            snapshot.Value.Should().ContainSingle("A");
        }

        [Fact]
        public void ObservableCollection_Remove()
        {
            var source = new ObservableCollection<string>() { "A" };
            var snapshot = source.ToLiveLinq().ToObservableEnumerable().Snapshot();
            source.RemoveAt(0);
            snapshot.Value.Should().BeEmpty();
        }

        [Fact]
        public void ObservableCollection_Clear()
        {
            var source = new ObservableCollection<string>() { "A", "B", "C" };
            var snapshot = source.ToLiveLinq().ToObservableEnumerable().Snapshot();
            source.Clear();
            snapshot.Value.Should().BeEmpty();
        }

        [Fact]
        public void ObservableCollection_AddRemove()
        {
            var source = new ObservableCollection<string>();
            var snapshot = source.ToLiveLinq().ToObservableEnumerable().Snapshot();
            source.Add("A");
            source.RemoveAt(0);
            snapshot.Value.Should().BeEmpty();
        }
    }
}
