Exemple #1
0
        public DataBaseReadTest(DatabaseFixture fixture)
        {
            if (TestConstants.IsMyMachine)
            {
                fixture.DBPath   = string.Format(@"{0}\AppData\CodeGeneratorTest.mdf", Directory.GetCurrentDirectory());
                fixture.DBServer = @"(LocalDB)\ProjectsV13";

                Fixture = fixture;

                var config = new GeneratorConfig
                {
                    DataBase = new DataBaseConfig
                    {
                        ConnectionString = string.Format(@"Data Source={0};AttachDbFilename={1};Integrated Security=True;Connect Timeout=30;MultipleActiveResultSets=True", Fixture.DBServer, Fixture.DBPath),
                        SchemasExclude   = new List <string> {
                            "dbo"
                        }
                    },
                    CSharp = new CSharpConfig
                    {
                    }
                };

                var generator = new Generator(config);

                var dataBaseRead = Kernel.Resolve <IDataBaseRead>();
                DataBase = dataBaseRead.Read();
            }
        }
            public void BuildUp() => DatabaseFixture.ExecuteCommand(ConnectionType.PostgresTesting, @"

            create function rest__post_return_body(_body json) returns json as $$
            begin
                return _body;
            end $$ language plpgsql;

            create function rest__post_return_body_additional(_body json, _additional text) returns json as $$
            begin
                return _body::jsonb || format('{""additional"": ""%s""}', _additional)::jsonb;
            end $$ language plpgsql;


            create function rest__put_return_body(_body json) returns json as $$
            begin
                return _body;
            end $$ language plpgsql;

            create function rest__put_return_body_additional(_body json, _additional text) returns json as $$
            begin
                return _body::jsonb || format('{""additional"": ""%s""}', _additional)::jsonb;
            end $$ language plpgsql;

            create function rest__post_return_plain_text(_body text) returns text as $$
            begin
                return _body;
            end $$ language plpgsql;

            create function rest__put_return_plain_text(_body text) returns text as $$
            begin
                return _body;
            end $$ language plpgsql;

            ");
        public async Task OnTestStartingAsync()
        {
            await DatabaseFixture.OnTestStartingAsync();

            // Reset to the default calling user
            await User.Reset();
        }
Exemple #4
0
        // public TagServiceTest()
        // {
        //     IUnitOfWork _unitOfWork = new InMemoryUnitOfWork();
        //     _tagService = new TagService(_unitOfWork);
        // }
        public TagServiceTest(DatabaseFixture fixture, ITestOutputHelper output)
        {
            IUnitOfWork _unitOfWork = fixture.Db;

            _tagService = new TagService(_unitOfWork);
            this.output = output;
        }
Exemple #5
0
        public RecipesRepositoryTests(DatabaseFixture fixture) : base(fixture.Db)
        {
            var mockStepRepo       = new Mock <IResourcesRepository <Step, int?> >();
            var mockIngredientRepo = new Mock <IResourcesRepository <Ingredient, int?> >();

            Repo = new RecipesRepository(MockLogger.Object, mockStepRepo.Object, mockIngredientRepo.Object, fixture.ConnectionString);
        }
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSession();
            services.AddSingleton <ISessionStore, SingletonSessionStore>();

            services.AddRouting();

            services.AddSingleton <IUserInstanceStateStore, TestUserInstanceStateStore>();

            services
            .AddAuthentication("Test")
            .AddScheme <TestAuthenticationOptions, TestAuthenticationHandler>("Test", _ => { });

            services.AddCourseDirectory(HostingEnvironment, Configuration);

            services.AddMediatR(typeof(Startup));
            services.AddBehaviors(typeof(Startup).Assembly);

            services.AddSingleton <TestUserInfo>();
            services.AddSingleton <IDistributedCache, ClearableMemoryCache>();
            services.AddSingleton <IMptxStateProvider, InMemoryMptxStateProvider>();
            services.AddSingleton <IFeatureFlagProvider, ConfigurationFeatureFlagProvider>();
            services.Decorate <IFeatureFlagProvider, OverridableFeatureFlagProvider>();
            services.AddSingleton <Settings>();
            services.AddSingleton <ICookieSettingsProvider, TestCookieSettingsProvider>();
            services.AddTransient <ValidatorBaseTestsValidator>();

            DatabaseFixture.ConfigureServices(services);
        }
        public ControllerFixture(string environment)
        {
            var startupAssembly = typeof(TStartup).GetTypeInfo().Assembly;
            var builder         = new WebHostBuilder()
                                  .UseContentRoot(Directory.GetCurrentDirectory())
                                  .UseEnvironment(environment)
                                  .UseStartup(typeof(TStartup));

            _testServer        = new TestServer(builder);
            Client             = _testServer.CreateClient();
            Client.BaseAddress = new Uri("http://localhost");

            var conf = new ConfigurationBuilder()
                       .SetBasePath(Directory.GetCurrentDirectory())
                       .AddJsonFile($"appsettings.{environment}.json", optional: true, reloadOnChange: true)
                       .Build();

            ContextOptions = new DbContextOptionsBuilder <VoteMonitorContext>()
                             .UseSqlServer(conf.GetConnectionString(ConnectionStringName))
                             .Options;

            _databaseFixture = new DatabaseFixture <VoteMonitorContext>(new VoteMonitorContext(ContextOptions));

            SeedData();
        }
