Bogus Implementation For Testing

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 5

public async Task InsuranceCreate(int increment)

{
var idArs = await _context.Ars.Select(a => a.id).ToListAsync();
var faker =
FakeSetup.GenerateInsuranceSetup(idArs).Generate(increment);
await _context.Seguro.AddRangeAsync(faker);

await _context.SaveChangesAsync();
}

public async Task PSSCodeCreation(int increment)


{
var idArsValues = await _context.Ars.Select(a => a.id).ToListAsync();
var idMedicoValues = await _context.Medico.Select(m =>
m.id).ToListAsync();

var FPSS = FakeSetup.GeneratePSSCodeSetup(idArsValues,


idMedicoValues).Generate(increment);
await _context.CodigoPSSes.AddRangeAsync(FPSS);

await _context.SaveChangesAsync();
}

public async Task DoctorsCreation(int increment)


{
var FakeDoctor = FakeSetup.GenerateDoctorSetup().Generate(increment);
await _context.Medico.AddRangeAsync(FakeDoctor);

await _context.SaveChangesAsync();
}

public async Task MedicalCenterCreation(int increment)


{
var FMedicalCenter =
FakeSetup.GenerateMedicalCenterSetup().Generate(increment);
await _context.Centro_Medico.AddRangeAsync(FMedicalCenter);

await _context.SaveChangesAsync();
}

public async Task DoctorCenterCreation(int increment)


{
var idMedico = await _context.Medico.Select(a => a.id).ToListAsync();
var idCentroMedico = await _context.Centro_Medico.Select(m =>
m.id).ToListAsync();

var FDoctorCenter = FakeSetup.GenerateDoctorCenterSetup(idMedico,


idCentroMedico).Generate(increment);
await _context.Centro_del_doctor.AddRangeAsync(FDoctorCenter);

await _context.SaveChangesAsync();
}

public async Task EventTypeCreation(int increment){


var idMedico_ = await _context.Medico.Select(a => a.id).ToListAsync();
var FEventType =
FakeSetup.GenerateEventTypeSetup(idMedico_).Generate(increment);
await _context.eventTypes.AddRangeAsync(FEventType);
await _context.SaveChangesAsync();
}

public async Task BookingCreation(int increment){


var ideventType_ = await _context.eventTypes.Select(a =>
a.id).ToListAsync();
var FBooking =
FakeSetup.GenerateBookingSetup(ideventType_).Generate(increment);;
await _context.bookings.AddRangeAsync(FBooking);

await _context.SaveChangesAsync();
}

public async Task BookingsDoctorCreation(int increment)


{
var idBooking_ = await _context.bookings.Select(a =>
a.id).ToListAsync();
var idDoctor_ = await _context.Medico.Select(a => a.id).ToListAsync();
var FBDoctor = FakeSetup.GenerateBookingDoctorSetup(idBooking_,
idDoctor_).Generate(increment);
await _context.bookingsDoctors.AddRangeAsync(FBDoctor);

await _context.SaveChangesAsync();
}

public async Task BookingsReferencesCreation(int increment)


{
var idBooking_ = await _context.bookings.Select(a =>
a.id).ToListAsync();
var BReferences =
FakeSetup.GenerateBookingReferencesSetup(idBooking_).Generate(increment);
await _context.bookingReferences.AddRangeAsync(BReferences);

await _context.SaveChangesAsync();
}

___________________________________________________________________________________
____________________________________

public static Faker<Seguros> GenerateInsuranceSetup( List<int> idArs)


