public void CreateContext()
        {
            _ctx = new TestingContext();
            _adp = new DbContextAdapter(_ctx);

            _productRepo = new Repository<Product>(_adp);
            _catRepo = new Repository<ProductCategory>(_adp);
        }
コード例 #2
0
 private void InitContext(TestingContext context)
 {
     context.AddPrincipalMock();
     context.AddInMemoryDb();
     context.AddMockLogService();
     context.AddGermanCultureServiceMock();
     context.AddBinaryServiceMock();
     context.AddQuestionService();
     context.DependencyMap[typeof(IBinaryService)] = context.GetService <BinaryService>();
 }
コード例 #3
0
 public void SetUp()
 {
     using (TestingContext context = new TestingContext())
     {
         TestModel model = new TestModel();
         context.Set <TestModel>().Add(model);
         context.Entry(model).State = EntityState.Modified;
         entry = context.Entry(model).Property(property => property.Text);
     }
 }
コード例 #4
0
        private void SetUpData()
        {
            state = ObjectFactory.CreateState();

            using (TestingContext context = new TestingContext())
            {
                context.Set <State>().Add(state);
                context.SaveChanges();
            }
        }
コード例 #5
0
        public AccountValidatorTests()
        {
            context = TestingContext.Create();
            hasher  = Substitute.For <IHasher>();
            hasher.VerifyPassword(Arg.Any <String>(), Arg.Any <String>()).Returns(true);
            validator = new AccountValidator(new UnitOfWork(TestingContext.Create(), TestingContext.Mapper), hasher);

            context.Drop().Add(account = ObjectsFactory.CreateAccount(0));
            context.SaveChanges();
        }
コード例 #6
0
        public RoleValidatorTests()
        {
            context   = new TestingContext();
            validator = new RoleValidator(new UnitOfWork(context));

            context.DropData();

            context.Add(role = ObjectFactory.CreateRole());
            context.SaveChanges();
        }
コード例 #7
0
        public AuthorizationTests()
        {
            context  = TestingContext.Create();
            services = Substitute.For <IServiceProvider>();

            services.GetService(typeof(IAuthorization)).Returns(Substitute.For <IAuthorization>());
            services.GetService(typeof(IUnitOfWork)).Returns(_ => new UnitOfWork(TestingContext.Create()));

            authorization = new Authorization(Assembly.GetExecutingAssembly(), services);
        }
コード例 #8
0
        public async Task GetSpecialTag(SpecialTag specialTag)
        {
            TestingContext testingContext = new TestingContext();

            SetupContext(testingContext);
            ITagService tagService = testingContext.GetService <TagService>();
            TagDto      tagDto     = await tagService.GetSpecialTagAsync(specialTag);

            Assert.NotNull(tagDto);
        }
コード例 #9
0
        private void SetUpData()
        {
            city = ObjectFactory.CreateCity();

            using (TestingContext context = new TestingContext())
            {
                context.Set <City>().Add(city);
                context.SaveChanges();
            }
        }
コード例 #10
0
        private void SetUpData()
        {
            account = ObjectFactory.CreateAccount();

            using (TestingContext testingContext = new TestingContext())
            {
                testingContext.Set <Account>().Add(account);
                testingContext.SaveChanges();
            }
        }
コード例 #11
0
        public UnitOfWorkTests()
        {
            context    = new TestingContext();
            model      = ObjectFactory.CreateTestModel();
            logger     = Substitute.For <IAuditLogger>();
            unitOfWork = new UnitOfWork(context, logger);

            context.Set <TestModel>().RemoveRange(context.Set <TestModel>());
            context.DropData();
        }
コード例 #12
0
        public void when_there_is_only_one_type()
        {
            // GrammarSystem is the only type in the Samples project

            var path = TestingContext.FindParallelDirectory("Storyteller.Samples");

            var project = Project.LoadForFolder(path);

            var controller = new RemoteController(project, new AppDomainSystemLauncher(project));
        }
