Пример #1
0
        public async Task TestOverLapInTheMiddle()
        {
            DateTime effectiveDate = DateTime.Today;
            int      fundId        = 100;

            using var session = SetupFundEquity(DateTime.Today, fundId);
            var src = new FundEquityDto {
                EffectiveDate = effectiveDate,
                FundId        = fundId,
                Start         = new DateTime(2020, 1, 5),
                End           = new DateTime(2020, 1, 5),
            };
            var entity = new FundEquity(src, "test", session);

            session.DbContext.Add(entity);
            await session.SaveChangesAsync();

            var list = session.DbContext.Set <FundEquity>().ToList();

            Assert.Equal(14, list.Count);
            var item = list[0];

            Assert.Equal(new DateTime(2020, 1, 1), item.Start);
            Assert.Equal(new DateTime(2020, 1, 4), item.End);
            item = list[12];
            Assert.Equal(new DateTime(2020, 1, 6), item.Start);
            Assert.Equal(new DateTime(2020, 1, 15), item.End);
            Assert.Same(entity, item);
            item = list[13];
            Assert.Equal(new DateTime(2020, 1, 5), item.Start);
            Assert.Equal(new DateTime(2020, 1, 5), item.End);
        }
Пример #2
0
        public async Task TestNoOverLapAtTheBeginning()
        {
            DateTime effectiveDate = DateTime.Today;
            int      fundId        = 100;

            using var session = SetupFundEquity(DateTime.Today, fundId);
            var src = new FundEquityDto {
                EffectiveDate = effectiveDate,
                FundId        = fundId,
                End           = new DateTime(1999, 1, 1),
            };
            var entity = new FundEquity(src, "test", session);

            session.DbContext.Add(entity);
            await session.SaveChangesAsync();

            var list = session.DbContext.Set <FundEquity>().ToList();

            Assert.Equal(13, list.Count);
            Assert.Same(entity, list.Last());
        }
Пример #3
0
        public async Task TestOverLapAtTheEnd()
        {
            DateTime effectiveDate = DateTime.Today;
            int      fundId        = 100;

            using var session = SetupFundEquity(DateTime.Today, fundId);
            var src = new FundEquityDto {
                EffectiveDate = effectiveDate,
                FundId        = fundId,
                Start         = new DateTime(2020, 12, 10),
            };
            var entity = new FundEquity(src, "test", session);

            session.DbContext.Add(entity);
            await session.SaveChangesAsync();

            var list = session.DbContext.Set <FundEquity>().ToList();

            Assert.Equal(13, list.Count);
            Assert.Same(entity, list.Last());
            var item = list[11];

            Assert.Equal(new DateTime(2020, 12, 9), item.End);
        }