{
Faker<Seguros> Faker;
Randomizer.Seed = new Random(DateTime.Now.Millisecond);
Faker = new Faker<Seguros>()
.RuleFor(a => a.NSS, b => b.Random.Number(1000, 9999))
.RuleFor(a => a.poliza, b => b.Random.AlphaNumeric(10).ToUpper())
.RuleFor(a => a.tipo_seguro, b => b.PickRandom("Seguro Publico",
"Seguro Privado", "Seguro Complementario"))
.RuleFor(a => a.id_ars, b => b.Random.ArrayElement(idArs.ToArray()))
.RuleFor(a => a.dependiente, b => b.Random.Bool());
return Faker;
}
public static Faker<CodigoPSS> GeneratePSSCodeSetup(List<int> idArs,
List<int> idMedico)
{
Faker<CodigoPSS> Faker;
Randomizer.Seed = new Random(DateTime.Now.Millisecond);
Faker = new Faker<CodigoPSS>()
.RuleFor(a => a.codigo, b => b.Random.AlphaNumeric(10).ToUpper())
.RuleFor(a => a.propietario, b => b.Name.FullName())
.RuleFor(a => a.status, b => b.Random.Bool())
.RuleFor(a => a.id_ars, b => b.Random.ArrayElement(idArs.ToArray()))
.RuleFor(a => a.id_medico, b =>
b.Random.ArrayElement(idMedico.ToArray()));
return Faker;
}