コード例 #13
0
        public void GasPriceComparer_for_eip1559_transactions(int feeCapX, int gasPremiumX, int feeCapY, int gasPremiumY, int headBaseFee, long headBlockNumber, int expectedResult)
        {
            long           eip1559Transition = 5;
            TestingContext context           = new TestingContext(true, eip1559Transition)
                                               .WithHeadBaseFeeNumber((UInt256)headBaseFee)
                                               .WithHeadBlockNumber(headBlockNumber);
            IComparer <Transaction> comparer = context.DefaultComparer;

            Assert1559Transactions(comparer, feeCapX, gasPremiumX, feeCapY, gasPremiumY, expectedResult);
        }
コード例 #14
0
        public void GasPriceComparer_for_legacy_transactions_1559(int gasPriceX, int gasPriceY, int headBaseFee, long headBlockNumber, int expectedResult)
        {
            long           eip1559Transition = 5;
            TestingContext context           = new TestingContext(true, eip1559Transition)
                                               .WithHeadBaseFeeNumber((UInt256)headBaseFee)
                                               .WithHeadBlockNumber(headBlockNumber);
            IComparer <Transaction> comparer = context.DefaultComparer;

            AssertLegacyTransactions(comparer, gasPriceX, gasPriceY, expectedResult);
        }
コード例 #15
0
 private void TearDownData()
 {
     using (TestingContext context = new TestingContext())
     {
         context.Set <Privilege>().RemoveRange(context.Set <Privilege>());
         context.Set <Account>().RemoveRange(context.Set <Account>());
         context.Set <Role>().RemoveRange(context.Set <Role>());
         context.SaveChanges();
     }
 }
コード例 #16
0
        public void pretty_print_for_sample_data()
        {
            var path = TestingContext.FindParallelDirectory("Storyteller.Samples").AppendPath("Specs");


            var hierarchy = HierarchyLoader.ReadHierarchy(path);

            var json = JsonSerialization.ToJson(hierarchy).FormatJson();
            Debug.WriteLine(json);
        }
コード例 #17
0
        public void Dispose_Context()
        {
            TestingContext testingContext = Substitute.For <TestingContext>();

            testingContext.ChangeTracker.Returns(context.ChangeTracker);

            new AuditLogger(testingContext, 0).Dispose();

            testingContext.Received().Dispose();
        }
コード例 #18
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();
        }
コード例 #19
0
        public BackgroundSteps(BackdoorDriver backdoor,
                               ScenarioContext scenarioContext,
                               TestingContext testingContext)
        {
            this.Backdoor        = backdoor;
            this.ScenarioContext = scenarioContext;
            this.TestingContext  = testingContext;

            this.Backdoor.SetIntegrationModeOn().Wait();
        }
コード例 #20
0
        public void Save_Logs()
        {
            TestingContext context = Substitute.For <TestingContext>();

            logger = Substitute.ForPartsOf <AuditLogger>(context);

            logger.Save();

            context.Received().SaveChanges();
        }
コード例 #21
0
ファイル: LoggablePropertyTests.cs プロジェクト: mdy6/ToDoApp
        public LoggablePropertyTests()
        {
            Role model = new() { Id = 1 };

            using DbContext context = TestingContext.Create();

            context.Set <Role>().Attach(model);
            context.Entry(model).State = EntityState.Modified;
            textProperty = context.Entry(model).Property(prop => prop.Title);
            dateProperty = context.Entry(model).Property(prop => prop.CreationDate);
        }
コード例 #22
0
        static void Main(string[] args)
        {
            using (var context = new TestingContext()) {
                context.Configuration.AutoDetectChangesEnabled = false;
                context.Configuration.LazyLoadingEnabled       = false;

                const int count = 10;

                TestServersEFE(context, count);
            }
        }
        private Task <SystemRecycled> start(string projectName)
        {
            _project = new Project
            {
                ProjectPath = TestingContext.FindParallelDirectory(projectName)
            };

            _controller = new EngineController(_project, new ProcessRunnerSystemLauncher(_project));

            return(_controller.Start());
        }
コード例 #24
0
        public LoggableEntityTests()
        {
            using (context = new TestingContext())
            {
                context.Add(model = ObjectsFactory.CreateTestModel());
                context.SaveChanges();
            }

            context = new TestingContext(context);
            entry   = context.Entry <BaseModel>(model);
        }
コード例 #25
0
 private void InitTestingContext(TestingContext testingContext)
 {
     testingContext.AddPrincipalMock();
     testingContext.AddBinaryServiceMock();
     testingContext.AddInMemoryDb();
     testingContext.AddUserService();
     testingContext.AddBusinessSecurityService();
     testingContext.AddLogServiceMock();
     testingContext.AddGermanCultureServiceMock();
     testingContext.AddQuestionService();
 }
