Esempio n. 1
0
        protected override void SetContextData()
        {
            itrtr32 = 1;
            repo    = new AppLoginHistoriesRepo(testCtx);

            var b = new Faker <AppLoginHistories>()
                    .RuleFor(r => r.UserId, f => f.Random.Uuid())
                    .RuleFor(r => r.LoginDate, f => DateTime.Now)
                    .RuleFor(r => r.ApplicationId, f => f.Random.Uuid());

            var bs = b.Generate(3).OrderBy(o => o.HistoryId).ToList();

            foreach (var item in bs)
            {
                item.HistoryId = itrtr32;

                if (!FakeCollection.Any(a => a.HistoryId == item.HistoryId))
                {
                    FakeCollection.Add(item);
                }

                if (!testCtx.AppLoginHistories.Any(a => a.HistoryId == item.HistoryId))
                {
                    testCtx.AppLoginHistories.Add(item);
                }

                itrtr32++;
            }

            int added = testCtx.SaveChanges();
        }