コード例 #1
0
        public async Task ShouldCreateContactBeOkHavingProvidedData()
        {
            //Conteggio gli elementi prima della creazione
            var countBefore = Scenario.Contacts.Count;

            //Composizione della request
            var request = new ContactCreateRequest
            {
                Name         = RandomizationUtils.GenerateRandomString(50),
                Token        = RandomizationUtils.GenerateRandomString(50),
                Description  = RandomizationUtils.GenerateRandomString(50),
                Email        = RandomizationUtils.GenerateRandomEmail(),
                Subject      = RandomizationUtils.GenerateRandomString(50),
                AcceptPolicy = true,
            };

            //Invoke del metodo
            var response = await Controller.CreateContact(request);

            //Conteggio gli elementi dopo la creazione
            var countAfter = Scenario.Contacts.Count;

            var lastInsert = Scenario.Contacts.OrderByDescending(x => x.CreationDateTime).FirstOrDefault();
            //Parsing della risposta e assert
            var parsed = ParseExpectedOk <OkResponse>(response);

            Assert.IsTrue(parsed != null &&
                          countAfter == countBefore + 1 &&
                          lastInsert != null &&
                          lastInsert.Name == request.Name &&
                          lastInsert.Description == request.Description &&
                          lastInsert.Email == request.Email &&
                          lastInsert.Subject == request.Subject
                          );
        }
コード例 #2
0
        public async Task ShouldUpdateTeamHolderBeOkHavingProvidedData()
        {
            var existing = Scenario.TeamHolders.FirstOrDefault();
            //Conteggio gli elementi prima della creazione
            var countBefore = Scenario.TeamHolders.Count;

            //Composizione della request
            var request = new TeamHolderCreateRequest
            {
                TeamId      = existing.TeamId,
                ShooterId   = existing.ShooterId,
                Description = RandomizationUtils.GenerateRandomString(5)
            };

            //Invoke del metodo
            var response = await Controller.UpsertTeamHolder(request);

            //Conteggio gli elementi dopo la creazione
            var countAfter = Scenario.TeamHolders.Count;

            //Parsing della risposta e assert
            var parsed = ParseExpectedOk <TeamHolderContract>(response);

            var updatedEntity = Scenario.TeamHolders.FirstOrDefault(x => x.Id == parsed.Data.TeamHolderId);

            Assert.IsNotNull(parsed);
            Assert.AreEqual(countAfter, countBefore);
            Assert.IsTrue(updatedEntity.TeamId == request.TeamId &&
                          updatedEntity.ShooterId == request.ShooterId &&
                          updatedEntity.Description == request.Description
                          );
        }
コード例 #3
0
        public async Task ShouldCreateShooterBeOkAndNotCreatePermissions()
        {
            //Conteggio gli elementi prima della creazione
            var countBefore = Scenario.Permissions.Count;

            //Composizione della request
            var request = new ShooterCreateRequest
            {
                Email     = RandomizationUtils.GenerateRandomEmail(),
                LastName  = RandomizationUtils.GenerateRandomString(10),
                FirstName = RandomizationUtils.GenerateRandomString(10),
                BirthDate = DateTime.Now,
                Username  = RandomizationUtils.GenerateRandomString(10)
            };

            //Invoke del metodo
            var response = await Controller.CreateShooter(request);

            //Conteggio gli elementi dopo la creazione
            var countAfter = Scenario.Permissions.Count;

            //Parsing della risposta e assert
            var parsed = ParseExpectedOk <ShooterContract>(response);

            Assert.IsTrue(parsed != null);
            Assert.AreEqual(countBefore, countAfter);
        }
コード例 #4
0
        public async Task ShouldCreateShooterBeBadRequestWithoutPermission()
        {
            UpdateIdentityUser(GetUserWithoutPermission(new List <Permissions> {
                Permissions.ManageShooters, Permissions.CreateShooters
            }));

            //Conteggio gli elementi prima della creazione
            var countBefore           = Scenario.Shooters.Count;
            var countBeforePermission = Scenario.Permissions.Count;

            //Composizione della request
            var request = new ShooterCreateRequest
            {
                Email     = RandomizationUtils.GenerateRandomEmail(),
                LastName  = RandomizationUtils.GenerateRandomString(10),
                FirstName = RandomizationUtils.GenerateRandomString(10),
                BirthDate = DateTime.Now,
                Username  = RandomizationUtils.GenerateRandomString(10)
            };

            //Invoke del metodo
            var response = await Controller.CreateShooter(request);

            //Conteggio gli elementi dopo la creazione
            var countAfter           = Scenario.Shooters.Count;
            var countAfterPermission = Scenario.Permissions.Count;

            //Parsing della risposta e assert
            var parsed = ParseExpectedBadRequest(response);

            Assert.IsTrue(parsed != null);
            Assert.AreEqual(countBefore, countAfter);
            // because is made by an admin the permissions should be the same
            Assert.AreEqual(countBeforePermission, countAfterPermission);
        }