Exemple #8
0
        public PublishSession(DatabaseFixture fixture)
        {
            _fixture = fixture;

            _cinemaId  = _fixture.SeedData.Cinema.Id;
            _sessionId = _fixture.SeedData.Sessions.First().Id;
        }
Exemple #9
0
        public AccountRepositoryTestFixture(DatabaseFixture fixture)
        {
            Context    = fixture.Context;
            MapperMock = new Mock <IMapper>();
            OrderByExpressionCreatorMock = new Mock <IOrderByExpressionCreator <AccountEntity> >();
            Repository = new AccountRepository(Context, MapperMock.Object, OrderByExpressionCreatorMock.Object);
            var token = Token.Builder()
                        .SetIssued(DateTimeOffset.UtcNow)
                        .SetExpires(DateTimeOffset.UtcNow.AddDays(1))
                        .SetType(TokenTypeEnumeration.AccountConfirmation)
                        .SetValue("123456")
                        .Build();

            Account = Account.Builder()
                      .SetId(Guid.NewGuid())
                      .SetEmail("*****@*****.**")
                      .SetConfirmed(false)
                      .SetPasswordHash("PasswordHash")
                      .SetSecurityStamp(Guid.NewGuid())
                      .SetCreated(DateTimeOffset.UtcNow)
                      .SetRoles(new List <Guid> {
                Guid.NewGuid()
            })
                      .SetTokens(new List <Token> {
                token
            })
                      .Build();
            InsertAccountEntity(Account);
        }
Exemple #10
0
        public SagaFixture(DatabaseFixture database)
        {
            var builder = new SqlSagaStorageConfigurationBuilder();

            Database      = database;
            Configuration = builder.HasConnectionString(database.ConnectionString).CreateConfiguration();
        }
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         DatabaseFixture.Dispose();
     }
 }
        // Initalize Method used for all tests
        public GenreRepositoryTests(DatabaseFixture fixture)
        {
            this.fixture = fixture;

            _bookRepository  = new BookRepository(fixture.dbContext);
            _genreRepository = new GenreRepository(fixture.dbContext);
        }
