Exemplo n.º 1
0
 public AParser(AContext aContext, FileStore fileStore, ILogger logger, LinkedList <string> messages)
 {
     _aContext  = aContext;
     _fileStore = fileStore;
     _logger    = logger;
     _messages  = messages;
 }
Exemplo n.º 2
0
        public void SetUp()
        {
            context    = new TestingContext();
            repository = new Repository <TestModel>(context);

            TearDownData();
        }
Exemplo n.º 3
0
        public void Execute_GivenContext_SetsActionStateToCommitted()
        {
            _test.Context = AContext.Build();

            _test.Execute(_fakeAction.Object);

            _fakeAction.VerifySet(x => x.ActionState = State.Committed);
        }
Exemplo n.º 4
0
        public void SetUp()
        {
            HttpContext.Current = new HttpMock().HttpContext;
            context             = new TestingContext();
            logger = new Logger(context);

            TearDownData();
        }
Exemplo n.º 5
0
        public void Context_WhenSet_RaisesPropertyChanged()
        {
            IGtdContext newContext = AContext.Build();
            var         test       = new Action();

            test.AssertThatChangeNotificationIsRaisedBy(x => x.Context).
            When(() => test.Context = newContext);
            Assert.Same(newContext, test.Context);
        }
Exemplo n.º 6
0
        public void Dispose_DiposesContext()
        {
            AContext   context    = Substitute.For <AContext>();
            UnitOfWork unitOfWork = new UnitOfWork(context);

            unitOfWork.Dispose();

            context.Received().Dispose();
        }
Exemplo n.º 7
0
        public TestingService(string dbName)
        {
            DbContextOptionsBuilder <InMemoryContext> builder = new DbContextOptionsBuilder <InMemoryContext>();
            DbContextOptions <InMemoryContext>        options = builder.UseInMemoryDatabase(databaseName: dbName).Options;

            Context = new InMemoryContext(options);
            Players = new PlayerRepository(Context);
            Rounds  = new RoundRepository(Context);
        }
Exemplo n.º 8
0
        public void SetUp()
        {
            context = new TestingContext();
            TearDownData();
            SetUpData();

            context     = new TestingContext();
            entry       = context.Entry(context.Set <Role>().SingleOrDefault());
            entry.State = EntityState.Modified;
        }
Exemplo n.º 9
0
        public void Execute_GivenContext_SetsContextOnAction()
        {
            IGtdContext context = AContext.Build();

            _test.Context = context;

            _test.Execute(_fakeAction.Object);

            _fakeAction.VerifySet(x => x.Context = context);
        }
Exemplo n.º 10
0
        public void Execute_GivenProject_AddsActionToProjectBlockingActions()
        {
            Mock <IAction> mockProject = AnAction.Mock();

            _test.Context = AContext.Build();
            _test.Project = mockProject.Object;

            _test.Execute(_fakeAction.Object);

            mockProject.Verify(x => x.AddBlockingAction(_fakeAction.Object));
        }
        public void GettingContextsCurrentItem_Initially_ReturnsContextFromCommand()
        {
            IGtdContext context = AContext.Build();

            _applyCommand.Context = context;

            DoLaterPresenter test = BuildDefaultDoLaterPresenter();

            test.Initialize();

            _fakeContextChooser.VerifySet(x => x.SelectedItem = context);
        }
Exemplo n.º 12
0
        protected virtual void Dispose(Boolean disposing)
        {
            if (disposed)
            {
                return;
            }

            context.Dispose();
            context = null;

            disposed = true;
        }
Exemplo n.º 13
0
        public void LoggableEntry_HasChangesIfAnyAttachedPropertyIsModified()
        {
            context.Dispose();
            context = new TestingContext();

            model.Name += "1";
            context.Set <Role>().Attach(model);
            entry       = context.Entry <Role>(model);
            entry.State = EntityState.Modified;

            Assert.IsTrue(new LoggableEntry(entry).HasChanges);
        }
        public void GettingApplyCommandContext_WhenContextHasBeenSelected_ReturnsTheContext()
        {
            DoLaterPresenter test = BuildDefaultDoLaterPresenter();

            test.Initialize();

            IGtdContext context = AContext.Build();

            ContextIsSelected(context);

            GC.KeepAlive(test);
            Assert.Same(context, _applyCommand.Context);
        }