コード例 #5
0
        public async Task ShouldUpdatePlaceBeNotFoundHavingProvidedWrongId()
        {
            //conteggio esistenti
            var countBefore = Scenario.Places.Count;


            //Composizione della request
            var request = new PlaceUpdateRequest
            {
                PlaceId       = RandomizationUtils.GenerateRandomString(10),
                Name          = RandomizationUtils.GenerateRandomString(50),
                Holder        = RandomizationUtils.GenerateRandomString(15),
                Email         = RandomizationUtils.GenerateRandomEmail(),
                City          = RandomizationUtils.GenerateRandomString(15),
                Region        = RandomizationUtils.GenerateRandomString(15),
                PostalZipCode = RandomizationUtils.GenerateRandomString(15),
                Country       = RandomizationUtils.GenerateRandomString(15)
            };

            //Invoke del metodo
            var response = await Controller.UpdatePlace(request);

            //Parsing della risposta e assert
            var parsed = ParseExpectedNotFound(response);

            //conteggio esistenti
            var countAfter = Scenario.Places.Count;


            Assert.IsTrue(parsed != null &&
                          parsed.Data == null);

            //verifica contatori
            Assert.AreEqual(countBefore, countAfter);
        }
コード例 #6
0
        public void ShouldUpdateUserPasswordBeOkHavingProvidedData()
        {
            //Recupero un user esistente
            var existing = Scenario.Shooters.FirstOrDefault();

            if (existing == null)
            {
                Assert.Inconclusive("User does not exists");
            }

            var oldPassword = existing.Password;

            //Composizione della request
            var request = new UserPasswordUpdateRequest
            {
                UserId   = existing.Id,
                Password = RandomizationUtils.GenerateRandomString(10)
            };

            //Invoke del metodo
            var response = Controller.UpdateUserPassword(request);

            var newPassword = Scenario.Shooters.FirstOrDefault(x => x.Id == existing.Id)?.Password;

            //Parsing della risposta e assert
            var parsed = ParseExpectedOk <BooleanResponse>(response);

            Assert.IsNotNull(newPassword);
            Assert.IsTrue(parsed != null &&
                          oldPassword != newPassword);
        }
コード例 #7
0
        public async Task ShouldCreateShooterAssociationBeBadRequestHaavingProvidedWrongAssociation()
        {
            var existing = Scenario.Shooters.FirstOrDefault();

            //Conteggio gli elementi prima della creazione
            var countBefore = Scenario.ShooterAssociations.Count;

            //Composizione della request
            var request = new ShooterAssociationCreateRequest
            {
                AssociationId    = RandomizationUtils.GenerateRandomString(5),
                ShooterId        = existing.Id,
                RegistrationDate = DateTime.Now,
                Classification   = RandomizationUtils.GenerateRandomString(5),
                Division         = RandomizationUtils.GenerateRandomString(5)
            };

            //Invoke del metodo
            var response = await Controller.UpsertShooterAssociation(request);

            //Conteggio gli elementi dopo la creazione
            var countAfter = Scenario.ShooterAssociations.Count;

            //Parsing della risposta e assert
            var parsed = ParseExpectedBadRequest(response);

            Assert.AreEqual(countBefore, countAfter);
            Assert.IsTrue(parsed != null &&
                          parsed.Data.Count > 0);
        }
コード例 #8
0
        public void ShouldUpdateUserBeUnauthorizedHavingProvidedWrongId()
        {
            //conteggio esistenti
            var countBefore = Scenario.Shooters.Count;

            //Composizione della request
            var request = new UserUpdateRequest
            {
                UserId = RandomizationUtils.GenerateRandomString(10)
            };

            //Invoke del metodo
            var response = Controller.UpdateProfile(request);

            //Parsing della risposta e assert
            var parsed = ParseExpectedUnauthorized(response);

            //conteggio esistenti
            var countAfter = Scenario.Shooters.Count;


            Assert.IsTrue(parsed != null &&
                          parsed.Data == null);

            //verifica contatori
            Assert.AreEqual(countBefore, countAfter);
        }
コード例 #9
0
        public async Task ShouldUpdateTeamBeNotFoundHavingProvidedWrongId()
        {
            //conteggio esistenti
            var countBefore = Scenario.Teams.Count;


            //Composizione della request
            var request = new TeamUpdateRequest
            {
                TeamId = RandomizationUtils.GenerateRandomString(10),
                Name   = RandomizationUtils.GenerateRandomString(50)
            };

            //Invoke del metodo
            var response = await Controller.UpdateTeam(request);

            //Parsing della risposta e assert
            var parsed = ParseExpectedNotFound(response);

            //conteggio esistenti
            var countAfter = Scenario.Teams.Count;


            Assert.IsTrue(parsed != null &&
                          parsed.Data == null);

            //verifica contatori
            Assert.AreEqual(countBefore, countAfter);
        }
コード例 #10
0
        public async Task ShouldUpdateShooterBeNotFoundHavingProvidedWrongId()
        {
            //conteggio esistenti
            var countBefore = Scenario.Shooters.Count;

            //Composizione della request
            var request = new ShooterUpdateRequest
            {
                ShooterId = RandomizationUtils.GenerateRandomString(10),
                Email     = RandomizationUtils.GenerateRandomEmail(),
                LastName  = RandomizationUtils.GenerateRandomString(10),
                FirstName = RandomizationUtils.GenerateRandomString(10),
                BirthDate = DateTime.Now,
                Username  = RandomizationUtils.GenerateRandomString(10)
            };

            //Invoke del metodo
            var response = await Controller.UpdateShooter(request);

            //Parsing della risposta e assert
            var parsed = ParseExpectedNotFound(response);

            //conteggio esistenti
            var countAfter = Scenario.Shooters.Count;


            Assert.IsTrue(parsed != null &&
                          parsed.Data == null);

            //verifica contatori
            Assert.AreEqual(countBefore, countAfter);
        }
