public SendRegistrationConfirmationHandler(HealthTrackerContext context, ICache cache, INotificationService notificationService, IEncryptionService encryptionService) { _context = context; _cache = cache; _notificationService = notificationService; _encryptionService = encryptionService; }
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(); }
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(); }
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(); }
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")); } }
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)); } }
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); } }
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(); }
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); } }
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); } }
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); } }
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; }
public GetAccountByIdHandler(HealthTrackerContext context, ICache cache) { _context = context; _cache = cache; }
public GetUsersHandler(HealthTrackerContext context, ICache cache) { _context = context; _cache = cache; }
public GetDigitalAssetByUniqueIdHandler(HealthTrackerContext context, ICache cache) { _context = context; _cache = cache; }
public AddOrUpdateProfileHandler(HealthTrackerContext context, ICache cache) { _context = context; _cache = cache; }
public AddOrUpdateAccountHandler(HealthTrackerContext context, ICache cache) { _context = context; _cache = cache; }
public RemoveAccountHandler(HealthTrackerContext context, ICache cache) { _context = context; _cache = cache; }