public void EnumerateRangeOfEmptyList()
        {
            var list = new TransactionListTestClass();

            var result = list.InDateRange(new DateRange(new Date(2000, 01, 01), new Date(2003, 01, 01))).Select(x => x.Date).ToList();

            result.Should().BeEmpty();
        }
        public void ClearNoEntries()
        {
            var list = new TransactionListTestClass();

            list.Clear();

            list.Should().BeEmpty();
        }
        public void IndexOfEmptyList()
        {
            var list = new TransactionListTestClass();

            var result = list.IndexOf(new Date(2000, 01, 01), TransationListPosition.First);

            result.Should().Be(~0);
        }
        public void AddToEmptyList()
        {
            var list = new TransactionListTestClass();

            list.Add(Guid.NewGuid(), new Date(2000, 01, 01));

            list.Count.Should().Be(1);
        }
        public void RemoveAtEmptyList()
        {
            var list = new TransactionListTestClass();

            Action a = () => list.RemoveAt(1);

            a.Should().Throw <ArgumentOutOfRangeException>();
        }
        public void EnumerateEmptyList()
        {
            var list = new TransactionListTestClass();

            var result = list.ToList();

            result.Should().BeEmpty();
        }
        public void EnumerateFromDateOfEmptyList()
        {
            var list = new TransactionListTestClass();

            var result = list.FromDate(new Date(2000, 01, 01)).Select(x => x.Date).ToArray();

            result.Should().BeEmpty();
        }
        public void Latest()
        {
            var list = new TransactionListTestClass();

            list.Add(Guid.NewGuid(), new Date(2000, 01, 01));
            list.Add(Guid.NewGuid(), new Date(2001, 01, 01));
            list.Add(Guid.NewGuid(), new Date(2002, 01, 01));

            list.Latest.Should().Be(new Date(2002, 01, 01));
        }
        public void Clear()
        {
            var list = new TransactionListTestClass();

            list.Add(Guid.NewGuid(), new Date(2000, 01, 01));
            list.Add(Guid.NewGuid(), new Date(2001, 01, 01));
            list.Add(Guid.NewGuid(), new Date(2002, 01, 01));

            list.Clear();

            list.Should().BeEmpty();
        }
        public void EnumerateList()
        {
            var list = new TransactionListTestClass();

            list.Add(Guid.NewGuid(), new Date(2000, 01, 01));
            list.Add(Guid.NewGuid(), new Date(2001, 01, 01));
            list.Add(Guid.NewGuid(), new Date(2002, 01, 01));

            var result = list.Select(x => x.Date).ToArray();

            result.Should().Equal(new Date[] { new Date(2000, 01, 01), new Date(2001, 01, 01), new Date(2002, 01, 01) });
        }
        public void AddWithSameIdAsExistingEntry()
        {
            var list = new TransactionListTestClass();

            var id = Guid.NewGuid();

            list.Add(id, new Date(2000, 01, 01));

            Action a = () => list.Add(id, new Date(2001, 01, 01));

            a.Should().Throw <ArgumentException>();
        }
        public void IndexOfBetweenTwoDates()
        {
            var list = new TransactionListTestClass();

            list.Add(Guid.NewGuid(), new Date(2000, 01, 01));
            list.Add(Guid.NewGuid(), new Date(2001, 01, 01));
            list.Add(Guid.NewGuid(), new Date(2001, 01, 01));
            list.Add(Guid.NewGuid(), new Date(2002, 01, 01));
            list.Add(Guid.NewGuid(), new Date(2003, 01, 01));

            var result = list.IndexOf(new Date(2001, 06, 01), TransationListPosition.First);

            result.Should().Be(~3);
        }
        public void AddInMiddleOnTheSameDayAsAnExitingEntry()
        {
            var list = new TransactionListTestClass();

            list.Add(Guid.NewGuid(), new Date(2000, 01, 01));
            list.Add(Guid.NewGuid(), new Date(2001, 01, 01));
            list.Add(Guid.NewGuid(), new Date(2002, 01, 01));

            var id = Guid.NewGuid();

            list.Add(id, new Date(2001, 01, 01));

            list[2].Id.Should().Be(id);
        }
        public void AddInMiddle()
        {
            var list = new TransactionListTestClass();

            list.Add(Guid.NewGuid(), new Date(2000, 01, 01));
            list.Add(Guid.NewGuid(), new Date(2001, 01, 01));
            list.Add(Guid.NewGuid(), new Date(2002, 01, 01));

            var id = Guid.NewGuid();

            list.Add(id, new Date(2001, 06, 01));

            list[2].Id.Should().Be(id);
        }
        public void AddBeforeFirstEntry()
        {
            var list = new TransactionListTestClass();

            list.Add(Guid.NewGuid(), new Date(2000, 01, 01));
            list.Add(Guid.NewGuid(), new Date(2001, 01, 01));
            list.Add(Guid.NewGuid(), new Date(2002, 01, 01));

            var id = Guid.NewGuid();

            list.Add(id, new Date(1999, 01, 01));

            list[0].Id.Should().Be(id);
        }
        public void AddAfterLastEntry()
        {
            var list = new TransactionListTestClass();

            list.Add(Guid.NewGuid(), new Date(2000, 01, 01));
            list.Add(Guid.NewGuid(), new Date(2001, 01, 01));
            list.Add(Guid.NewGuid(), new Date(2002, 01, 01));

            var id = Guid.NewGuid();

            list.Add(id, new Date(2003, 01, 01));

            list[3].Id.Should().Be(id);
        }
        public void IndexOfBeforeFirstEntry()
        {
            var list = new TransactionListTestClass();

            list.Add(Guid.NewGuid(), new Date(2000, 01, 01));
            list.Add(Guid.NewGuid(), new Date(2001, 01, 01));
            list.Add(Guid.NewGuid(), new Date(2001, 01, 01));
            list.Add(Guid.NewGuid(), new Date(2002, 01, 01));
            list.Add(Guid.NewGuid(), new Date(2003, 01, 01));

            var result = list.IndexOf(new Date(1999, 01, 01), TransationListPosition.First);

            result.Should().Be(~0);
        }
        public void IndexOfMatchingMultipeDatesToGetLastEntry()
        {
            var list = new TransactionListTestClass();

            list.Add(Guid.NewGuid(), new Date(2000, 01, 01));
            list.Add(Guid.NewGuid(), new Date(2001, 01, 01));
            list.Add(Guid.NewGuid(), new Date(2001, 01, 01));
            list.Add(Guid.NewGuid(), new Date(2001, 01, 01));
            list.Add(Guid.NewGuid(), new Date(2002, 01, 01));
            list.Add(Guid.NewGuid(), new Date(2003, 01, 01));

            var result = list.IndexOf(new Date(2001, 01, 01), TransationListPosition.Last);

            result.Should().Be(3);
        }
        public void IndexOfAfterLastEntry()
        {
            var list = new TransactionListTestClass();

            list.Add(Guid.NewGuid(), new Date(2000, 01, 01));
            list.Add(Guid.NewGuid(), new Date(2001, 01, 01));
            list.Add(Guid.NewGuid(), new Date(2001, 01, 01));
            list.Add(Guid.NewGuid(), new Date(2001, 01, 01));
            list.Add(Guid.NewGuid(), new Date(2002, 01, 01));
            list.Add(Guid.NewGuid(), new Date(2003, 01, 01));

            var result = list.IndexOf(new Date(2004, 01, 01), TransationListPosition.Last);

            result.Should().Be(~6);
        }
        public void AccessById()
        {
            var list = new TransactionListTestClass();

            var id = Guid.NewGuid();

            list.Add(id, new Date(2000, 01, 01));
            var id2 = Guid.NewGuid();

            list.Add(id2, new Date(2001, 01, 01));

            var entry = list[id];

            entry.Date.Should().Be(new Date(2000, 01, 01));
        }
        public void SetByIdNoEntry()
        {
            var list = new TransactionListTestClass();

            var id = Guid.NewGuid();

            list.Add(id, new Date(2000, 01, 01));
            var id2 = Guid.NewGuid();

            list.Add(id2, new Date(2001, 01, 01));

            Action a = () => { list[Guid.NewGuid()] = new TransactionTestClass(Guid.NewGuid(), new Date(2002, 01, 01)); };

            a.Should().Throw <KeyNotFoundException>();
        }
        public void SetByIndexNoEntry()
        {
            var list = new TransactionListTestClass();

            var id = Guid.NewGuid();

            list.Add(id, new Date(2000, 01, 01));
            var id2 = Guid.NewGuid();

            list.Add(id2, new Date(2001, 01, 01));

            Action a = () => list[2] = new TransactionTestClass(id, new Date(2002, 01, 01));

            a.Should().Throw <ArgumentOutOfRangeException>();
        }
        public void EnumerateFromDateMatchingMultipleEntries()
        {
            var list = new TransactionListTestClass();

            list.Add(Guid.NewGuid(), new Date(2000, 01, 01));
            list.Add(Guid.NewGuid(), new Date(2001, 01, 01));
            list.Add(Guid.NewGuid(), new Date(2001, 01, 01));
            list.Add(Guid.NewGuid(), new Date(2001, 01, 01));
            list.Add(Guid.NewGuid(), new Date(2002, 01, 01));
            list.Add(Guid.NewGuid(), new Date(2003, 01, 01));

            var result = list.FromDate(new Date(2001, 01, 01)).Select(x => x.Date).ToArray();

            result.Should().Equal(new Date[] { new Date(2001, 01, 01), new Date(2001, 01, 01), new Date(2001, 01, 01), new Date(2002, 01, 01), new Date(2003, 01, 01) });
        }
        public void SetByIndex()
        {
            var list = new TransactionListTestClass();

            var id = Guid.NewGuid();

            list.Add(id, new Date(2000, 01, 01));
            var id2 = Guid.NewGuid();

            list.Add(id2, new Date(2001, 01, 01));

            var id3 = Guid.NewGuid();

            list[0] = new TransactionTestClass(id3, new Date(2002, 01, 01));

            var entry = list[0];

            entry.Date.Should().Be(new Date(2002, 01, 01));
        }
        public void LatestNoEnties()
        {
            var list = new TransactionListTestClass();

            list.Earliest.Should().Be(Date.MinValue);
        }
        public void CountNoEnties()
        {
            var list = new TransactionListTestClass();

            list.Count.Should().Be(0);
        }