コード例 #11
0
        public async Task ShouldUpdatePlaceBeOkHavingProvidedData()
        {
            //Recupero una Place esistente
            var existing = Scenario.Places.FirstOrDefault();

            if (existing == null)
            {
                Assert.Inconclusive("Place does not exists");
            }

            //conteggio esistenti
            var countBefore = Scenario.Places.Count;


            //Composizione della request
            var request = new PlaceUpdateRequest
            {
                PlaceId       = existing.Id,
                Name          = RandomizationUtils.GenerateRandomString(50),
                Holder        = RandomizationUtils.GenerateRandomString(15),
                Phone         = RandomizationUtils.GenerateRandomString(10),
                Email         = RandomizationUtils.GenerateRandomEmail(),
                Address       = RandomizationUtils.GenerateRandomString(15),
                City          = RandomizationUtils.GenerateRandomString(15),
                Region        = RandomizationUtils.GenerateRandomString(15),
                PostalZipCode = RandomizationUtils.GenerateRandomString(15),
                Country       = RandomizationUtils.GenerateRandomString(15)
            };

            //Invoke del metodo
            var response = await Controller.UpdatePlace(request);

            //Parsing della risposta e assert
            var parsed = ParseExpectedOk <PlaceContract>(response);

            //conteggio esistenti
            var countAfter = Scenario.Places.Count;


            Assert.IsTrue(parsed != null &&
                          parsed.Data.Name == request.Name &&
                          parsed.Data.Holder == request.Holder &&
                          parsed.Data.Phone == request.Phone &&
                          parsed.Data.Email == request.Email &&
                          parsed.Data.Address == request.Address &&
                          parsed.Data.City == request.City &&
                          parsed.Data.Region == request.Region &&
                          parsed.Data.PostalZipCode == request.PostalZipCode &&
                          parsed.Data.Country == request.Country);

            //verifica contatori
            Assert.AreEqual(countBefore, countAfter);
        }
コード例 #12
0
        public async Task ShouldUpdateMatchBeOkHavingProvidedData()
        {
            //Recupero una Match esistente
            var existing = Scenario.Matches.FirstOrDefault();

            if (existing == null)
            {
                Assert.Inconclusive("Match does not exists");
            }

            var existingAssociation = Scenario.Associations.FirstOrDefault(x => x.Id != existing.AssociationId);
            var existingPlace       = Scenario.Places.FirstOrDefault(x => x.Id != existing.PlaceId);

            //conteggio esistenti
            var countBefore = Scenario.Matches.Count;


            //Composizione della request
            var request = new MatchUpdateRequest
            {
                MatchId              = existing.Id,
                Name                 = RandomizationUtils.GenerateRandomString(50),
                AssociationId        = existingAssociation.Id,
                PlaceId              = existingPlace.Id,
                MatchDateTimeStart   = DateTime.Now,
                MatchDateTimeEnd     = DateTime.Now.AddDays(1),
                OpenMatch            = !existing.OpenMatch,
                UnifyClassifications = !existing.UnifyClassifications
            };

            //Invoke del metodo
            var response = await Controller.UpdateMatch(request);

            //Parsing della risposta e assert
            var parsed = ParseExpectedOk <MatchContract>(response);

            //conteggio esistenti
            var countAfter = Scenario.Matches.Count;


            Assert.IsTrue(parsed != null &&
                          parsed.Data.Name == request.Name &&
                          parsed.Data.Association.AssociationId == request.AssociationId &&
                          parsed.Data.Place.PlaceId == request.PlaceId &&
                          parsed.Data.MatchDateTimeStart == request.MatchDateTimeStart &&
                          parsed.Data.MatchDateTimeEnd == request.MatchDateTimeEnd &&
                          parsed.Data.OpenMatch == request.OpenMatch &&
                          parsed.Data.UnifyClassifications == request.UnifyClassifications);

            //verifica contatori
            Assert.AreEqual(countBefore, countAfter);
        }
コード例 #13
0
        public async Task ShouldUpdatePlaceBeBadRequestOnNameZipAndDuplicate()
        {
            //utente corrente
            var user = GetIdentityUser();

            //Recupero place esistente
            var existing = Scenario.Places.FirstOrDefault();

            if (existing == null)
            {
                Assert.Inconclusive("First place is invalid");
            }

            //Recupero place esistente
            var anotherExisting = Scenario.Places.FirstOrDefault(x => x.Id != existing.Id);

            if (anotherExisting == null)
            {
                Assert.Inconclusive("Second place is invalid");
            }

            //Conteggio gli elementi prima della creazione
            var countBefore = Scenario.Places.Count;

            //Composizione della request
            var request = new PlaceUpdateRequest
            {
                PlaceId       = existing.Id,
                Name          = anotherExisting.Name,
                PostalZipCode = anotherExisting.PostalZipCode,
                Holder        = RandomizationUtils.GenerateRandomString(15),
                Email         = RandomizationUtils.GenerateRandomEmail(),
                City          = RandomizationUtils.GenerateRandomString(15),
                Region        = RandomizationUtils.GenerateRandomString(15),
                Country       = RandomizationUtils.GenerateRandomString(15)
            };

            //Invoke del metodo
            var response = await Controller.UpdatePlace(request);

            //Conteggio gli elementi dopo la creazione
            var countAfter = Scenario.Places.Count;

            //Parsing della risposta e assert
            var parsed = ParseExpectedBadRequest(response);

            Assert.IsTrue(parsed != null &&
                          parsed.Data.Any());

            //verifica contatori
            Assert.AreEqual(countBefore, countAfter);
        }