Exemplo n.º 15
0
        public void SetUp()
        {
            context             = new TestingContext();
            dataContext         = new TestingContext();
            logger              = new EntityLogger(context);
            HttpContext.Current = new HttpMock().HttpContext;

            TearDownData();

            TestModel model = ObjectFactory.CreateTestModel();

            dataContext.Set <TestModel>().Add(model);
            entry = dataContext.Entry(model);
            dataContext.SaveChanges();
        }
Exemplo n.º 16
0
        public void Expression_IsContextSetsExpression()
        {
            DbSet <TestModel> databaseSet = Substitute.For <DbSet <TestModel>, IQueryable>();

            (databaseSet as IQueryable).Expression.Returns(Expression.Add(Expression.Constant(0), Expression.Constant(0)));

            AContext context = Substitute.For <AContext>();

            context.Set <TestModel>().Returns(databaseSet);
            repository = new Repository <TestModel>(context);

            Expression expected = (context.Set <TestModel>() as IQueryable).Expression;
            Expression actual   = (repository as IQueryable).Expression;

            Assert.AreSame(expected, actual);
        }
Exemplo n.º 17
0
        protected TestBase()
        {
            var LServices = new ServiceCollection();

            LServices.AddSingleton <DatabaseContextFactory>();
            LServices.AddScoped(AContext =>
            {
                var LFactory = AContext.GetService <DatabaseContextFactory>();
                return(LFactory?.CreateDatabaseContext());
            });

            var LServiceScope    = LServices.BuildServiceProvider(true).CreateScope();
            var LServiceProvider = LServiceScope.ServiceProvider;

            FDatabaseContextFactory = LServiceProvider.GetService <DatabaseContextFactory>();
        }
Exemplo n.º 18
0
        public void Update_UpdatesNotAttachedModel()
        {
            TestModel expected = ObjectFactory.CreateTestModel();

            context.Set <TestModel>().Add(expected);
            context.SaveChanges();

            expected.Text += "Test";
            context        = new TestingContext();
            repository     = new Repository <TestModel>(context);
            repository.Update(expected);
            context.SaveChanges();

            TestModel actual = context.Set <TestModel>().SingleOrDefault();

            TestHelper.PropertyWiseEqual(expected, actual);
        }
 public PlayerRepository(AContext context) : base(context)
 {
 }
Exemplo n.º 20
0
 public RoundRepository(AContext context) : base(context)
 {
 }
Exemplo n.º 21
0
 public Logger(AContext context)
 {
     this.context = context;
 }
Exemplo n.º 22
0
 public CreditTypesController(AContext context)
 {
     _context = context;
 }
 public AffiliatesController(AContext context)
 {
     _context = context;
 }
 public LocalService()
 {
     Context = new SqliteContext();
     Players = new PlayerRepository(Context);
     Rounds  = new RoundRepository(Context);
 }
Exemplo n.º 25
0
 public UsersController(AContext context)
 {
     _context = context;
 }
Exemplo n.º 26
0
 public UnitOfWork(AContext aContext)
 {
     _aContext      = aContext;
     UserRepository = new UserRepository(_aContext);
 }
Exemplo n.º 27
0
 public void SetUp()
 {
     context    = new TestingContext();
     logger     = Substitute.For <IEntityLogger>();
     unitOfWork = new UnitOfWork(context, logger);
 }
 public UserRepository(AContext aContext) : base(aContext)
 {
     _aContext = aContext;
 }
Exemplo n.º 29
0
 public EntityLogger(AContext context)
 {
     this.context = context;
 }
 public AService(AContext aContext)
 {
     _aContext = aContext;
 }