示例#1
0
 public SendRegistrationConfirmationHandler(HealthTrackerContext context, ICache cache, INotificationService notificationService, IEncryptionService encryptionService)
 {
     _context             = context;
     _cache               = cache;
     _notificationService = notificationService;
     _encryptionService   = encryptionService;
 }
示例#2
0
        public async Task UpdateSymptomReturnsUpdated()
        {
            Connection = new SqliteConnection("DataSource=../../../testdb.db3");

            Opts = new DbContextOptionsBuilder <HealthTrackerContext>()
                   .UseSqlite(Connection).Options;

            using (var db = new HealthTrackerContext(Opts))
            {
                var service    = new SymptomDataService(db);
                var inputmodel = new SymptomInputModel
                {
                    SymptomName = "FirstSymptomUpdated",
                    UpdatedDate = DateTimeOffset.UtcNow,
                    Description = "I just Updated this",
                    Id          = "c89b00bd-289b-4b63-a4c5-46fe11e12f2c"
                };

                //Act
                var result = await service.UpdateSymptom(inputmodel);

                //Assert
                Assert.IsTrue(result.SymptomName.Contains("Updated"));
                Assert.IsInstanceOf <SymptomApiModel>(result);
            }
        }
 public RegisterHandler(HealthTrackerContext context, ICache cache, Lazy <IAuthConfiguration> lazyAuthConfiguration, IMediator mediator)
 {
     _context         = context;
     _cache           = cache;
     _mediator        = mediator;
     _jwtWriterFormat = new JwtWriterFormat(lazyAuthConfiguration, new OAuthOptions(lazyAuthConfiguration, mediator));
 }
        public static void Seed(HealthTrackerContext context)
        {
            context.Tenants.AddOrUpdate(x => x.Name, new Tenant()
            {
                Name = "Default"
            });

            context.SaveChanges();
        }
示例#5
0
        public static void Seed(HealthTrackerContext context)
        {
            var tenant = context.Tenants.Single(x => x.Name == "Default");

            context.Accounts.AddOrUpdate(x => x.Firstname, new Account()
            {
                Firstname = "Quinntyne",
                Lastname  = "Brown",
                TenantId  = tenant.Id
            });

            context.SaveChanges();
        }
示例#6
0
        public static void Seed(HealthTrackerContext context)
        {
            var systemRole = context.Roles.First(x => x.Name == Roles.SYSTEM);
            var tenant     = context.Tenants.Single(x => x.Name == "Default");
            var account    = context.Accounts.Single(x => x.Firstname == "Quinntyne");

            context.Profiles.AddOrUpdate(x => x.Name, new Profile()
            {
                Name      = "Quinntyne",
                AccountId = account.Id,
                TenantId  = tenant.Id
            });

            context.SaveChanges();
        }
        public static void Seed(HealthTrackerContext context)
        {
            var systemRole = context.Roles.First(x => x.Name == Roles.SYSTEM);
            var roles      = new List <Role>();
            var tenant     = context.Tenants.Single(x => x.Name == "Default");

            roles.Add(systemRole);
            context.Users.AddOrUpdate(x => x.Username, new User()
            {
                Username = "******",
                Password = new EncryptionService().TransformPassword("system"),
                Roles    = roles,
                TenantId = tenant.Id
            });

            context.SaveChanges();
        }
示例#8
0
        public async Task DeleteThrowsExceptionWhenIdDoesNotExist()
        {
            Connection = new SqliteConnection("DataSource=../../../testdb.db3");

            Opts = new DbContextOptionsBuilder <HealthTrackerContext>()
                   .UseSqlite(Connection).Options;

            using (var db = new HealthTrackerContext(Opts))
            {
                var service = new SymptomDataService(db);

                //Act

                //Assert
                Assert.ThrowsAsync <NullReferenceException>(async() => await service.DeleteSymptom("somedumbId"));
            }
        }
示例#9
0
        public async Task ItThrowsNullReferenceExceptionWhenInputModelFieldsAreEmpty()
        {
            var inputmodel = new SymptomInputModel();


            Connection = new SqliteConnection("DataSource=../../../testdb.db3");

            Opts = new DbContextOptionsBuilder <HealthTrackerContext>()
                   .UseSqlite(Connection).Options;

            using (var db = new HealthTrackerContext(Opts))
            {
                var service = new SymptomDataService(db);

                Assert.ThrowsAsync <NullReferenceException>(async() => await service.UpdateSymptom(inputmodel));
            }
        }
示例#10
0
        public async Task GetSymptomByIdReturnsSingleSymptomApiModel()
        {
            Connection = new SqliteConnection("DataSource=../../../testdb.db3");

            Opts = new DbContextOptionsBuilder <HealthTrackerContext>()
                   .UseSqlite(Connection).Options;

            using (var db = new HealthTrackerContext(Opts))
            {
                var service = new SymptomDataService(db);

                //Act
                var result = await service.GetSymptomById("c89b00bd-289b-4b63-a4c5-46fe11e12f2c");

                //Assert
                Assert.IsInstanceOf <SymptomApiModel>(result);
            }
        }
