public async Task Test_Create_Should_Create() { using var inMemoryDb = new JuniorAssignDbContext(CreateNewContextOptions()); var usersService = new UsersService(inMemoryDb); await usersService.CreateAsync("Monkata", "123"); Assert.Equal(1, inMemoryDb.Users.Count()); }
public async Task Test_IsUsernameUsed_Should_Return_False_If_Username_Does_Not_Exists() { using var inMemoryDb = new JuniorAssignDbContext(CreateNewContextOptions()); var usersService = new UsersService(inMemoryDb); await usersService.CreateAsync("Test", "123"); var isUsernameUsed = usersService.IsUsernameUsed("Invalid"); Assert.False(isUsernameUsed); }
public async Task Test_GetUserIdBy_Username_Should_Return_Correct_User() { using var inMemoryDb = new JuniorAssignDbContext(CreateNewContextOptions()); var usersService = new UsersService(inMemoryDb); var createdUserId = await usersService.CreateAsync("Test", "123"); var userId = usersService.GetUserIdBy("Test"); Assert.Equal(userId, createdUserId); }
public async Task Test_GetBy_Username_And_Password_Should_Return_Correct_User() { using var inMemoryDb = new JuniorAssignDbContext(CreateNewContextOptions()); var usersService = new UsersService(inMemoryDb); await usersService.CreateAsync("Test", "123"); var user = usersService.GetBy("Test", "123"); Assert.Equal("Test", user.Username); }
public async Task Test_Create_Should_Create() { using var inMemoryDb = new JuniorAssignDbContext(CreateNewContextOptions()); var contragentsService = new ContragentsService(inMemoryDb); var usersService = new UsersService(inMemoryDb); var createdUsedId = await usersService.CreateAsync("TestUsername", "123"); await contragentsService.CreateAsync("Test", "Testovo", "*****@*****.**", "123456", createdUsedId); Assert.Equal(1, inMemoryDb.Contragents.Count()); }
public async Task Test_GetAll_Should_Return_All_Users() { using var inMemoryDb = new JuniorAssignDbContext(CreateNewContextOptions()); var usersService = new UsersService(inMemoryDb); await usersService.CreateAsync("Monkata", "123"); await usersService.CreateAsync("Goshkata", "123"); await usersService.CreateAsync("Mitko", "123"); Assert.Equal(3, inMemoryDb.Users.Count()); }
public async Task Test_UpdateAsync_Should_Propelry_Update() { using var inMemoryDb = new JuniorAssignDbContext(CreateNewContextOptions()); var usersService = new UsersService(inMemoryDb); var createdUserId = await usersService.CreateAsync("Test", "123"); await usersService.UpdateAsync(createdUserId, "NewTest", "New123"); var user = usersService.GetBy(createdUserId); Assert.Equal("NewTest", user.Username); }
public async Task Test_GetAll_Should_Return_Only_Contragents_For_Current_User() { using var inMemoryDb = new JuniorAssignDbContext(CreateNewContextOptions()); var contragentsService = new ContragentsService(inMemoryDb); var usersService = new UsersService(inMemoryDb); var createdUsedId = await usersService.CreateAsync("TestUsername", "123"); await contragentsService.CreateAsync("Test", "Testovo", "*****@*****.**", "123456", createdUsedId); await contragentsService.CreateAsync("Test1", "Testovo1", "*****@*****.**", "1234567", createdUsedId); await contragentsService.CreateAsync("Test2", "Testovo2", "*****@*****.**", "12345678", "otherId"); var allContragents = contragentsService.GetAll(createdUsedId); Assert.Equal(2, allContragents.Count()); Assert.Equal(3, inMemoryDb.Contragents.Count()); }
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { var db = new JuniorAssignDbContext(); db.Database.EnsureCreated(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
public UsersService(JuniorAssignDbContext db) { this.db = db; }
public ContragentsService(JuniorAssignDbContext db) { this.db = db; }
public UserStore(JuniorAssignDbContext context) { db = context; }