コード例 #14
0
        public async Task ShouldUpdateShooterBeOkHavingProvidedData()
        {
            //Recupero una Shooter esistente
            var existing = Scenario.Shooters.FirstOrDefault();

            if (existing == null)
            {
                Assert.Inconclusive("Shooter does not exists");
            }

            //conteggio esistenti
            var countBefore = Scenario.Shooters.Count;


            //Composizione della request
            var request = new ShooterUpdateRequest
            {
                ShooterId                    = existing.Id,
                Email                        = RandomizationUtils.GenerateRandomEmail(),
                LastName                     = RandomizationUtils.GenerateRandomString(10),
                FirstName                    = RandomizationUtils.GenerateRandomString(10),
                BirthDate                    = DateTime.Now,
                Username                     = RandomizationUtils.GenerateRandomString(10),
                FirearmsLicence              = RandomizationUtils.GenerateRandomString(10),
                FirearmsLicenceExpireDate    = DateTime.Now,
                MedicalExaminationExpireDate = DateTime.Now
            };

            //Invoke del metodo
            var response = await Controller.UpdateShooter(request);

            //Parsing della risposta e assert
            var parsed = ParseExpectedOk <ShooterContract>(response);

            //conteggio esistenti
            var countAfter = Scenario.Shooters.Count;


            Assert.IsTrue(parsed != null &&
                          parsed.Data.Email == request.Email &&
                          parsed.Data.LastName == request.LastName &&
                          parsed.Data.FirstName == request.FirstName &&
                          parsed.Data.BirthDate == request.BirthDate &&
                          parsed.Data.FirearmsLicence == request.FirearmsLicence &&
                          parsed.Data.FirearmsLicenceExpireDate == request.FirearmsLicenceExpireDate &&
                          parsed.Data.MedicalExaminationExpireDate == request.MedicalExaminationExpireDate &&
                          parsed.Data.Username == request.Username);

            //verifica contatori
            Assert.AreEqual(countBefore, countAfter);
        }
コード例 #15
0
        public async Task ShouldCreateShooterAssociationInfoBeOkHavingProvidedData()
        {
            var shooterIds = Scenario.ShooterAssociationInfos.Select(x => x.ShooterId).ToList();
            var existing   = Scenario.Shooters.FirstOrDefault(x => !shooterIds.Contains(x.Id));

            if (existing == null)
            {
                Assert.Inconclusive("No shooter without association exists");
            }
            //Conteggio gli elementi prima della creazione
            var countBefore = Scenario.ShooterAssociationInfos.Count;

            var existingAssociation = Scenario.Associations.FirstOrDefault();

            //Composizione della request
            var request = new ShooterAssociationInfoCreateRequest
            {
                AssociationId    = existingAssociation.Id,
                ShooterId        = existing.Id,
                SafetyOfficier   = true,
                RegistrationDate = RandomizationUtils.GetRandomDate(),
                CardNumber       = RandomizationUtils.GenerateRandomString(5),
                Categories       = new List <string> {
                    existingAssociation.Categories.FirstOrDefault()
                }
            };

            //Invoke del metodo
            var response = await Controller.CreateShooterAssociationInfo(request);

            //Conteggio gli elementi dopo la creazione
            var countAfter = Scenario.ShooterAssociationInfos.Count;

            //Parsing della risposta e assert
            var parsed = ParseExpectedOk <ShooterAssociationInfoContract>(response);

            Assert.IsTrue(parsed != null &&
                          countAfter == countBefore + 1 &&
                          parsed != null &&
                          parsed.Data.Association.AssociationId == request.AssociationId &&
                          parsed.Data.Shooter.ShooterId == request.ShooterId &&
                          parsed.Data.RegistrationDate == request.RegistrationDate &&
                          parsed.Data.SafetyOfficier == request.SafetyOfficier &&
                          parsed.Data.CardNumber == request.CardNumber &&
                          parsed.Data.Categories.All(x => request.Categories.Contains(x))
                          );
        }
