Beispiel #1
0
        protected Customer CreateCustomer(string customerFirstName)
        {
            var customer = new Customer
            {
                FirstName           = customerFirstName,
                LastName            = "Legrand",
                Address             = "516 rue Saint-Luc",
                PostalCode          = "G1N2V3",
                City                = "Quebec",
                Province            = "Quebec",
                Country             = "Canada",
                DateOfBirth         = new DateTime(1986, 11, 25),
                Phone               = "418-271-3856",
                SecondaryPhone      = "418-895-5996",
                HeardOfUsFrom       = _context.HeardOfUsFroms.Find(3),
                ReferenceBy         = _context.ReferenceTypes.Find(2),
                SupportGroup        = _context.SupportGroups.Find(4),
                CustomerDescription = new CustomerDescription()
            };

            customer.CustomerActivations.Add(new CustomerActivation {
                IsActive = true, IsActiveSince = DateTime.Now
            });

            _context.Add(customer);
            _context.SaveChanges();
            return(_context.Customers.Include(c => c.CustomerActivations).Where(c => c.FirstName.Equals(customerFirstName)).Single());
        }
Beispiel #2
0
        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 ProfilOptionTestBase()
        {
            _context = GetDbContext();

            _context.Add(InstanciateEntity(FIND));
            _context.Add(InstanciateEntity(UPDATE));
            _context.Add(InstanciateEntity(DELETE));
            _context.Add(InstanciateEntity("Deleted", true));

            _context.SaveChanges();
        }
Beispiel #4
0
        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 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 async Task <Unit> Handle(CreateCustomerCommand request, CancellationToken cancellationToken)
        {
            int fileNumber = CustomerFileNumberCreator.CreateFileNumberAsync(_context, _time);

            Customer customer = new Customer
            {
                CustomerDescription = new CustomerDescription(),
                FileNumber          = fileNumber,
                CreationDate        = _time.Now,
                SuppressionDate     = null,
                FirstName           = request.Model.FirstName,
                LastName            = request.Model.LastName,
                NormalizedName      = StringNormalizer.Normalize(request.Model.FirstName + request.Model.LastName),
                DateOfBirth         = request.Model.DateOfBirth,
                Address             = request.Model.Address,
                PostalCode          = request.Model.PostalCodeName,
                City            = request.Model.CityName,
                Province        = request.Model.ProvinceName,
                Country         = request.Model.CountryName,
                Phone           = request.Model.Phone,
                SecondaryPhone  = request.Model.SecondaryPhone,
                SupportGroup    = (request.Model.SupportGroupId == null) ? null : _context.SupportGroups.Find(request.Model.SupportGroupId),
                ReferenceBy     = (request.Model.ReferenceById == null) ? null : _context.ReferenceTypes.Find(request.Model.ReferenceById),
                HeardOfUsFrom   = (request.Model.HeardOfUsFromId == null) ? null : _context.HeardOfUsFroms.Find(request.Model.HeardOfUsFromId),
                InscriptionDate = request.Model.InscriptionDate
            };

            customer.CustomerActivations.Add(new CustomerActivation {
                IsActive = true, IsActiveSince = DateTime.Now
            });
            _context.Add(customer);
            await _context.SaveChangesAsync();

            return(Unit.Value);
        }
        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 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 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);
            }
        }
Beispiel #10
0
        public async Task <Unit> Handle(CreateProfilOptionCommand <YearlyIncome> request, CancellationToken cancellationToken)
        {
            _context.Add(new YearlyIncome {
                Name = request.Name
            });

            await _context.SaveChangesAsync(cancellationToken);

            return(Unit.Value);
        }
        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 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 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();
        }
Beispiel #14
0
        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 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();
        }
Beispiel #17
0
        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 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 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 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 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 CreateSessionException(Season season, int year)
        {
            _context.Add(new Session
            {
                Year   = year,
                Season = season
            });

            _context.SaveChanges();

            _mediator.Send(new CreateSessionCommand
            {
                Season = season,
                Year   = year
            }).ShouldThrow(typeof(ValidationException));
        }