< Summary

Information
Class: Syki.Back.Features.Cross.SkipUserRegister.SkipUserRegisterService
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Features/Cross/SkipUserRegister/SkipUserRegisterService.cs
Tag: 22_11348620282
Line coverage
0%
Covered lines: 0
Uncovered lines: 21
Coverable lines: 21
Total lines: 44
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
Skip()0%620%
Register()100%210%
Login()100%210%

File(s)

/home/runner/work/syki/syki/Back/Features/Cross/SkipUserRegister/SkipUserRegisterService.cs

#LineLine coverage
 1using Syki.Back.Features.Cross.GenerateJWT;
 2using Syki.Back.Features.Cross.FinishUserRegister;
 3using Syki.Back.Features.Cross.CreatePendingUserRegister;
 4
 5namespace Syki.Back.Features.Cross.SkipUserRegister;
 6
 07public class SkipUserRegisterService(
 08    SykiDbContext ctx,
 09    GenerateJWTService generateJWTService,
 010    FinishUserRegisterService finishService,
 011    CreatePendingUserRegisterService createService
 012) : ICrossService
 13{
 14    public async Task<OneOf<SkipUserRegisterLoginOut, SykiError>> Skip(SkipUserRegisterLoginIn data)
 15    {
 016        var user = await ctx.Users.AsNoTracking().Where(x => x.Id == data.UserId).FirstOrDefaultAsync();
 17
 018        if (user == null) data.UserId = await Register();
 19
 020        return await Login(data.UserId);
 021    }
 22
 23    public async Task<Guid> Register()
 24    {
 025        var email = $"academico.{Guid.NewGuid().ToString().OnlyNumbers()[..8]}@syki.skip.com";
 026        var password = $"Academic@{Guid.NewGuid().ToString().OnlyNumbers()}";
 27
 028        await createService.Create(new(email));
 29
 030        var register = await ctx.UserRegisters.FirstAsync(d => d.Email == email);
 31
 032        var user = await finishService.Finish(new(register.Id.ToString(), password));
 033        return user.GetSuccess().Id;
 034    }
 35
 36    public async Task<SkipUserRegisterLoginOut> Login(Guid userId)
 37    {
 038        var user = await ctx.Users.AsNoTracking().Where(x => x.Id == userId).FirstAsync();
 39
 040        var jwt = await generateJWTService.Generate(user.Email);
 41
 042        return new() { UserId = userId, AccessToken = jwt };
 043    }
 44}