コード例 #16
0
        public async Task ShouldUpdateShooterBeBadRequestHavingProvidedSameFirearmsLicence()
        {
            //conteggio esistenti
            var countBefore = Scenario.Shooters.Count;
            //Recupero una Shooter esistente
            var existing = Scenario.Shooters.FirstOrDefault();

            if (existing == null)
            {
                Assert.Inconclusive("Shooter does not exists");
            }

            //Recupero una Shooter esistente
            var existingToUpdate = Scenario.Shooters.FirstOrDefault(x => x.Id != existing.Id);

            if (existing == null)
            {
                Assert.Inconclusive("Shooter does not exists");
            }

            //Composizione della request
            var request = new ShooterUpdateRequest
            {
                ShooterId       = existingToUpdate.Id,
                FirearmsLicence = existing.FirearmsLicence,
                Email           = RandomizationUtils.GenerateRandomEmail(),
                LastName        = RandomizationUtils.GenerateRandomString(10),
                FirstName       = RandomizationUtils.GenerateRandomString(10),
                BirthDate       = DateTime.Now,
                Username        = RandomizationUtils.GenerateRandomString(10)
            };

            //Invoke del metodo
            var response = await Controller.UpdateShooter(request);

            //Parsing della risposta e assert
            var parsed = ParseExpectedBadRequest(response);

            //conteggio esistenti
            var countAfter = Scenario.Shooters.Count;

            Assert.IsNotNull(parsed);
            Assert.IsTrue(parsed.Data.Any());

            //verifica contatori
            Assert.AreEqual(countBefore, countAfter);
        }
        public async Task ShouldCreateShooterTeamPaymentBeOkHavingProvidedData()
        {
            var shooterIds = Scenario.ShooterTeamPayments.Select(x => x.ShooterId).ToList();
            var existing   = Scenario.Shooters.FirstOrDefault(x => !shooterIds.Contains(x.Id));

            if (existing == null)
            {
                Assert.Inconclusive("No shooter team payment without association exists");
            }
            //Conteggio gli elementi prima della creazione
            var countBefore = Scenario.ShooterTeamPayments.Count;

            var existingTeam = Scenario.Teams.FirstOrDefault();

            //Composizione della request
            var request = new ShooterTeamPaymentCreateRequest
            {
                TeamId          = existingTeam.Id,
                ShooterId       = existing.Id,
                Reason          = RandomizationUtils.GenerateRandomString(15),
                Amount          = 1,
                PaymentDateTime = RandomizationUtils.GetRandomDate()
            };

            //Invoke del metodo
            var response = await Controller.CreateShooterTeamPayment(request);

            //Conteggio gli elementi dopo la creazione
            var countAfter = Scenario.ShooterTeamPayments.Count;

            //Parsing della risposta e assert
            var parsed = ParseExpectedOk <ShooterTeamPaymentContract>(response);

            var updatedEntity = Scenario.ShooterTeamPayments.FirstOrDefault(x => x.Id == parsed.Data.ShooterTeamPaymentId);

            Assert.IsTrue(parsed != null &&
                          countAfter == countBefore + 1 &&
                          updatedEntity.TeamId == request.TeamId &&
                          updatedEntity.ShooterId == request.ShooterId &&
                          updatedEntity.Amount == request.Amount &&
                          updatedEntity.Reason == request.Reason &&
                          updatedEntity.PaymentDateTime == request.PaymentDateTime &&
                          updatedEntity.ExpireDateTime == request.ExpireDateTime &&
                          updatedEntity.NotifyExpiration == request.NotifyExpiration
                          );
        }
        public async Task ShouldUpdateShooterTeamPaymentBeOkHavingProvidedData()
        {
            var existing = Scenario.ShooterTeamPayments.FirstOrDefault();

            if (existing == null)
            {
                Assert.Inconclusive("No shooter team payment exists");
            }
            //Conteggio gli elementi prima della creazione
            var countBefore = Scenario.ShooterTeamPayments.Count;


            //Composizione della request
            var request = new ShooterTeamPaymentUpdateRequest
            {
                ShooterTeamPaymentId = existing.Id,
                TeamId          = existing.TeamId,
                ShooterId       = existing.ShooterId,
                Reason          = RandomizationUtils.GenerateRandomString(5),
                Amount          = 1,
                PaymentDateTime = existing.PaymentDateTime
            };

            //Invoke del metodo
            var response = await Controller.UpdateShooterTeamPayment(request);

            //Conteggio gli elementi dopo la creazione
            var countAfter = Scenario.ShooterTeamPayments.Count;

            //Parsing della risposta e assert
            var parsed = ParseExpectedOk <ShooterTeamPaymentContract>(response);

            var updatedEntity = Scenario.ShooterTeamPayments.FirstOrDefault(x => x.Id == parsed.Data.ShooterTeamPaymentId);

            Assert.IsNotNull(parsed);
            Assert.AreEqual(countAfter, countBefore);
            Assert.IsTrue(updatedEntity.TeamId == request.TeamId &&
                          updatedEntity.ShooterId == request.ShooterId &&
                          updatedEntity.Reason == request.Reason &&
                          updatedEntity.PaymentDateTime == request.PaymentDateTime &&
                          updatedEntity.Amount == request.Amount &&
                          updatedEntity.ExpireDateTime == request.ExpireDateTime &&
                          updatedEntity.NotifyExpiration == request.NotifyExpiration
                          );
        }
コード例 #19
0
        public void ShouldUpdateUserPasswordBeUnauthorizedHavingProvidedWrongId()
        {
            //Composizione della request
            var request = new UserPasswordUpdateRequest
            {
                UserId   = RandomizationUtils.GenerateRandomString(10),
                Password = RandomizationUtils.GenerateRandomString(10)
            };

            //Invoke del metodo
            var response = Controller.UpdateUserPassword(request);

            //Parsing della risposta e assert
            var parsed = ParseExpectedUnauthorized(response);

            //verifica contatori
            Assert.IsNull(parsed.Data);
        }
