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);
        }
Пример #2
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
                          );
        }
        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);
        }
        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 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);
        }
Пример #7
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);
        }
        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);
        }
        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);
        }
Пример #10
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);
        }
Пример #11
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);
        }
        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
                          );
        }