コード例 #1
0
        public void Insert()
        {
            //Setup
            Performer performer = new Performer
            {
                FirstName = "SLTEST",
                LastName  = "SLTEST"
            };
            PerformerList performers = new PerformerList();

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



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

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

            //Assert
            performers.Clear();
            performers.Load();
            Assert.AreEqual(originalCount + 1, performers.Count);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        public void Update()
        {
            PerformerList performers = new PerformerList();

            performers.Load();
            Performer performer          = performers.FirstOrDefault(c => c.FirstName == "SLTEST");
            Performer retrievedPerformer = new Performer();

            if (performer != null)
            {
                retrievedPerformer.Id = performer.Id;

                performer.FirstName = "SLTEST1";

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

                retrievedPerformer.LoadById();
            }
            //Assert
            Assert.AreEqual(performer.FirstName, retrievedPerformer.FirstName);
        }
コード例 #4
0
        // GET: api/Performer
        public IEnumerable <Performer> Get()
        {
            PerformerList performers = new PerformerList();

            performers.Load();
            return(performers);
        }
コード例 #5
0
        public void LoadTest()
        {
            PerformerList performers = new PerformerList();

            performers.Load();
            Assert.AreEqual(7, performers.Count);
        }
コード例 #6
0
        public void DeleteTest()
        {
            Performer     performer  = new Performer();
            PerformerList performers = new PerformerList();

            performers.Load();
            performer = performers.FirstOrDefault(c => c.FirstName == "BL Test");

            int results = performer.Delete();

            Assert.IsTrue(results == 1);
        }
コード例 #7
0
        public void Delete()
        {
            //Setup
            PerformerList performers = new PerformerList();

            performers.Load();
            int       originalCount = performers.Count();
            Performer performer     = performers.FirstOrDefault(c => c.FirstName == "SLTEST1");


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

            //Assert
            performers.Clear();
            performers.Load();
            Assert.AreEqual(originalCount - 1, performers.Count);
        }
コード例 #8
0
        public void LoadById()
        {
            Performer     performer  = new Performer();
            PerformerList performers = new PerformerList();

            performers.Load();
            performer = performers.FirstOrDefault(c => c.FirstName == "BL Test");

            Performer newPerformer = new Performer {
                Id = performer.Id
            };

            newPerformer.LoadById();

            Assert.AreEqual(performer.FirstName, newPerformer.FirstName);
        }
コード例 #9
0
        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);
        }
コード例 #10
0
        public void GetOne()
        {
            //Setup
            Performer     performer          = new Performer();
            Performer     retrievedPerformer = new Performer();
            PerformerList performers         = new PerformerList();

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

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

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

                retrievedPerformer = JsonConvert.DeserializeObject <Performer>(result);
            }

            //Assert
            Assert.IsTrue(performer.FirstName == retrievedPerformer.FirstName && !string.IsNullOrEmpty(retrievedPerformer.FirstName));
        }