コード例 #20
0
        public async Task ShouldCreateShooterAssociationInfoBeBadRequestHavingProvidedWrongCategories()
        {
            var shooterIds = Scenario.ShooterAssociationInfos.Select(x => x.ShooterId).ToList();
            var existing   = Scenario.Shooters.FirstOrDefault(x => !shooterIds.Contains(x.Id));

            if (existing == null)
            {
                Assert.Inconclusive("No shooter without association exists");
            }
            //Conteggio gli elementi prima della creazione
            var countBefore = Scenario.ShooterAssociationInfos.Count;

            var existingAssociation = Scenario.Associations.FirstOrDefault();

            //Composizione della request
            var request = new ShooterAssociationInfoCreateRequest
            {
                AssociationId  = existingAssociation.Id,
                ShooterId      = existing.Id,
                SafetyOfficier = false,
                CardNumber     = RandomizationUtils.GenerateRandomString(5),
                Categories     = new List <string> {
                    RandomizationUtils.GenerateRandomString(5)
                }
            };

            //Invoke del metodo
            var response = await Controller.CreateShooterAssociationInfo(request);

            //Conteggio gli elementi dopo la creazione
            var countAfter = Scenario.ShooterAssociationInfos.Count;

            //Parsing della risposta e assert
            var parsed = ParseExpectedBadRequest(response);


            Assert.AreEqual(countBefore, countAfter);
            Assert.IsTrue(parsed != null &&
                          // the old one should be closed with end date
                          parsed.Data.Any()
                          );
        }
コード例 #21
0
        public void ShouldUpdateUserBeOkHavingProvidedData()
        {
            //Recupero un user esistente
            var existing = GetIdentityUser();

            //conteggio esistenti
            var countBefore = Scenario.Shooters.Count;


            //Composizione della request
            var request = new UserUpdateRequest
            {
                UserId    = existing.Id,
                Username  = RandomizationUtils.GenerateRandomString(10),
                FirstName = RandomizationUtils.GenerateRandomString(10),
                LastName  = RandomizationUtils.GenerateRandomString(10),
                Email     = RandomizationUtils.GenerateRandomEmail(),
                BirthDate = DateTime.Now
            };

            //Invoke del metodo
            var response = Controller.UpdateProfile(request);

            //Parsing della risposta e assert
            var parsed = ParseExpectedOk <ShooterContract>(response);

            //conteggio esistenti
            var countAfter = Scenario.Shooters.Count;


            Assert.IsTrue(parsed != null &&
                          parsed.Data.ShooterId == request.UserId &&
                          parsed.Data.FirstName == request.FirstName &&
                          parsed.Data.LastName == request.LastName &&
                          parsed.Data.Username == request.Username &&
                          parsed.Data.Email == request.Email &&
                          parsed.Data.BirthDate == request.BirthDate);

            //verifica contatori
            Assert.AreEqual(countBefore, countAfter);
        }
コード例 #22
0
        public async Task ShouldUpdateShooterAssociationInfoBeOkHavingProvidedData()
        {
            var existing = Scenario.ShooterAssociationInfos.FirstOrDefault();
            //Conteggio gli elementi prima della creazione
            var countBefore = Scenario.ShooterAssociationInfos.Count;

            var existingAssociation = Scenario.Associations.FirstOrDefault(x => x.Id == existing.AssociationId);

            //Composizione della request
            var request = new ShooterAssociationInfoUpdateRequest
            {
                ShooterAssociationInfoId = existing.Id,
                AssociationId            = existing.AssociationId,
                ShooterId        = existing.ShooterId,
                RegistrationDate = RandomizationUtils.GetRandomDate(),
                SafetyOfficier   = !existing.SafetyOfficier,
                CardNumber       = RandomizationUtils.GenerateRandomString(5),
                Categories       = new List <string> {
                    existingAssociation.Categories.LastOrDefault()
                }
            };

            //Invoke del metodo
            var response = await Controller.UpdateShooterAssociationInfo(request);

            //Conteggio gli elementi dopo la creazione
            var countAfter = Scenario.ShooterAssociationInfos.Count;

            //Parsing della risposta e assert
            var parsed = ParseExpectedOk <ShooterAssociationInfoContract>(response);

            Assert.AreEqual(countBefore, countAfter);
            Assert.IsTrue(parsed != null &&
                          parsed.Data.Association.AssociationId == request.AssociationId &&
                          parsed.Data.Shooter.ShooterId == request.ShooterId &&
                          parsed.Data.RegistrationDate == request.RegistrationDate &&
                          parsed.Data.SafetyOfficier == request.SafetyOfficier &&
                          parsed.Data.CardNumber == request.CardNumber &&
                          parsed.Data.Categories.All(x => request.Categories.Contains(x))
                          );
        }