示例#11
0
        public static void Seed(HealthTrackerContext context)
        {
            context.Roles.AddOrUpdate(x => x.Name, new Role()
            {
                Name = Roles.SYSTEM
            });

            context.Roles.AddOrUpdate(x => x.Name, new Role()
            {
                Name = Roles.PRODUCT
            });

            context.Roles.AddOrUpdate(x => x.Name, new Role()
            {
                Name = Roles.DEVELOPMENT
            });

            context.SaveChanges();
        }
示例#12
0
        public async Task ItReturnsSymptomApiModelIfInputModelIsNull()
        {
            Connection = new SqliteConnection("DataSource=../../../testdb.db3");

            Opts = new DbContextOptionsBuilder <HealthTrackerContext>()
                   .UseSqlite(Connection).Options;

            using (var db = new HealthTrackerContext(Opts))
            {
                var service = new SymptomDataService(db);

                //Act
                var result = await service.GetSymptoms(null);

                //Assert
                Assert.IsInstanceOf <List <SymptomApiModel> >(result);
                Assert.AreEqual(2, result.Count);
            }
        }
示例#13
0
        public async Task Test1()
        {
            //Arrange
            Connection = new SqliteConnection("DataSource=../../../testdb.db3");

            Opts = new DbContextOptionsBuilder <HealthTrackerContext>()
                   .UseSqlite(Connection).Options;


            using (var db = new HealthTrackerContext(Opts))
            {
                db.Database.EnsureCreated();
                if (db.Database.IsSqlite())
                {
                    Console.WriteLine("Created Successfully and Database is SQLite!");
                }
                //Console.WriteLine($"{db.Symptoms.Count()} records in symptoms table! ${db.Symptoms.First().SymptomId.ToString()}" +
                //$"first record in database");
            }
            //Act
            using (var db = new HealthTrackerContext(Opts))
            {
                if (db.Symptoms.Count() < 1)
                {
                    var symptoms = new List <Symptom>
                    {
                        new Symptom("First Symptom", "The First one found"),
                        new Symptom("Second Symptom", "The Second one found")
                    };
                    db.Add(symptoms[0]);
                    db.Add(symptoms[1]);
                    db.SaveChanges();
                }
            }
            //Assert
            using (var db = new HealthTrackerContext(Opts))
            {
                var service = new SymptomDataService(db);
                var results = await service.GetSymptoms();

                Assert.AreEqual(2, results.Count);
            }
        }
示例#14
0
        public async Task DeleteChangesEntityStatusToDeleted()
        {
            Connection = new SqliteConnection("DataSource=../../../testdb.db3");

            Opts = new DbContextOptionsBuilder <HealthTrackerContext>()
                   .UseSqlite(Connection).Options;

            using (var db = new HealthTrackerContext(Opts))
            {
                var service = new SymptomDataService(db);

                var id = "c89b00bd-289b-4b63-a4c5-46fe11e12f2c";

                var symptom = await service.DeleteSymptom(id);

                var result = await db.Symptoms.AsNoTracking().SingleOrDefaultAsync(s => s.SymptomId.Equals(id));

                Assert.IsTrue(result.IsDeleted);
            }
        }
示例#15
0
 public GetMyProfileHandler(HealthTrackerContext context, ICache cache)
 {
     _context = context;
     _cache   = cache;
 }
 public SymptomDataService(HealthTrackerContext db)
 {
     _db = db;
 }
 public ConfirmRegistrationHandler(HealthTrackerContext context, ICache cache)
 {
     _context = context;
     _cache   = cache;
 }
示例#18
0
 public GetAccountByIdHandler(HealthTrackerContext context, ICache cache)
 {
     _context = context;
     _cache   = cache;
 }
示例#19
0
 public GetUsersHandler(HealthTrackerContext context, ICache cache)
 {
     _context = context;
     _cache   = cache;
 }
示例#20
0
 public GetDigitalAssetByUniqueIdHandler(HealthTrackerContext context, ICache cache)
 {
     _context = context;
     _cache   = cache;
 }
示例#21
0
 public AddOrUpdateProfileHandler(HealthTrackerContext context, ICache cache)
 {
     _context = context;
     _cache   = cache;
 }
示例#22
0
 public AddOrUpdateAccountHandler(HealthTrackerContext context, ICache cache)
 {
     _context = context;
     _cache   = cache;
 }
示例#23
0
 public RemoveAccountHandler(HealthTrackerContext context, ICache cache)
 {
     _context = context;
     _cache   = cache;
 }