Exemple #13
0
        public QueueFixture(DatabaseFixture database)
        {
            var builder = new SqlMessageQueueConfigurationBuilder();

            Database      = database;
            Configuration = builder.HasConnectionString(database.ConnectionString).CreateConfiguration();
        }
		public UserStoreTests(string collectionPrefix)
		{
			collectionPrefix = $"{typeof(UserStoreTests).Name}_{collectionPrefix}";

			_databaseFixture = new DatabaseFixture(collectionPrefix);
			_userCollection = _databaseFixture.GetCollection<IdentityUser>();
			_roleCollection = _databaseFixture.GetCollection<IdentityRole>();
			_databaseContext = new IdentityDatabaseContext { UserCollection = _userCollection, RoleCollection = _roleCollection };

			_errorDescriber = new IdentityErrorDescriber();
			_userStore = new UserStore<IdentityUser, IdentityRole>(_databaseContext, null, _errorDescriber);


			_claim1 = new Claim("ClaimType1", "some value");
			_claim2 = new Claim("ClaimType2", "some other value");
			_claim3 = new Claim("other type", "some other value");

			_claim1SameType = new Claim(_claim1.Type, _claim1.Value + " different");

			_identityClaim1 = new IdentityClaim(_claim1);
			_identityClaim2 = new IdentityClaim(_claim2);
			_identityClaim3 = new IdentityClaim(_claim3);

			_identityClaim1SameType = new IdentityClaim(_claim1SameType);
		}
 public CoreIntegrationTest(
     DatabaseFixture fixture,
     ITestOutputHelper output
     ) : base(output, fixture.Context)
 {
     fixture.CleanDatabaseTables();
 }
        public EntityTests(DatabaseFixture dbFixture)
        {
            _dbFixture = dbFixture;
            _dbFixture.InitializeData();

            _autoFixture = new Fixture();
            _autoFixture.Behaviors.Add(new OmitOnRecursionBehavior());
        }
Exemple #17
0
        public SnapshotFixture(DatabaseFixture database)
        {
            var builder = new SqlEventStoreConfigurationBuilder();

            Database      = database;
            Configuration = builder.HasConnectionString(database.ConnectionString).SupportsSnapshots().CreateConfiguration();
            Persistence   = EventStoreOnlyPersistence.New(Configuration, database);
        }
Exemple #18
0
 public LocationSyncJobTests(DatabaseFixture databaseFixture) : base(databaseFixture)
 {
     _mockEnv    = new Mock <IEnv>();
     _mockLogger = new Mock <ILogger <LocationSyncJob> >();
     _metrics    = new MetricService();
     _job        = new LocationSyncJob(_mockEnv.Object,
                                       DbContext, _mockLogger.Object, _metrics);
 }
        public ClinicControllerShould(DatabaseFixture dbFixture) : base(dbFixture)
        {
            var logger           = new Mock <ILogger <ClinicController> >();
            var clinicReposiyory = new ClinicRepository(Context);
            var clinicAppService = new ClinicAppService(clinicReposiyory);

            clinicController = new ClinicController(clinicAppService, logger.Object);
        }
 public StreetSegmentGroupRepositoryTests(DatabaseFixture fixture)
 {
     Repository        = new StreetSegmentGroupRepository(fixture.Context);
     SegmentRepository = new StreetSegmentRepository(fixture.Context);
     Segments          = new StreetSegments();
     SegmentRepository.Add(Segments[0]);
     SegmentRepository.Add(Segments[1]);
 }
Exemple #21
0
 public FlatForRentAnnouncementRepositoryTestFixture(DatabaseFixture fixture)
 {
     CosmosStore = fixture.FlatForRentAnnouncementCosmosStore;
     MapperMock  = new Mock <IMapper>();
     OrderByExpressionCreatorMock = new Mock <IOrderByExpressionCreator <FlatForRentAnnouncementEntity> >();
     Repository = new FlatForRentAnnouncementRepository(CosmosStore, MapperMock.Object, OrderByExpressionCreatorMock.Object);
     FlatForRentAnnouncement = InsertFlatForRentAnnouncementAsync().GetAwaiter().GetResult();
 }