コード例 #26
0
ファイル: AccountServiceTests.cs プロジェクト: mdy6/ToDoApp
        public AccountServiceTests()
        {
            context     = TestingContext.Create();
            hasher      = Substitute.For <IHasher>();
            httpContext = new DefaultHttpContext();
            service     = new AccountService(new UnitOfWork(TestingContext.Create(), TestingContext.Mapper), hasher);

            hasher.HashPassword(Arg.Any <String>()).Returns(info => $"{info.Arg<String>()}Hashed");
            context.Drop().Add(account = ObjectsFactory.CreateAccount(0));
            context.SaveChanges();
        }
コード例 #27
0
        public LoggableEntityTests()
        {
            using (context = TestingContext.Create())
            {
                context.Drop().Add(model = ObjectsFactory.CreateRole(0));
                context.SaveChanges();
            }

            context = TestingContext.Create();
            entry = context.Entry<AModel>(model);
        }
コード例 #28
0
        public AuditLoggerTests()
        {
            context = new TestingContext();
            logger  = new AuditLogger(context, 1);
            TestModel      model       = ObjectFactory.CreateTestModel();
            TestingContext dataContext = new TestingContext();

            entry = dataContext.Entry <BaseModel>(dataContext.Set <TestModel>().Add(model));
            dataContext.Set <AuditLog>().RemoveRange(dataContext.Set <AuditLog>());
            dataContext.DropData();
        }
コード例 #29
0
        public void convert_the_top_suite_to_a_hierarchy_gets_the_specs()
        {
            var path = TestingContext.FindParallelDirectory("Storyteller.Samples").AppendPath("Specs");


            var hierarchy = HierarchyLoader.ReadHierarchy(path).ToHierarchy();

            hierarchy.Specifications["embeds"].ShouldNotBeNull();
            hierarchy.Specifications["sentence1"].ShouldNotBeNull();
            hierarchy.Specifications["sentence2"].ShouldNotBeNull();
        }
コード例 #30
0
        public void Resources_HasAllPermissionActionTitles()
        {
            using DbContext context           = TestingContext.Create();
            using Configuration configuration = new(context);

            configuration.Seed();

            foreach (String name in context.Set <Permission>().Select(permission => permission.Action).Distinct())
            {
                Assert.True(Resource.ForAction(name) != "", $"'{name}' action does not have a title.");
            }
        }
コード例 #31
0
        public AccountValidatorTests()
        {
            context = new TestingContext();
            hasher  = Substitute.For <IHasher>();
            hasher.VerifyPassword(Arg.Any <String>(), Arg.Any <String>()).Returns(true);

            context.DropData();
            SetUpData();

            validator = new AccountValidator(new UnitOfWork(context), hasher);
            validator.CurrentAccountId = account.Id;
        }
コード例 #32
0
ファイル: TaxGiven.cs プロジェクト: repinvv/TestingContext
 public TaxGiven(TestingContext context)
 {
     this.context = context;
 }
コード例 #33
0
 public LoggerMustProduceInfo(TestingContext context)
 {
     this.context = context;
 }
コード例 #34
0
 public WorkProjectWhen(TestingContext context)
 {
     this.context = context;
 }
コード例 #35
0
 public InsuranceGiven(TestingContext context)
 {
     this.context = context;
 }
コード例 #36
0
ファイル: CompanyWhen.cs プロジェクト: repinvv/TestingContext
 public CompanyWhen(TestingContext context)
 {
     this.context = context;
 }
コード例 #37
0
 public DepartmentGiven(TestingContext context)
 {
     this.context = context;
 }
コード例 #38
0
 public AssignmentThen(TestingContext context)
 {
     this.context = context;
 }
コード例 #39
0
 public ThenException(TestingContext context)
 {
     this.context = context;
 }
コード例 #40
0
 public CompanyPropertyGiven(TestingContext context)
 {
     this.context = context;
 }
コード例 #41
0
 public EmployeeWhen(TestingContext context)
 {
     this.context = context;
 }
コード例 #42
0
 public PerfTest(TestingContext context)
 {
     this.context = context;
 }