Пример #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;
 }