public void Insert()
        {
            //Setup
            Instrument instrument = new Instrument
            {
                Description = "SLTEST"
            };
            InstrumentList instruments = new InstrumentList();

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



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

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

            //Assert
            instruments.Clear();
            instruments.Load();
            Assert.AreEqual(originalCount + 1, instruments.Count);
        }
        public void UpdateTest()
        {
            //Load up Guids
            PerformerList performers = new PerformerList();
            Performer     performer  = new Performer();

            performers.Load();
            performer = performers.FirstOrDefault(p => p.FirstName == "Hunter");

            GroupList groups = new GroupList();
            Group     group  = new Group();

            groups.Load();
            group = groups.FirstOrDefault(c => c.Name == "Jazz Ensemble");

            InstrumentList instruments = new InstrumentList();
            Instrument     instrument  = new Instrument();

            instruments.Load();
            instrument = instruments.FirstOrDefault(c => c.Description == "Euphonium");

            GroupMember     groupMember  = new GroupMember();
            GroupMemberList groupMembers = new GroupMemberList();

            groupMembers.Load();
            groupMember           = groupMembers.FirstOrDefault(p => p.GroupId == group.Id && p.PerformerId == performer.Id);
            groupMember.StartDate = Convert.ToDateTime("04/24/3000");
            groupMember.EndDate   = Convert.ToDateTime("04/25/3000");

            groupMember.Instrument = instrument.Id;
            int results = groupMember.Update();

            Assert.IsTrue(results == 1);
        }
        public void Update()
        {
            InstrumentList instruments = new InstrumentList();

            instruments.Load();
            Instrument instrument          = instruments.FirstOrDefault(ct => ct.Description == "SLTEST");
            Instrument retrievedInstrument = new Instrument();

            if (instrument != null)
            {
                retrievedInstrument.Id = instrument.Id;

                instrument.Description = "SLTEST1";

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

                retrievedInstrument.LoadById();
            }
            //Assert
            Assert.AreEqual(instrument.Description, retrievedInstrument.Description);
        }
        // GET: api/Instrument
        public IEnumerable <Instrument> Get()
        {
            InstrumentList instruments = new InstrumentList();

            instruments.Load();
            return(instruments);
        }
        public void LoadTest()
        {
            InstrumentList instruments = new InstrumentList();

            instruments.Load();
            Assert.AreEqual(6, instruments.Count);
        }
        public void DeleteTest()
        {
            Instrument     instrument  = new Instrument();
            InstrumentList instruments = new InstrumentList();

            instruments.Load();
            instrument = instruments.FirstOrDefault(i => i.Description == "Update");

            int results = instrument.Delete();

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

            instruments.Load();
            int        originalCount = instruments.Count();
            Instrument instrument    = instruments.FirstOrDefault(ct => ct.Description == "SLTEST1");


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

            //Assert
            instruments.Clear();
            instruments.Load();
            Assert.AreEqual(originalCount - 1, instruments.Count);
        }
        public void LoadById()
        {
            Instrument     instrument  = new Instrument();
            InstrumentList instruments = new InstrumentList();

            instruments.Load();
            instrument = instruments.FirstOrDefault(i => i.Description == "Update");

            Instrument newInstrument = new Instrument {
                Id = instrument.Id
            };

            newInstrument.LoadById();

            Assert.AreEqual(instrument.Description, newInstrument.Description);
        }
        public void LoadById()
        {
            //Load up Guids
            PerformerList performers = new PerformerList();
            Performer     performer  = new Performer();

            performers.Load();
            performer = performers.FirstOrDefault(p => p.FirstName == "Hunter");

            GroupList groups = new GroupList();
            Group     group  = new Group();

            groups.Load();
            group = groups.FirstOrDefault(c => c.Name == "Jazz Ensemble");

            InstrumentList instruments = new InstrumentList();
            Instrument     instrument  = new Instrument();

            instruments.Load();
            instrument = instruments.FirstOrDefault(c => c.Description == "Euphonium");

            GroupMember     groupMember  = new GroupMember();
            GroupMemberList groupMembers = new GroupMemberList();

            groupMembers.Load();
            groupMember           = groupMembers.FirstOrDefault(p => p.GroupId == group.Id && p.PerformerId == performer.Id);
            groupMember.StartDate = Convert.ToDateTime("04/24/3000");
            groupMember.EndDate   = Convert.ToDateTime("04/25/3000");

            GroupMember newgroupmember = new GroupMember {
                Id = groupMember.Id
            };

            newgroupmember.LoadById();

            Assert.AreEqual(groupMember.Instrument, newgroupmember.Instrument);
        }
        public void GetOne()
        {
            //Setup
            Instrument     instrument          = new Instrument();
            Instrument     retrievedInstrument = new Instrument();
            InstrumentList instruments         = new InstrumentList();

            instruments.Load();
            instrument = instruments.FirstOrDefault(ct => ct.Description == "Saxophone");

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

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

                retrievedInstrument = JsonConvert.DeserializeObject <Instrument>(result);
            }

            //Assert
            Assert.IsTrue(instrument.Description == retrievedInstrument.Description && !string.IsNullOrEmpty(retrievedInstrument.Description));
        }