Exemple #22
0
        public ClinicAppServiceShould(DatabaseFixture dbFixture) : base(dbFixture)
        {
            var configuration   = new Mock <IConfiguration>();
            var serviceProvider = new Mock <IServiceProvider>();

            clinicRepository = new ClinicRepository(base.Context);
            clinicAppService = new ClinicAppService(clinicRepository);
        }
            public void TearDown() => DatabaseFixture.ExecuteCommand(ConnectionType.PostgresTesting, @"

            drop function rest__get_values_from_params(int, text, timestamp, text);
            drop function rest__post_values_from_params(int, text, timestamp, text);
            drop function rest__put_values_from_params(int, text, timestamp, text);
            drop function rest__delete_values_from_params(int, text, timestamp, text);

            ");
Exemple #24
0
            public void BuildUp() => DatabaseFixture.ExecuteCommand(ConnectionType.PostgresTesting, @"

            create function rest__get_test_route_name() returns json as $$ begin return '{}'; end $$ language plpgsql;
            create function rest__post_test_route_name() returns json as $$ begin return '{}'; end $$ language plpgsql;
            create function rest__put_test_route_name() returns json as $$ begin return '{}'; end $$ language plpgsql;
            create function rest__delete_test_route_name() returns json as $$ begin return '{}'; end $$ language plpgsql;

            ");
Exemple #25
0
            public void TearDown() => DatabaseFixture.ExecuteCommand(ConnectionType.PostgresTesting, @"

            drop function rest__get_test_route_name();
            drop function rest__post_test_route_name();
            drop function rest__put_test_route_name();
            drop function rest__delete_test_route_name();

            ");
Exemple #26
0
        public GetAllAggregateNamesQueryTests(DatabaseFixture databaseFixture)
        {
            var connectionStringProvider = databaseFixture.ConnectionStringProvider;

            aggregateNameDatabaseHelper = new DatabaseHelper <Guid, AggregateNameAggregateState>("AggregateName", connectionStringProvider.TemplateConnectionString, x => x.Id);

            this.sut = new GetAllAggregateNamesQuery(connectionStringProvider);
        }
        // Initalize Method used for all tests
        public RecommendationTests(DatabaseFixture fixture)
        {
            this.fixture = fixture;

            _bookRepository           = new BookRepository(fixture.dbContext);
            _personRepository         = new PersonRepository(fixture.dbContext);
            _recommendationRepository = new RecommendationRepository(fixture.dbContext);
        }
            public void TearDown() => DatabaseFixture.ExecuteCommand(ConnectionType.PostgresTesting, @"

            drop function rest__get_values_no_grant();
            drop function rest__get_values_with_grant();
            drop function rest__get_values_with_grant_param(text);
            drop table test_values;

            ");
        // Initalize Method used for all tests
        public PersonRepositoryTests(DatabaseFixture fixture)
        {
            this.fixture = fixture;

            _personRepository = new PersonRepository(fixture.dbContext);
            _bookRepository   = new BookRepository(fixture.dbContext);
            _FriendRepository = new FriendRepository(fixture.dbContext);
        }
Exemple #30
0
 public async Task DbContextWithDependency_MissingCorrectConstructor_ExceptionThrown()
 {
     var databaseFixture = new DatabaseFixture <DbContextWithDependency>();
     await Assert.ThrowsAsync <InvalidOperationException>(async() =>
     {
         await databaseFixture.PerformDatabaseOperation(_ => { });
     });
 }
Exemple #31
0
 public UserRepositoryTestFixture(DatabaseFixture fixture)
 {
     Context = fixture.Context;
     OrderByExpressionCreatorMock = new Mock <IOrderByExpressionCreator <UserEntity> >();
     MapperMock = new Mock <IMapper>();
     Repository = new UserRepository(Context, OrderByExpressionCreatorMock.Object, MapperMock.Object);
     User       = InsertUser("*****@*****.**");
 }
 public BicyclePathGroupRepositoryTests(DatabaseFixture fixture)
 {
     Repository     = new BicyclePathGroupRepository(fixture.Context);
     PathRepository = new BicyclePathRepository(fixture.Context);
     Paths          = new BicyclePaths();
     PathRepository.Add(Paths[0]);
     PathRepository.Add(Paths[1]);
 }
		public RoleStoreTests(string collectionPrefix)
		{
			collectionPrefix = $"{typeof(RoleStoreTests).Name}_{collectionPrefix}";

			_databaseFixture = new DatabaseFixture(collectionPrefix);
			_userCollection = _databaseFixture.GetCollection<IdentityUser>();
			_roleCollection = _databaseFixture.GetCollection<IdentityRole>();
			_databaseContext = new IdentityDatabaseContext { UserCollection = _userCollection, RoleCollection = _roleCollection };

			_userStore = new UserStore<IdentityUser, IdentityRole>(_databaseContext);
			_roleStore = new RoleStore<IdentityUser, IdentityRole>(_databaseContext);
			_errorDescriber = new IdentityErrorDescriber();
		}
 public InsertTests(DatabaseFixture fixture)
 {
     database = fixture;
 }
 public ConnectionTests(DatabaseFixture data)
 {
     database = data;
 }