public SupportGroupTest() { _context = GetDbContext(); _context.Add(new SupportGroup { Name = FIND, Description = CREATE_DESCRIPTION }); _context.SaveChanges(); _context.Add(new SupportGroup { Name = UPDATE }); _context.SaveChanges(); _context.Add(new SupportGroup { Name = DELETE }); _context.SaveChanges(); }
public async Task IsUniqueOnCreate(string insertedInDb, string insertedInCommand) { var result = await _context.AddAsync(InstanciateEntity(insertedInDb)); _context.SaveChanges(); _mediator.Send(new CreateProfilOptionCommand <TProfilOption> { Name = insertedInCommand }) .ShouldThrow(typeof(ValidationException)); }
public void CantCreateExistingGroup(string createWithDb, string createWithMediator) { _context.Add(new SupportGroup { Name = createWithDb }); _context.SaveChanges(); _mediator.Send(new CreateSupportGroupCommand { Name = createWithMediator }).ShouldThrow(typeof(ValidationException)); }
public void GetListVolunteeringTest() { _context.Add(new Volunteering { Title = VOLUNTEERING_TITLE2, Date = new DateTime(2014, 3, 29), Amount = 5, Details = "This is a detail", HourCount = 9, Acknowledgment = "WantSomeNuts", Customer = Customer, IsDelete = false, Type = VolunteeringType2 }); _context.SaveChanges(); var response = _mediator.Send(new GetVolunteeringListQuery { CustomerId = _context.Customers.Where(c => c.FirstName == "Yoo").Single().CustomerId }).Result; response.GetType().GetInterfaces().ShouldContain(typeof(System.Collections.Generic.IEnumerable <Volunteering>)); response.Count().ShouldBe(2); response.ElementAt(0).Amount.ShouldBe(3); response.ElementAt(0).Title.ShouldBe(VOLUNTEERING_TITLE); response.ElementAt(0).Type.Name.ShouldBe("Freeee"); response.ElementAt(0).Date.ShouldBe(new DateTime(2012, 3, 29)); response.ElementAt(0).Details.ShouldBe(""); response.ElementAt(0).HourCount.ShouldBe(8); response.ElementAt(0).Acknowledgment.ShouldBe("WantSome"); response.ElementAt(0).Customer.CustomerId.ShouldBe(Customer.CustomerId); response.ElementAt(0).VolonteeringTypeId.ShouldBe(VolunteeringType.Id); response.ElementAt(0).IsDelete.ShouldBe(false); response.ElementAt(1).Amount.ShouldBe(5); response.ElementAt(1).Title.ShouldBe(VOLUNTEERING_TITLE2); response.ElementAt(1).Type.Name.ShouldBe("Freeee"); response.ElementAt(1).Date.ShouldBe(new DateTime(2014, 3, 29)); response.ElementAt(1).Details.ShouldBe("This is a detail"); response.ElementAt(1).HourCount.ShouldBe(9); response.ElementAt(1).Acknowledgment.ShouldBe("WantSomeNuts"); response.ElementAt(1).Customer.CustomerId.ShouldBe(Customer.CustomerId); response.ElementAt(1).VolonteeringTypeId.ShouldBe(VolunteeringType2.Id); response.ElementAt(1).IsDelete.ShouldBe(false); }
public void GetNoteTest() { var dateAdded = DateTime.Now; _context.Add(new Note { NoteName = GETNOTENAME, Body = GETNOTEBODY, NoteType = new NoteType { Id = NOTETYPEID }, CreationDate = dateAdded, SupervisorName = GETNOTESUPERVISOR, SupervisorTitle = SUPPERVISORTITLE, Customer = _context.Customers.First() }); _context.SaveChanges(); var result = _mediator.Send(new GetNoteQuery { NoteId = _context.Notes.First().NoteId }).Result; result.ShouldBeOfType(typeof(GetNoteModel)); result.NoteName.ShouldBe(GETNOTENAME); result.NoteId.ShouldBe(1); result.NoteTypeId.ShouldBe(NOTETYPEID); result.Body.ShouldBe(GETNOTEBODY); result.CreationDate.ShouldBe(dateAdded); result.CustomerId.ShouldBe(1); result.SupervisorName.ShouldBe(GETNOTESUPERVISOR); result.SupervisorTitle.ShouldBe(SUPPERVISORTITLE); }
public void CreateParticipantTest() { var customer = _context.Add(new Customer { FirstName = "Fred", LastName = "Jacq", CustomerDescription = new CustomerDescription() }); var atelier = _context.Add(new Workshop { Session = new Session() }); _context.SaveChanges(); var seance1 = _context.Add(new Seance { WorkshopId = atelier.Entity.WorkshopId }); var seance2 = _context.Add(new Seance { WorkshopId = atelier.Entity.WorkshopId }); _context.SaveChanges(); _mediator.Send(new CreateParticipantCommand { CustomerId = customer.Entity.CustomerId, WorkshopId = atelier.Entity.WorkshopId }).Wait(); var participants = _context.Participants.ToArray(); participants.Count().ShouldBe(2); foreach (var participant in participants) { participant.CustomerId.ShouldBe(customer.Entity.CustomerId); participant.WorkshopId.ShouldBe(atelier.Entity.WorkshopId); (participant.SeanceId == seance1.Entity.SeanceId || participant.SeanceId == seance2.Entity.SeanceId).ShouldBe(true); } }
public void GetWorkshopTest() { var workshop = _context.Add(new Workshop { EndDate = WORKSHOP_ENDDATE, Session = new Session { Year = 2019, Season = Season.Winter }, StartDate = WORKSHOP_STATDATE, WorkshopDescription = WORKSHOP_DESCRIPTION, WorkshopName = WORKSHOP_NAME, WorkshopType = new WorkshopType { Name = WORKSHOP_TYPE }, IsOpen = ISOPENSTATE }); _context.SaveChanges(); _context.Add(new Seance { SeanceDate = SEANCE1_DATETIME, SeanceDescription = SEANCE1_DESCRIPTION, SeanceName = SEANCE1_NAME, SeanceTimeSpan = SEANCE1_TIMESPAN, WorkshopId = workshop.Entity.WorkshopId }); _context.SaveChanges(); var result = _mediator.Send(new GetWorkshopQuery { WorkshopId = workshop.Entity.WorkshopId }).Result; result.ShouldBeOfType(typeof(GetWorkshopModel)); result.EndDate.ShouldBe(WORKSHOP_ENDDATE); result.StartDate.ShouldBe(WORKSHOP_STATDATE); result.WorkshopDescription.ShouldBe(WORKSHOP_DESCRIPTION); result.WorkshopId.ShouldBe(workshop.Entity.WorkshopId); result.WorkshopTypeName.ShouldBe(WORKSHOP_TYPE); result.Seances.Count.ShouldBe(1); result.IsOpen.ShouldBe(ISOPENSTATE); var seance = result.Seances.ElementAt(0); seance.SeanceId.ShouldBeGreaterThan(0); seance.SeanceDate.ShouldBe(SEANCE1_DATETIME); seance.SeanceName.ShouldBe(SEANCE1_NAME); seance.SeanceTimeSpan.ShouldBe(SEANCE1_TIMESPAN); }
public ProfilOptionTestBase() { _context = GetDbContext(); _context.Add(InstanciateEntity(FIND)); _context.Add(InstanciateEntity(UPDATE)); _context.Add(InstanciateEntity(DELETE)); _context.Add(InstanciateEntity("Deleted", true)); _context.SaveChanges(); }
public void Test1() { _context.Add(new FamilyType { Name = NAME }); _context.SaveChanges(); var familytype = _context.FamilyTypes.SingleOrDefault(x => x.Name == NAME); familytype.ShouldBeOfType <FamilyType>(); familytype.Name.ShouldBe(NAME); }
public override void CantDeleteRelatedData() { var entity = _context.Add(new ChildrenAgeBracket { Name = "RandomName" }).Entity; _context.SaveChanges(); _context.CustomerChildrenAgeBrackets.Add(new CustomerChildrenAgeBracket { AgeBracket = entity, Customer = _context.CustomerDescriptions.First() }); _context.SaveChanges(); entity.CustomerChildrenAgeBrackets.Add(_context.CustomerChildrenAgeBrackets.First()); _mediator.Send(new DeleteProfilOptionCommand <ChildrenAgeBracket> { Id = entity.Id }) .ShouldThrow(typeof(ValidationException)); }
public YearlyIncomeTest() : base() { _context = GetDbContext(); var customer = _context.Add(new Customer { CustomerDescription = new CustomerDescription() }).Entity; customer.CustomerActivations.Add(new CustomerActivation()); _context.SaveChanges(); }
public override void CantDeleteRelatedData() { var yearlyIncome = _context.YearlyIncomes.First(); yearlyIncome.CustomerDescriptions.Add(_context.CustomerDescriptions.First()); _context.SaveChanges(); var result = _mediator.Send(new DeleteProfilOptionCommand <YearlyIncome> { Id = yearlyIncome.Id }).ShouldThrow(typeof(ValidationException)); }
private void PopulateTestingData() { _context.AddRange(new SupportGroup { Name = "Cegep de sainte-foy" }, new SupportGroup { Name = "Universite Laval" }, new SupportGroup { Name = "Hopital regional" }, new SupportGroup { Name = "Centre des femmes" }, new SupportGroup { Name = "isDelete", IsDelete = true }); _context.AddRange(new ReferenceType { Name = "Ecole" }, new ReferenceType { Name = "Hopital" }, new ReferenceType { Name = "CLSC" }, new ReferenceType { Name = "isDelete", IsDelete = true }); _context.AddRange(new HeardOfUsFrom { Name = "reseau sociaux" }, new HeardOfUsFrom { Name = "moteur de recherche" }, new HeardOfUsFrom { Name = "journaux" }, new HeardOfUsFrom { Name = "connaissance" }, new HeardOfUsFrom { Name = "professionnel de la sante" }, new HeardOfUsFrom { Name = "isDelete", IsDelete = true }); _context.SaveChanges(); }
public SchoolingTest() : base() { _context = GetDbContext(); var customer = _context.Add(new Customer { CustomerDescription = new CustomerDescription() }).Entity; customer.CustomerActivations.Add(new CustomerActivation { IsActive = true, IsActiveSince = DateTime.Now }); _context.SaveChanges(); }
public override void CantDeleteRelatedData() { var entity = _context.Add(new CitizenStatus { Name = "CantBeDeleted" }).Entity; entity.CustomerDescriptions.Add(_context.CustomerDescriptions.First()); _context.SaveChanges(); _mediator.Send(new DeleteProfilOptionCommand <CitizenStatus> { Id = entity.Id }).ShouldThrow(typeof(ValidationException)); }
public override void CantDeleteRelatedData() { var entity = new Availability { Name = "testTrue" }; entity.CustomerDescriptions.Add(_context.CustomerDescriptions.First()); _context.Add(entity); _context.SaveChanges(); var result = _mediator.Send(new DeleteProfilOptionCommand <Availability> { Id = entity.Id }) .ShouldThrow(typeof(ValidationException)); }
public SeanceTest() { _context = GetDbContext(); _context.Add(new Workshop()); var custo = _context.Add(new Customer { FirstName = CUSTOMER_FIRST_NAME, LastName = CUSTOMER_LAST_NAME, CustomerDescription = new CustomerDescription() }).Entity; custo.CustomerActivations.Add(new CustomerActivation()); _context.SaveChanges(); }
public override void CantDeleteRelatedData() { var volonteeringType = new VolunteeringType { Name = "test" }; _context.Add(new Volunteering { Type = volonteeringType }); _context.SaveChanges(); _mediator.Send(new DeleteProfilOptionCommand <VolunteeringType> { Id = volonteeringType.Id }) .ShouldThrow(typeof(ValidationException)); }
public override void CantDeleteRelatedData() { var document = new Document { DocumentType = new DocumentType { Name = "test" } }; _context.Documents.Add(document); _context.SaveChanges(); var result = _mediator.Send(new DeleteProfilOptionCommand <DocumentType> { Id = _context.DocumentTypes.Where(t => t.Name == "test").Single().Id }).ShouldThrow(typeof(ValidationException)); }
public void CantGetDeletedSeance() { var deletedSeance = _context.Add(new Seance { SeanceDate = SEANCE_DATE, SeanceDescription = SEANCE_DESCRIPTION, SeanceName = SEANCE_NAME, SeanceTimeSpan = SEANCE_TIMESPAN, IsDelete = true, WorkshopId = _context.Workshops.First().WorkshopId }); _context.SaveChanges(); var result = _mediator.Send(new GetSeanceQuery { SeanceId = deletedSeance.Entity.SeanceId }).ShouldThrow(typeof(ValidationException)); }
public NoteTest() { _context = GetDbContext(); _context.Add(new Customer { Address = "288, rue principale", City = "Saint-Alfred", Country = "Canada", CustomerDescription = new CustomerDescription(), DateOfBirth = new DateTime(1994, 01, 21), FirstName = "Frédéric", LastName = "Jacques", Phone = "418-774-9890", PostalCode = "G0M 1L0", Province = "Québec" }); _context.SaveChanges(); }
public VolunteeringTest() { _context = GetDbContext(); Customer = new Customer { FirstName = "Yoo" }; Customer2 = new Customer { FirstName = "Aaargh" }; VolunteeringType = new VolunteeringType { Name = "Freeee" }; VolunteeringType2 = new VolunteeringType { Name = "Freeee" }; _context.Add(Customer); _context.Add(Customer2); _context.Add(VolunteeringType); _context.Add(VolunteeringType2); MainVolonteering = new Volunteering { Title = VOLUNTEERING_TITLE, Date = new DateTime(2012, 3, 29), Amount = 3, Details = "", HourCount = 8, Acknowledgment = "WantSome", Customer = Customer, IsDelete = false, Type = VolunteeringType }; _context.Add(MainVolonteering); _context.SaveChanges(); }
public override void CantDeleteRelatedData() { var language = _context.Add(new Language { Name = "Testing" }).Entity; var customer = _context.Add(new Customer { CustomerDescription = new CustomerDescription() }).Entity; customer.CustomerActivations.Add(new CustomerActivation()); language.CustomerDescriptions.Add(customer.CustomerDescription); _context.SaveChanges(); _mediator.Send(new DeleteProfilOptionCommand <Language> { Id = language.Id }) .ShouldThrow(typeof(ValidationException)); }
public MemberTest() { _context = GetDbContext(); _context.Add(new CustomerDescription()); _context.Add(new Member { AmountByMonth = 1000m, Customer = new Customer(), SubscriptionDate = new DateTime(2012, 3, 29), VolunteeringHourCountByMonth = 3 }); _context.Add(new Member { AmountByMonth = 1500m, Customer = new Customer(), SubscriptionDate = new DateTime(2012, 3, 29), VolunteeringHourCountByMonth = 4 }); _context.SaveChanges(); }
public DocumentTest() { _context = GetDbContext(); var johnDoe = new Customer { Address = "288, northway-south", City = "Saint-Alfredos", Country = "Canada", CustomerDescription = null, DateOfBirth = new DateTime(1994, 01, 21, 11, 36, 34), FirstName = "John", LastName = "Doe", Phone = "458-895-5623", PostalCode = "G0G 0G0", Province = "Québec" }; _context.Add(johnDoe); var documentType = new DocumentType { Name = DOCUMENT_TYPE_NAME }; var afterupdateDocType = new DocumentType { Name = AFTER_UPDATE_TYPE }; _context.Add(documentType); _context.Add(afterupdateDocType); _testFileDirectory = $"{Directory.GetCurrentDirectory()}\\DocumentTestFiles"; Directory.CreateDirectory(_testFileDirectory); _findPath = $"{_testFileDirectory}\\{FIND}.txt"; var updateFilePath = $"{_testFileDirectory}\\{UPDATE}.txt"; var deleteFilePath = $"{_testFileDirectory}\\{DELETE}.txt"; var deletedFilePath = $"{_testFileDirectory}\\{DELETED}.txt"; File.WriteAllText(_findPath, FIND); File.WriteAllText(updateFilePath, UPDATE); File.WriteAllText(deleteFilePath, DELETE); _context.Documents.Add(new Document { DocumentName = FIND, Description = FIND_DESCRIPTION, Path = _findPath, Customer = johnDoe, DocumentType = documentType }); _context.Documents.Add(new Document { DocumentName = UPDATE, Path = updateFilePath, Description = UPDATE_DESCRIPTION, Customer = johnDoe, DocumentType = documentType }); _context.Documents.Add(new Document { DocumentName = DELETE, Path = deleteFilePath, Customer = johnDoe, DocumentType = documentType }); _context.Documents.Add(new Document { DocumentName = DELETED, Path = deleteFilePath, Customer = johnDoe, IsDelete = true }); _context.SaveChanges(); }
public void GetListSessionTest() { var session2017Fall = new Session { Season = Season.Fall, Year = 2017 }; var session2018Winter = new Session { Season = Season.Winter, Year = 2018 }; var session2019Summer = new Session { Season = Season.Summer, Year = 2019 }; var session2020Spring = new Session { Season = Season.Spring, Year = 2020 }; var session2021Summer = new Session { Season = Season.Summer, Year = 2021 }; var session2022Summer = new Session { Season = Season.Summer, Year = 2022 }; _context.Sessions.AddRange( session2017Fall, session2018Winter, session2019Summer, session2020Spring, session2021Summer, session2022Summer ); _context.SaveChanges(); var sessionsResult = _mediator.Send(new GetSessionListQuery()).Result; sessionsResult.Sessions.Count().ShouldBe(6); sessionsResult.Sessions.ShouldContain(s => s.SeasonName == "Automne" && s.Year == 2017); sessionsResult.Sessions.ShouldContain(s => s.SeasonName == "Hiver" && s.Year == 2018); sessionsResult.Sessions.ShouldContain(s => s.SeasonName == "Été" && s.Year == 2019); sessionsResult.Sessions.ShouldContain(s => s.SeasonName == "Printemps" && s.Year == 2020); sessionsResult.Sessions.ShouldContain(s => s.SeasonName == "Été" && s.Year == 2021); sessionsResult.Sessions.ShouldContain(s => s.SeasonName == "Été" && s.Year == 2022); }
private void PopulateTestingData() { _context.AddRange(new Sex { Name = "homme" }, new Sex { Name = "femme" }, new Sex { Name = "autre" }); _context.AddRange(new Parent { Name = "pere" }, new Parent { Name = "mere" }); _context.AddRange(new MaritalStatus { Name = "marie" }, new MaritalStatus { Name = "conjoint de fait" }, new MaritalStatus { Name = "celibataire" }, new MaritalStatus { Name = "separe" }); _context.AddRange(new CitizenStatus { Name = "citoyen canadien" }, new CitizenStatus { Name = "resident temporaire" }, new CitizenStatus { Name = "immigrant" }); _context.AddRange(new FamilyType { Name = "biologique" }, new FamilyType { Name = "reconstitue" }, new FamilyType { Name = "separe" }); _context.AddRange(new Language { Name = "francais" }, new Language { Name = "anglais" }, new Language { Name = "espagnol" }, new Language { Name = "mandarin" }, new Language { Name = "arabe" }, new Language { Name = "japonais" }); _context.AddRange(new HomeType { Name = "maison unifamiliale" }, new HomeType { Name = "appartement" }, new HomeType { Name = "hlm" }, new HomeType { Name = "condo" }, new HomeType { Name = "autre" }); _context.AddRange(new TransportType { Name = "voiture" }, new TransportType { Name = "camion" }, new TransportType { Name = "transport en commun" }, new TransportType { Name = "velo" }, new TransportType { Name = "autre" }); _context.AddRange(new Schooling { Name = "primaire" }, new Schooling { Name = "secondaire" }, new Schooling { Name = "collegiale" }, new Schooling { Name = "universitaire baccalaureat" }, new Schooling { Name = "universitaire maitrise" }, new Schooling { Name = "universitaire doctorat" }, new Schooling { Name = "autre" }); _context.AddRange(new IncomeSource { Name = "travail" }, new IncomeSource { Name = "aide-social" }, new IncomeSource { Name = "chomage" }, new IncomeSource { Name = "autre" }); _context.AddRange(new Availability { Name = "matin 8:00 - 10:00" }, new Availability { Name = "matin 10:00 - 12:00" }, new Availability { Name = "jour 12:00 - 14:00" }, new Availability { Name = "jour 14:00 - 16:00" }, new Availability { Name = "jour 16:00 - 18:00" }, new Availability { Name = "soir 18:00 - 20:00" }, new Availability { Name = "soir 20:00 - 22:00" }); _context.AddRange(new YearlyIncome { Name = "1" }, new YearlyIncome { Name = "2" }, new YearlyIncome { Name = "3" }, new YearlyIncome { Name = "4" }, new YearlyIncome { Name = "5" }, new YearlyIncome { Name = "6" }, new YearlyIncome { Name = "7" }); _context.AddRange(new LegalCustody { Name = "avec droit d'acces" }, new LegalCustody { Name = "sans droit d'acces" }, new LegalCustody { Name = "garde partagee" }); _context.AddRange(new ChildrenAgeBracket { Name = "1" }, new ChildrenAgeBracket { Name = "2" }, new ChildrenAgeBracket { Name = "3" }, new ChildrenAgeBracket { Name = "4" }, new ChildrenAgeBracket { Name = "5" }, new ChildrenAgeBracket { Name = "6" }); _context.AddRange(new SkillToDevelop { Name = "Habilete parental" }, new SkillToDevelop { Name = "Habilete perso et social" }, new SkillToDevelop { Name = "Saines habitude de vie" }); _context.AddRange(new SocialService { Name = "Hopitaux" }, new SocialService { Name = "CLSC" }, new SocialService { Name = "organisme communautaire" }, new SocialService { Name = "services prives" }, new SocialService { Name = "des proches" }, new SocialService { Name = "du reseau social" }); _context.AddRange(new SupportGroup { Name = "Cegep de sainte-foy" }, new SupportGroup { Name = "Universite Laval" }, new SupportGroup { Name = "Hopital regional" }, new SupportGroup { Name = "Centre des femmes" }, new SupportGroup { Name = "autre" }); _context.AddRange(new ReferenceType { Name = "Ecole" }, new ReferenceType { Name = "Hopital" }, new ReferenceType { Name = "CLSC" }, new ReferenceType { Name = "Autre" }); _context.AddRange(new HeardOfUsFrom { Name = "reseau sociaux" }, new HeardOfUsFrom { Name = "moteur de recherche" }, new HeardOfUsFrom { Name = "journaux" }, new HeardOfUsFrom { Name = "connaissance" }, new HeardOfUsFrom { Name = "professionnel de la sante" }, new HeardOfUsFrom { Name = "autre" }); _context.SaveChanges(); }