public void Can_track_composite_keys()
        {
            string key1     = RandomText;
            string key2     = RandomText;
            string userName = RandomText;
            string descr    = RandomText;


            ModelWithCompositeKey entity = ObjectFactory <ModelWithCompositeKey> .Create();

            entity.Description = descr;
            entity.Key1        = key1;
            entity.Key2        = key2;

            db.ModelsWithCompositeKey.Add(entity);
            db.SaveChanges(userName);

            string expectedKey = string.Format("[{0},{1}]", key1, key2);

            entity.AssertAuditForAddition(db, expectedKey, userName,
                                          new KeyValuePair <string, string>("Description", descr),
                                          new KeyValuePair <string, string>("Key1", key1),
                                          new KeyValuePair <string, string>("Key2", key2)
                                          );
        }
Exemple #2
0
        public void Can_track_composite_keys()
        {
            string key1     = RandomText;
            string key2     = RandomText;
            string userName = RandomText;
            string descr    = RandomText;


            ModelWithCompositeKey entity = ObjectFactory.Create <ModelWithCompositeKey>();

            entity.Description = descr;
            entity.Key1        = key1;
            entity.Key2        = key2;

            Db.ModelsWithCompositeKey.Add(entity);
            Db.SaveChanges(userName);

            string expectedKey = string.Format("[{0},{1}]", key1, key2);

            entity.AssertAuditForAddition(Db, expectedKey, userName,
                                          x => x.Description,
                                          x => x.Key1,
                                          x => x.Key2
                                          );
        }
        public void Can_track_composite_keys()
        {
            var options = new DbContextOptionsBuilder <TestTrackerContext>()
                          .UseSqlServer(TestConnectionString)
                          .Options;

            string key1     = rdg.Get <string>();
            string key2     = rdg.Get <string>();
            string userName = rdg.Get <string>();
            string descr    = rdg.Get <string>();

            ModelWithCompositeKey entity = new ModelWithCompositeKey();

            entity.Description = descr;
            entity.Key1        = key1;
            entity.Key2        = key2;

            using (TestTrackerContext ttc = new TestTrackerContext(options))
            {
                ttc.ModelWithCompositeKeys.Add(entity);
                ttc.SaveChanges(userName);

                string expectedKey = $"[{key1},{key2}]";

                entity.AssertAuditForAddition(ttc, expectedKey, userName,
                                              x => x.Description,
                                              x => x.Key1,
                                              x => x.Key2);
            }
        }
        public void Can_track_composite_keys()
        {
            string key1     = RandomText;
            string key2     = RandomText;
            string userName = RandomText;
            string descr    = RandomText;


            ModelWithCompositeKey entity = ObjectFactory <ModelWithCompositeKey> .Create();

            entity.Description = descr;
            entity.Key1        = key1;
            entity.Key2        = key2;

            db.ModelsWithCompositeKey.Add(entity);
            db.SaveChanges(userName);

            string expectedKey = $"[{key1},{key2}]";

            entity.AssertAuditForAddition(db, expectedKey, userName,
                                          x => x.Description,
                                          x => x.Key1,
                                          x => x.Key2);
        }