예제 #1
0
        public static void Init()
        {
            _dbContext = GenerateDbContext();

            var dateTimeOffset      = new DateTimeOffset(DateTime.UtcNow);
            var alertDateTimeOffset = new DateTimeOffset(DateTime.UtcNow.AddHours(5));

            _task = new DiaTask
            {
                Id              = Guid.NewGuid().ToString(),
                UserId          = null, // intentionally null since we can't set user claims.
                TaskDescription = "Here's my task description.",
                DueDateTime     = dateTimeOffset,
                AlertTimes      = new List <AlertTime> {
                    new AlertTime {
                        Id = Guid.NewGuid().ToString(), Time = alertDateTimeOffset
                    }
                },
                Comments = new List <Comment> {
                    new Comment {
                        Id = Guid.NewGuid().ToString(), Text = "Hi"
                    }
                }
            };

            _dbContext.Tasks.Add(_task);
            _dbContext.SaveChanges();
        }
예제 #2
0
        public void TaskService_GetTasksWithDetails_ThrowsNoTasksFoundException()
        {
            _dbContext = GenerateDbContext();
            var taskService = new TaskService(_dbContext);

            Assert.ThrowsAsync <NoTasksFoundException>(() => taskService.GetTasksWithDetailsAsync(null));
        }
예제 #3
0
        public void TaskService_GetAlerts_ThrowsNoDatabaseObjectFoundException()
        {
            _dbContext = GenerateDbContext();
            var taskService = new TaskService(_dbContext);

            Assert.ThrowsAsync <NoDatabaseObjectFoundException>(() => taskService.GetAlertsAsync(null, "abcde"));
        }
예제 #4
0
        public void Init()
        {
            var options = new DbContextOptionsBuilder <DoItDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            _dbContext = new DoItDbContext(options);
        }
예제 #5
0
        public async Task TaskService_GetAlerts_ThrowsNoAlertsFoundException()
        {
            _dbContext = GenerateDbContext();
            var newTask = new DiaTask {
                Id = "abcde"
            };

            _dbContext.Tasks.Add(newTask);
            await _dbContext.SaveChangesAsync();

            var taskService = new TaskService(_dbContext);

            Assert.ThrowsAsync <NoAlertsFoundException>(() => taskService.GetAlertsAsync(null, newTask.Id));
        }
예제 #6
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, DoItDbContext doItDbContext)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            doItDbContext.Database.EnsureCreated(); //Migrate()
            app.UseResponseCaching();
            app.UseAuthentication();
            app.UseMvc();
        }
예제 #7
0
        public SliceFixture()
        {
            _config = new ConfigurationBuilder()
                      .SetBasePath(AppDomain.CurrentDomain.BaseDirectory)
                      .AddJsonFile("appsettings.json", optional: true)
                      .AddEnvironmentVariables()
                      .Build();

            var services = new ServiceCollection();

            services.AddSingleton(_config);

            services
            //.AddLogging()
            .AddApplication()
            .AddInfrastructure(_config.GetConnectionString("DefaultConnection"));

            _serviceProvider = services.BuildServiceProvider();

            _scope   = CreateScope();
            _context = _scope.ServiceProvider.GetService <DoItDbContext>();
        }
예제 #8
0
 public EfRepository(DoItDbContext context)
 {
     _context = context;
 }
예제 #9
0
 public TaskService(DoItDbContext doItDbContext)
 {
     _doItDbContext = doItDbContext;
 }