コード例 #23
0
        public async Task ShouldCreatePlaceBeOkHavingProvidedData()
        {
            //Conteggio gli elementi prima della creazione
            var countBefore = Scenario.Places.Count;

            //Composizione della request
            var request = new PlaceCreateRequest
            {
                Name          = RandomizationUtils.GenerateRandomString(50),
                Holder        = RandomizationUtils.GenerateRandomString(15),
                Phone         = RandomizationUtils.GenerateRandomString(10),
                Email         = RandomizationUtils.GenerateRandomEmail(),
                Address       = RandomizationUtils.GenerateRandomString(15),
                City          = RandomizationUtils.GenerateRandomString(15),
                Region        = RandomizationUtils.GenerateRandomString(15),
                PostalZipCode = RandomizationUtils.GenerateRandomString(15),
                Country       = RandomizationUtils.GenerateRandomString(15),
            };

            //Invoke del metodo
            var response = await Controller.CreatePlace(request);

            //Conteggio gli elementi dopo la creazione
            var countAfter = Scenario.Places.Count;

            //Parsing della risposta e assert
            var parsed = ParseExpectedOk <PlaceContract>(response);

            Assert.IsTrue(parsed != null &&
                          countAfter == countBefore + 1 &&
                          parsed.Data.Name == request.Name &&
                          parsed.Data.Holder == request.Holder &&
                          parsed.Data.Phone == request.Phone &&
                          parsed.Data.Email == request.Email &&
                          parsed.Data.Address == request.Address &&
                          parsed.Data.City == request.City &&
                          parsed.Data.Region == request.Region &&
                          parsed.Data.PostalZipCode == request.PostalZipCode &&
                          parsed.Data.Country == request.Country);
        }
コード例 #24
0
        public async Task ShouldCreateTeamHolderBeOkHavingProvidedData()
        {
            var shooterIds = Scenario.TeamHolders.Select(x => x.ShooterId).ToList();
            var existing   = Scenario.Shooters.FirstOrDefault(x => !shooterIds.Contains(x.Id));

            if (existing == null)
            {
                Assert.Inconclusive("No shooter without association exists");
            }
            //Conteggio gli elementi prima della creazione
            var countBefore = Scenario.TeamHolders.Count;

            var existingTeam = Scenario.Teams.FirstOrDefault();

            //Composizione della request
            var request = new TeamHolderCreateRequest
            {
                TeamId      = existingTeam.Id,
                ShooterId   = existing.Id,
                Description = RandomizationUtils.GenerateRandomString(15)
            };

            //Invoke del metodo
            var response = await Controller.UpsertTeamHolder(request);

            //Conteggio gli elementi dopo la creazione
            var countAfter = Scenario.TeamHolders.Count;

            //Parsing della risposta e assert
            var parsed = ParseExpectedOk <TeamHolderContract>(response);

            var updatedEntity = Scenario.TeamHolders.FirstOrDefault(x => x.Id == parsed.Data.TeamHolderId);

            Assert.IsTrue(parsed != null &&
                          countAfter == countBefore + 1 &&
                          updatedEntity.TeamId == request.TeamId &&
                          updatedEntity.ShooterId == request.ShooterId &&
                          updatedEntity.Description == request.Description
                          );
        }
コード例 #25
0
        public async Task ShouldCreateMatchBeOkHavingProvidedData()
        {
            //Conteggio gli elementi prima della creazione
            var countBefore = Scenario.Matches.Count;

            var existingAssociation = Scenario.Associations.FirstOrDefault();
            var existingPlace       = Scenario.Places.FirstOrDefault();

            //Composizione della request
            var request = new MatchCreateRequest
            {
                Name                 = RandomizationUtils.GenerateRandomString(50),
                AssociationId        = existingAssociation.Id,
                PlaceId              = existingPlace.Id,
                MatchDateTimeStart   = DateTime.Now,
                MatchDateTimeEnd     = DateTime.Now.AddDays(1),
                OpenMatch            = true,
                UnifyClassifications = true
            };

            //Invoke del metodo
            var response = await Controller.CreateMatch(request);

            //Conteggio gli elementi dopo la creazione
            var countAfter = Scenario.Matches.Count;

            //Parsing della risposta e assert
            var parsed = ParseExpectedOk <MatchContract>(response);

            Assert.IsTrue(parsed != null &&
                          countAfter == countBefore + 1 &&
                          parsed.Data.Name == request.Name &&
                          parsed.Data.Association.AssociationId == request.AssociationId &&
                          parsed.Data.Place.PlaceId == request.PlaceId &&
                          parsed.Data.MatchDateTimeStart == request.MatchDateTimeStart &&
                          parsed.Data.MatchDateTimeEnd == request.MatchDateTimeEnd &&
                          parsed.Data.OpenMatch == request.OpenMatch &&
                          parsed.Data.UnifyClassifications == request.UnifyClassifications
                          );
        }
コード例 #26
0
        public async Task ShouldCreateMatchBeBadRequestWithoutPermission()
        {
            UpdateIdentityUser(GetUserWithoutPermission(new List <Permissions> {
                Permissions.ManageMatches, Permissions.CreateMatches
            }));

            //Conteggio gli elementi prima della creazione
            var countBefore           = Scenario.Matches.Count;
            var countBeforePermission = Scenario.Permissions.Count;

            var existingAssociation = Scenario.Associations.FirstOrDefault();
            var existingPlace       = Scenario.Places.FirstOrDefault();

            //Composizione della request
            var request = new MatchCreateRequest
            {
                Name                 = RandomizationUtils.GenerateRandomString(50),
                AssociationId        = existingAssociation.Id,
                PlaceId              = existingPlace.Id,
                MatchDateTimeStart   = DateTime.Now,
                MatchDateTimeEnd     = DateTime.Now.AddDays(1),
                OpenMatch            = true,
                UnifyClassifications = true
            };

            //Invoke del metodo
            var response = await Controller.CreateMatch(request);

            //Conteggio gli elementi dopo la creazione
            var countAfter           = Scenario.Matches.Count;
            var countAfterPermission = Scenario.Permissions.Count;

            //Parsing della risposta e assert
            var parsed = ParseExpectedBadRequest(response);

            Assert.IsTrue(parsed != null);
            Assert.AreEqual(countBefore, countAfter);
            // because is made by an admin the permissions should be the same
            Assert.AreEqual(countBeforePermission, countAfterPermission);
        }
