Example #1
0
 public UnitOfWorkTests()
 {
     context    = new TestingContext();
     logger     = Substitute.For <IAuditLogger>();
     model      = ObjectsFactory.CreateTestModel();
     unitOfWork = new UnitOfWork(context, logger);
 }
Example #2
0
        public QueryTests()
        {
            context = new TestingContext();
            select  = new Query <TestModel>(context.Set <TestModel>());

            context.RemoveRange(context.Set <TestModel>());
            context.Add(ObjectsFactory.CreateTestModel());
            context.SaveChanges();
        }
Example #3
0
        public AuditLoggerTests()
        {
            context = new TestingContext();
            logger  = new AuditLogger(context, 1);
            TestingContext dataContext = new TestingContext();
            TestModel      model       = ObjectsFactory.CreateTestModel();

            entry = dataContext.Entry <BaseModel>(dataContext.Add(model).Entity);
            dataContext.SaveChanges();
        }
        public LoggableEntityTests()
        {
            using (context = new TestingContext())
            {
                context.Add(model = ObjectsFactory.CreateTestModel());
                context.SaveChanges();
            }

            context = new TestingContext(context);
            entry   = context.Entry <BaseModel>(model);
        }
Example #5
0
        public void DeleteRange_Models()
        {
            IEnumerable <TestModel> models = new[] { ObjectsFactory.CreateTestModel(1), ObjectsFactory.CreateTestModel(2) };

            context.AddRange(models);
            context.SaveChanges();

            unitOfWork.DeleteRange(models);
            unitOfWork.Commit();

            Assert.Empty(context.Set <TestModel>());
        }
Example #6
0
        public void InsertRange_AddsModelsToDbSet()
        {
            IEnumerable <TestModel> models         = new[] { ObjectsFactory.CreateTestModel(1), ObjectsFactory.CreateTestModel(2) };
            TestingContext          testingContext = Substitute.For <TestingContext>();

            testingContext.When(sub => sub.AddRange(models)).DoNotCallBase();

            unitOfWork.Dispose();

            unitOfWork = new UnitOfWork(testingContext);
            unitOfWork.InsertRange(models);

            testingContext.Received().AddRange(models);
        }