public static Faker<Medico> GenerateDoctorSetup(){


Faker<Medico> FakerDoctor;
Randomizer.Seed = new Random(DateTime.Now.Millisecond);
FakerDoctor = new Faker<Medico>()
.RuleFor(a => a.auth0_id, b => b.Random.AlphaNumeric(10).ToUpper())
.RuleFor(a => a.cedula, b => b.Random.Long(1111111111, 99999999999))
.RuleFor(a => a.nombre, b => b.Name.FirstName())
.RuleFor(a => a.apellido, b => b.Name.LastName())
.RuleFor(a => a.excut, b => b.Random.AlphaNumeric(10).ToUpper())
.RuleFor(a => a.correo, b => b.Internet.Email())
.RuleFor(a => a.username, b => b.Internet.UserName())
.RuleFor(a => a.especialidad, b => b.PickRandom("Medicina General",
"Pediatría", "Obstetricia y Ginecología",
"Medicina Interna", "Cardiología", "Dermatología","Endocrinología",
"Gastroenterología", "Hematología","Nefrología",
"Neurología", "Neumología","Oncología", "Psiquiatría",
"Radiología","Anestesiología", "Urología", "Oftalmología",
"Otorrinolaringología", "Reumatología", "Infectología","Cirugía
Ortopédica y Traumatología",
"Cirugía Cardiovascular", "Cirugía Cardiovascular","Cirugía Plástica y
Reconstructiva", "Neurologia", "Nefrología"));
return FakerDoctor;
}
public static Faker<Centro_medico> GenerateMedicalCenterSetup(){
Faker<Centro_medico> FakeMedicalCenter;
Randomizer.Seed = new Random(DateTime.Now.Millisecond);
FakeMedicalCenter = new Faker<Centro_medico>()
.RuleFor(a => a.nombre, b => b.Company.CompanyName())
.RuleFor(a => a.codigo_empresarial, b =>
b.Random.AlphaNumeric(10).ToUpper());
return FakeMedicalCenter;
}

public static Faker<Centro_del_doctor> GenerateDoctorCenterSetup(List<int>


idMedico, List<int> idcentroMedico){
Faker<Centro_del_doctor> FakeDoctorCenter;
Randomizer.Seed = new Random(DateTime.Now.Millisecond);
FakeDoctorCenter = new Faker<Centro_del_doctor>()
.RuleFor(a => a.id_medico, b =>
b.Random.ArrayElement(idMedico.ToArray()))
.RuleFor(a => a.id_centro_medico, b =>
b.Random.ArrayElement(idcentroMedico.ToArray()));
return FakeDoctorCenter;
}

public static Faker<EventType> GenerateEventTypeSetup(List<int> idMedico){


Faker<EventType> FakeEventType;
Randomizer.Seed = new Random(DateTime.Now.Millisecond);
FakeEventType = new Faker<EventType>()
.RuleFor(a => a.title, b => b.Lorem.Sentence())
.RuleFor(a => a.slug, b => b.Lorem.Slug())
.RuleFor(a => a.description, b => b.Lorem.Paragraph())
.RuleFor(a => a.link, b => "https://" + b.Random.AlphaNumeric(10) +
".com/page-" + b.Random.Number(1, 100) + ".html")
.RuleFor(a => a.time, b => b.Random.Int(0, 24))
.RuleFor(a => a.timeZone, b => b.PickRandom("UTC-11 Pacific/Midway",
"UTC-4 America/Santo_Domingo",
"UTC-4 America/Puerto_Rico", "UTC-10 Pacific/Honolulu", "UTC-8
America/Tijuana", "UTC-8 America/Los_Angeles",
"UTC-8 America/Vancouver", "UTC-5 America/Bogota", "UTC-4
America/Caracas", "UTC+2 Asia/Jerusalem"))
.RuleFor(a => a.id_Medico, b =>
b.Random.ArrayElement(idMedico.ToArray()));

return FakeEventType;
}

public static Faker<Booking> GenerateBookingSetup(List<int> ideventType){


Faker<Booking> Fakebooking;
Randomizer.Seed = new Random(DateTime.Now.Millisecond);

Fakebooking = new Faker<Booking>()


.RuleFor(a => a.title, b => b.Lorem.Sentence())
.RuleFor(a => a.description, b => b.Lorem.Paragraph())
.RuleFor(a => a.email, b => b.Internet.Email())
.RuleFor(a => a.status, b => b.Random.Bool())
.RuleFor(a => a.starTime, b => b.Date.Between(new
DateTime(2023,1,1).Date, new DateTime(2024,1,1).Date))
.RuleFor(a => a.endTime, b => b.Date.Between(new
DateTime(2024,1,1).Date, new DateTime(2025,1,1).Date))
.RuleFor(a => a.CreateAt, b => b.Date.BetweenTimeOnly(new
TimeOnly(8,0), new TimeOnly(12, 0)))
.RuleFor(a => a.UpdateAt, b => b.Date.BetweenTimeOnly(new TimeOnly(13,
0), new TimeOnly(18, 0)))
.RuleFor(a => a.statusCancellation, b => b.Random.Bool())
.RuleFor(a => a.id_EventType, b =>
b.Random.ArrayElement(ideventType.ToArray()));

return Fakebooking;
}

public static Faker<BookingsDoctor> GenerateBookingDoctorSetup(List<int>


idbooking, List<int> idDoctor){
Faker<BookingsDoctor> FakebookingDoctor;
Randomizer.Seed = new Random(DateTime.Now.Millisecond);
FakebookingDoctor = new Faker<BookingsDoctor>()
.RuleFor(a => a.id_Booking, b =>
b.Random.ArrayElement(idbooking.ToArray()))
.RuleFor(a => a.id_Doctor, b =>
b.Random.ArrayElement(idDoctor.ToArray()));

return FakebookingDoctor;
}
public static Faker<BookingReferences>
GenerateBookingReferencesSetup(List<int> idbooking){
Faker<BookingReferences> Fakeb_References;
Randomizer.Seed = new Random(DateTime.Now.Millisecond);
Fakeb_References = new Faker<BookingReferences>()
.RuleFor(a => a.cancellationReason, b => b.Lorem.Paragraph())
.RuleFor(a => a.id_Booking, b =>
b.Random.ArrayElement(idbooking.ToArray()));

return Fakeb_References;
}
}

___________________________________________________________________________________
__________________________________
await _dummy.InsuranceCreate(increment);
await _dummy.DoctorsCreation(increment);
await _dummy.DoctorCenterCreation(increment);
await _dummy.PSSCodeCreation(increment);
await _dummy.MedicalCenterCreation(increment);
await _dummy.EventTypeCreation(increment);
await _dummy.BookingCreation(increment);
await _dummy.BookingsDoctorCreation(increment);
await _dummy.BookingsReferencesCreation(increment);

You might also like