Esempio n. 1
0
        public void Update_Person_ResponseIsSuccess()
        {
            //arrange
            var person = TestDomain.CreatePerson(1);

            PersonContext.Persons.AddRange(person);
            PersonContext.SaveChanges();


            using (var client = TestHttpClientFactory.Create())
            {
                var personApiUri = new Uri(client.BaseAddress, $"api/{nameof(Person)}");

                //act
                //change the person properties
                person.FirstName = "John";
                person.LastName  = "Doe";
                person.Age       = 99;
                person.Born      = DateTime.Today.AddYears(-99);

                var response     = client.PutAsJsonAsync(personApiUri, person).Result;
                var returnPerson = response.Content.ReadAsAsync <Person>().Result;

                //assert
                returnPerson.ShouldBeEquivalentTo(person);
                Assert.That(PersonContext.Persons.Any(), Is.True);
                Assert.That(response.IsSuccessStatusCode, Is.True, "response:" + response);
            }
        }
Esempio n. 2
0
        public void Read_Persons_ResponseIsSuccess()
        {
            //arrange
            var persons = new List <Person>();

            for (int i = 1; i <= 10; i++)
            {
                persons.Add(TestDomain.CreatePerson(i));
            }

            PersonContext.Persons.AddRange(persons);
            PersonContext.SaveChanges();

            using (var client = TestHttpClientFactory.Create())
            {
                var personApiUri = new Uri(client.BaseAddress, $"api/{nameof(Person)}/Read");

                //act
                var responseFromGet      = client.GetAsync(personApiUri).Result;
                var returnPersonsFromGet = responseFromGet.Content.ReadAsAsync <List <Person> >().Result;

                //assert
                returnPersonsFromGet.ShouldBeEquivalentTo(persons);
                Assert.That(responseFromGet.IsSuccessStatusCode, Is.True, "response:" + responseFromGet);
            }
        }
Esempio n. 3
0
        public void Create_Person_ResponseIsSuccess()
        {
            var person = TestDomain.CreatePerson(100);

            //arrange
            using (var client = TestHttpClientFactory.Create())
            {
                var personApiUri = new Uri(client.BaseAddress, $"api/{nameof(Person)}/Create");

                //act
                var response     = client.PostAsJsonAsync(personApiUri, person).Result;
                var returnPerson = response.Content.ReadAsAsync <Person>().Result;

                //assert
                returnPerson.ShouldBeEquivalentTo(person);
                Assert.That(response.IsSuccessStatusCode, Is.True, "response:" + response);
                Assert.That(returnPerson.Id, Is.GreaterThan(0));
            }
        }
Esempio n. 4
0
        public void Delete_Person_ResponseIsSuccess()
        {
            //arrange
            var person = TestDomain.CreatePerson(1);

            PersonContext.Persons.Add(person);
            PersonContext.SaveChanges();

            using (var client = TestHttpClientFactory.Create())
            {
                var personApiGetByIdUri = new Uri(client.BaseAddress, $"api/{nameof(Person)}/delete/{person.Id}");

                //act
                var response = client.DeleteAsync(personApiGetByIdUri).Result;

                //assert
                Assert.That(PersonContext.Persons.Any(), Is.False);
                Assert.That(response.IsSuccessStatusCode, Is.True, "response:" + response);
            }
        }
Esempio n. 5
0
        public void Read_Person_ResponseIsSuccess()
        {
            //arrange
            var person = TestDomain.CreatePerson(100);

            PersonContext.Persons.AddRange(person);
            PersonContext.SaveChanges();

            using (var client = TestHttpClientFactory.Create())
            {
                var personApiGetByIdUri = new Uri(client.BaseAddress, $"api/{nameof(Person)}/Read/{person.Id}");

                //act
                var responseFromGet     = client.GetAsync(personApiGetByIdUri).Result;
                var returnPersonFromGet = responseFromGet.Content.ReadAsAsync <Person>().Result;

                //assert
                returnPersonFromGet.ShouldBeEquivalentTo(person);
                Assert.That(responseFromGet.IsSuccessStatusCode, Is.True, "response:" + responseFromGet);
            }
        }
        public void Seed()
        {
            var names =
                "Olga Roberson, Bob Simpson,Jackie Fletcher,Travis Pittman,Vera Rivera, Erin Turner,Leona Davis, Ralph Greene,Roger Ballard, Lula Rodgers,Raul Pierce, Doris Vaughn," +
                "Norma Hanson, Bernice Haynes,Marie Saunders, Deborah Roy,Cindy Smith, Christopher Powell,Drew Santos, Ruby Burton," +
                "Benny Phillips, Harriet Owens,Jay Carson, Doreen Copeland,Stacy Crawford, Jerald Sanders,Jennie Townsend, Patti Palmer," +
                "Tracy Hayes, Bobbie Christensen,Ignacio Alvarez, Colin Strickland,Kristy Nunez, Anna Holloway,Sherri Wade, Beth Curtis," +
                "Laura Potter, Tiffany Franklin,Lorenzo Cunningham, Calvin Brewer,Jean Young, Lionel Adkins,Gregory Pope, Miriam Hardy," +
                "Donnie Robinson, Mike Lowe,Lawrence Higgins, Sidney Reid,Candice Garner, Lois Ross,Marjorie Maldonado, Terri Ramirez,Ira West," +
                "Elias Waters,Charles Malone, Irene Hicks,Danny Hampton, Emma Reeves,Rose Riley, Elijah Colon,Grant Lyons," +
                "Sylvia Payne,Teresa Evans, Jessie Keller,Shannon Nichols, Steven Mullins,Terrell Parsons, Alma Morris,Rebecca Norton, Tanya Burns," +
                "Chris Washington, Keith Abbott,Lyle Mclaughlin, Lela Hart,Tony Rodriguez, Marc Cox,Erica Bishop, Mathew Campbell," +
                "Dan Elliott, Eddie Jones,Joseph Hunter, Courtney Webb,Jody Watson, Ismael Curry,Margie Wright, Bernadette Diaz,Salvatore Phelps," +
                "Kim Sandoval,Marilyn Guzman, Ollie Williamson,Megan Mcdaniel, Jerome Conner,Blanche Sims, Irvin Love,Ramona Lloyd," +
                "Evelyn Mason,Justin Collins, Sherman Green,Darrin Marsh, Tommy Becker";

            foreach (var fullName in names.Split(','))
            {
                Persons.Add(TestDomain.CreatePerson(fullName.Trim()));
            }
        }