public void Insert()
        {
            //Setup
            Gender gender = new Gender
            {
                Description = "SLTEST"
            };
            GenderList genders = new GenderList();

            genders.Load();
            int originalCount = genders.Count();



            //Act
            HttpClient client = InitializeClient();
            //Serialize a gender object that we're trying to insert
            string serializedGender = JsonConvert.SerializeObject(gender);
            var    content          = new StringContent(serializedGender);

            content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
            HttpResponseMessage response = client.PostAsync("Gender", content).Result;

            //Assert
            genders.Clear();
            genders.Load();
            Assert.AreEqual(originalCount + 1, genders.Count);
        }
Exemplo n.º 2
0
        // GET: api/Gender
        public IEnumerable <Gender> Get()
        {
            GenderList genders = new GenderList();

            genders.Load();
            return(genders);
        }
Exemplo n.º 3
0
        private void Rebind()
        {
            switch (screenmode)
            {
            case ScreenMode.Location:
                locations = new LocationList();
                locations.Load();

                // Bind to the datagrid
                cboAttribute.ItemsSource = null;
                cboAttribute.ItemsSource = locations;
                break;

            case ScreenMode.Gender:

                genders = new GenderList();
                genders.Load();
                cboAttribute.ItemsSource = null;
                cboAttribute.ItemsSource = genders;
                break;

            case ScreenMode.Race:

                races = new RaceList();
                races.Load();
                cboAttribute.ItemsSource = null;
                cboAttribute.ItemsSource = races;
                break;
            }

            cboAttribute.DisplayMemberPath = "Description";
            cboAttribute.SelectedValuePath = "Id";
        }
Exemplo n.º 4
0
        public void LoadTest()
        {
            GenderList genders = new GenderList();

            genders.Load();
            Assert.AreEqual(3, genders.Count);
        }
        public void Update()
        {
            GenderList genders = new GenderList();

            genders.Load();
            Gender gender          = genders.FirstOrDefault(g => g.Description == "SLTEST");
            Gender retrievedGender = new Gender();

            if (gender != null)
            {
                retrievedGender.Id = gender.Id;

                gender.Description = "SLTEST1";

                //Act
                HttpClient client = InitializeClient();
                //Serialize a question object that we're trying to insert
                string serializedGender = JsonConvert.SerializeObject(gender);
                var    content          = new StringContent(serializedGender);
                content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
                HttpResponseMessage response = client.PutAsync("Gender/" + gender.Id, content).Result;

                retrievedGender.LoadById();
            }
            //Assert
            Assert.AreEqual(gender.Description, retrievedGender.Description);
        }
Exemplo n.º 6
0
        public void DeleteTest()
        {
            Gender     gender  = new Gender();
            GenderList genders = new GenderList();

            genders.Load();
            gender = genders.FirstOrDefault(g => g.Description == "Update");

            int results = gender.Delete();

            Assert.IsTrue(results == 1);
        }
        public void Delete()
        {
            //Setup
            GenderList genders = new GenderList();

            genders.Load();
            int    originalCount = genders.Count();
            Gender gender        = genders.FirstOrDefault(g => g.Description == "SLTEST1");


            //Act
            if (gender != null)
            {
                HttpClient          client   = InitializeClient();
                HttpResponseMessage response = client.DeleteAsync("Gender/" + gender.Id).Result;
            }

            //Assert
            genders.Clear();
            genders.Load();
            Assert.AreEqual(originalCount - 1, genders.Count);
        }
Exemplo n.º 8
0
        public void LoadById()
        {
            Gender     gender  = new Gender();
            GenderList genders = new GenderList();

            genders.Load();
            gender = genders.FirstOrDefault(g => g.Description == "Update");

            Gender newGender = new Gender {
                Id = gender.Id
            };

            newGender.LoadById();

            Assert.AreEqual(gender.Description, newGender.Description);
        }
        public void GetOne()
        {
            //Setup
            Gender     gender          = new Gender();
            Gender     retrievedGender = new Gender();
            GenderList genders         = new GenderList();

            genders.Load();
            gender = genders.FirstOrDefault(g => g.Description == "Male");

            //Act
            if (gender != null)
            {
                HttpClient          client   = InitializeClient();
                HttpResponseMessage response = client.GetAsync("Gender/" + gender.Id).Result;

                string result = response.Content.ReadAsStringAsync().Result;

                retrievedGender = JsonConvert.DeserializeObject <Gender>(result);
            }

            //Assert
            Assert.IsTrue(gender.Description == retrievedGender.Description && !string.IsNullOrEmpty(retrievedGender.Description));
        }