コード例 #27
0
        public async Task ShouldDeleteTeamBeBadNotFoundHavingProvidedWrongId()
        {
            //Conteggio gli elementi prima della cancellazione
            var countBefore = Scenario.Teams.Count;

            //Composizione della request
            var request = new TeamRequest {
                TeamId = RandomizationUtils.GenerateRandomString(10)
            };

            //Invoke del metodo
            var response = await Controller.DeleteTeam(request);

            //Parsing della risposta
            var parsed = ParseExpectedNotFound(response);

            //Conteggio gli elementi dopo la cancellazione
            var countAfter = Scenario.Teams.Count;

            Assert.IsTrue(parsed != null &&
                          parsed.Data == null);
            Assert.AreEqual(countBefore, countAfter);
        }
コード例 #28
0
        public async Task ShouldCreateShooterBeOkHavingProvidedData()
        {
            //Conteggio gli elementi prima della creazione
            var countBefore = Scenario.Shooters.Count;

            //Composizione della request
            var request = new ShooterCreateRequest
            {
                Email                     = RandomizationUtils.GenerateRandomEmail(),
                LastName                  = RandomizationUtils.GenerateRandomString(10),
                FirstName                 = RandomizationUtils.GenerateRandomString(10),
                BirthDate                 = DateTime.Now,
                Username                  = RandomizationUtils.GenerateRandomString(10),
                FirearmsLicence           = RandomizationUtils.GenerateRandomString(10),
                FirearmsLicenceExpireDate = DateTime.Now
            };

            //Invoke del metodo
            var response = await Controller.CreateShooter(request);

            //Conteggio gli elementi dopo la creazione
            var countAfter = Scenario.Shooters.Count;

            //Parsing della risposta e assert
            var parsed = ParseExpectedOk <ShooterContract>(response);

            Assert.IsTrue(parsed != null &&
                          countAfter == countBefore + 1 &&
                          parsed.Data.Email == request.Email &&
                          parsed.Data.LastName == request.LastName &&
                          parsed.Data.FirstName == request.FirstName &&
                          parsed.Data.BirthDate == request.BirthDate &&
                          parsed.Data.Username == request.Username &&
                          parsed.Data.FirearmsLicence == request.FirearmsLicence &&
                          parsed.Data.FirearmsLicenceExpireDate == request.FirearmsLicenceExpireDate
                          );
        }
コード例 #29
0
        public async Task ShouldUpdateTeamBeOkHavingProvidedData()
        {
            //Recupero una Team esistente
            var existing = Scenario.Teams.FirstOrDefault();

            if (existing == null)
            {
                Assert.Inconclusive("Team does not exists");
            }

            //conteggio esistenti
            var countBefore = Scenario.Teams.Count;


            //Composizione della request
            var request = new TeamUpdateRequest
            {
                TeamId = existing.Id,
                Name   = RandomizationUtils.GenerateRandomString(50)
            };

            //Invoke del metodo
            var response = await Controller.UpdateTeam(request);

            //Parsing della risposta e assert
            var parsed = ParseExpectedOk <TeamContract>(response);

            //conteggio esistenti
            var countAfter = Scenario.Teams.Count;


            Assert.IsTrue(parsed != null &&
                          parsed.Data.Name == request.Name);

            //verifica contatori
            Assert.AreEqual(countBefore, countAfter);
        }
コード例 #30
0
        public async Task ShouldUpdateMatchBeNotFoundHavingProvidedWrongId()
        {
            //conteggio esistenti
            var countBefore = Scenario.Matches.Count;

            var existingAssociation = Scenario.Associations.FirstOrDefault();
            var existingPlace       = Scenario.Places.FirstOrDefault();

            //Composizione della request
            var request = new MatchUpdateRequest
            {
                MatchId              = RandomizationUtils.GenerateRandomString(10),
                Name                 = RandomizationUtils.GenerateRandomString(50),
                AssociationId        = existingAssociation.Id,
                PlaceId              = existingPlace.Id,
                MatchDateTimeStart   = DateTime.Now,
                MatchDateTimeEnd     = DateTime.Now.AddDays(1),
                OpenMatch            = false,
                UnifyClassifications = false
            };

            //Invoke del metodo
            var response = await Controller.UpdateMatch(request);

            //Parsing della risposta e assert
            var parsed = ParseExpectedNotFound(response);

            //conteggio esistenti
            var countAfter = Scenario.Matches.Count;


            Assert.IsTrue(parsed != null &&
                          parsed.Data == null);

            //verifica contatori
            Assert.AreEqual(countBefore, countAfter);
        }