コード例 #1
0
        public static void Main(string[] args)
        {
            using (var context = new CrowdSparkContext())
            {
            }

            BuildWebHost(args).Run();
        }
コード例 #2
0
        public SparkRepositoryTests()
        {
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();

            var builder = new DbContextOptionsBuilder <CrowdSparkContext>()
                          .UseSqlite(connection);

            context = new CrowdSparkContext(builder.Options);
            context.Database.EnsureCreated();

            context.Database.BeginTransaction();
        }
コード例 #3
0
        private CrowdSparkContext setupContextForIntegrationTests()
        {
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();

            var builder = new DbContextOptionsBuilder <CrowdSparkContext>()
                          .UseSqlite(connection);

            context = new CrowdSparkContext(builder.Options);
            context.Database.EnsureCreated();
            context.Database.BeginTransaction();

            return(context);
        }
コード例 #4
0
        public async void CreateAsync(CreateProjectDTO project, int userId, ResponseLogic expected)
        {
            var existingCategry = new Category()
            {
                Id = 1, Name = "Cooking"
            };
            var creatingUser = new User()
            {
                Id = 1, Firstname = "IAlready", Surname = "Exist", Mail = "*****@*****.**", AzureUId = "existingAuzreUId"
            };
            var existingLocation = new Location()
            {
                Id = 1, City = "Sydney", Country = "Australia"
            };

            context            = setupContextForIntegrationTests();
            userRepository     = new UserRepository(context);
            skillRepository    = new SkillRepository(context);
            projectRepository  = new ProjectRepository(context);
            locationRepository = new LocationRepository(context);
            categoryRepository = new CategoryRepository(context);

            var locationLogic = new LocationLogic(locationRepository, userRepository, projectRepository);
            var categoryLogic = new CategoryLogic(categoryRepository, projectRepository);

            context.Users.Add(creatingUser);
            context.Locations.Add(existingLocation);
            context.Categories.Add(existingCategry);
            context.SaveChanges();

            //SanityCheck
            Assert.Equal(1, await context.Users.CountAsync());
            Assert.Equal(creatingUser, await context.Users.FirstAsync());
            Assert.Equal(1, await context.Locations.CountAsync());
            Assert.Equal(existingLocation, await context.Locations.FirstAsync());
            Assert.Equal(1, await context.Categories.CountAsync());
            Assert.Equal(existingCategry, await context.Categories.FirstAsync());

            using (var logic = new ProjectLogic(projectRepository, locationRepository, skillLogicMock.Object, sparkLogicMock.Object, locationLogic, categoryLogic))
            {
                var result = await logic.CreateAsync(project, userId);

                Assert.Equal(expected, result.outcome);
            }
        }
コード例 #5
0
        public ProjectRepositoryTests()
        {
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();

            var builder = new DbContextOptionsBuilder <CrowdSparkContext>()
                          .UseSqlite(connection);

            context = new CrowdSparkContext(builder.Options);
            context.Database.EnsureCreated();

            context.Database.BeginTransaction();

            creator = new User()
            {
                Id = 1, Firstname = "Test", Surname = "Surname", Mail = "*****@*****.**", AzureUId = "blahblahblah"
            };
            context.Users.Add(creator);
            context.SaveChanges();
        }