public void UpdateTest() { //Load up Guids PieceList pieces = new PieceList(); Piece piece = new Piece(); pieces.Load(); piece = pieces.FirstOrDefault(p => p.Name == "Rock Music"); ComposerList composers = new ComposerList(); Composer composer = new Composer(); composers.Load(); composer = composers.FirstOrDefault(c => c.FirstName == "Modest"); ComposerTypeList ctl = new ComposerTypeList(); ComposerType ct = new ComposerType(); ctl.Load(); ct = ctl.FirstOrDefault(c => c.Description == "Composer"); PieceWriter pieceWriter = new PieceWriter(); PieceWriterList pieceWriters = new PieceWriterList(); pieceWriters.Load(); pieceWriter = pieceWriters.FirstOrDefault(p => p.ComposerId == composer.Id && p.PieceId == piece.Id); pieceWriter.ComposerTypeId = ct.Id; int results = pieceWriter.Update(); Assert.IsTrue(results == 1); }
public void Update() { ComposerTypeList composerTypes = new ComposerTypeList(); composerTypes.Load(); ComposerType composerType = composerTypes.FirstOrDefault(ct => ct.Description == "SLTEST"); ComposerType retrievedComposerType = new ComposerType(); if (composerType != null) { retrievedComposerType.Id = composerType.Id; composerType.Description = "SLTEST1"; //Act HttpClient client = InitializeClient(); //Serialize a question object that we're trying to insert string serializedComposerType = JsonConvert.SerializeObject(composerType); var content = new StringContent(serializedComposerType); content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json"); HttpResponseMessage response = client.PutAsync("ComposerType/" + composerType.Id, content).Result; retrievedComposerType.LoadById(); } //Assert Assert.AreEqual(composerType.Description, retrievedComposerType.Description); }
public void Insert() { //Setup ComposerType composerType = new ComposerType { Description = "SLTEST" }; ComposerTypeList composerTypes = new ComposerTypeList(); composerTypes.Load(); int originalCount = composerTypes.Count(); //Act HttpClient client = InitializeClient(); //Serialize a composerType object that we're trying to insert string serializedComposerType = JsonConvert.SerializeObject(composerType); var content = new StringContent(serializedComposerType); content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json"); HttpResponseMessage response = client.PostAsync("ComposerType", content).Result; //Assert composerTypes.Clear(); composerTypes.Load(); Assert.AreEqual(originalCount + 1, composerTypes.Count); }
// GET: api/ComposerType/5 public ComposerType Get(Guid id) { ComposerType composerType = new ComposerType { Id = id }; composerType.LoadById(); return(composerType); }
public void InsertTest() { ComposerType composerType = new ComposerType(); composerType.Description = "Test"; int results = composerType.Insert(); Assert.IsTrue(results == 1); }
public void DeleteTest() { ComposerType composerType = new ComposerType(); ComposerTypeList composerTypes = new ComposerTypeList(); composerTypes.Load(); composerType = composerTypes.FirstOrDefault(c => c.Description == "Update"); int results = composerType.Delete(); Assert.IsTrue(results == 1); }
public void Insert() { //Setup ComposerList cl = new ComposerList(); Composer composer = new Composer(); cl.Load(); composer = cl.FirstOrDefault(c => c.FirstName == "Alex"); PieceList pl = new PieceList(); Piece piece = new Piece(); pl.Load(); piece = pl.FirstOrDefault(p => p.Name == "Pictures At An Exhibition"); ComposerTypeList ctl = new ComposerTypeList(); ComposerType composerType = new ComposerType(); ctl.Load(); composerType = ctl.FirstOrDefault(ct => ct.Description == "Composer"); PieceWriter pieceWriter = new PieceWriter { ComposerId = composer.Id, ComposerTypeId = composerType.Id, PieceId = piece.Id }; PieceWriterList pieceWriters = new PieceWriterList(); pieceWriters.Load(); int originalCount = pieceWriters.Count(); //Act HttpClient client = InitializeClient(); //Serialize a pieceWriter object that we're trying to insert string serializedPieceWriter = JsonConvert.SerializeObject(pieceWriter); var content = new StringContent(serializedPieceWriter); content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json"); HttpResponseMessage response = client.PostAsync("PieceWriter", content).Result; //Assert pieceWriters.Clear(); pieceWriters.Load(); Assert.AreEqual(originalCount + 1, pieceWriters.Count); }
public void Update() { //Setup ComposerList cl = new ComposerList(); Composer composer = new Composer(); cl.Load(); composer = cl.FirstOrDefault(c => c.FirstName == "Alex"); PieceList pl = new PieceList(); Piece piece = new Piece(); pl.Load(); piece = pl.FirstOrDefault(p => p.Name == "Pictures At An Exhibition"); ComposerTypeList ctl = new ComposerTypeList(); ComposerType composerType = new ComposerType(); ComposerType arranger = new ComposerType(); ctl.Load(); composerType = ctl.FirstOrDefault(ct => ct.Description == "Composer"); arranger = ctl.FirstOrDefault(ct => ct.Description == "Arranger"); PieceWriterList pieceWriters = new PieceWriterList(); pieceWriters.Load(); PieceWriter pieceWriter = pieceWriters.FirstOrDefault(pw => pw.ComposerId == composer.Id && pw.ComposerTypeId == composerType.Id && pw.PieceId == piece.Id); PieceWriter retrievedPieceWriter = new PieceWriter(); if (pieceWriter != null) { retrievedPieceWriter.Id = pieceWriter.Id; pieceWriter.ComposerTypeId = arranger.Id; //Act HttpClient client = InitializeClient(); //Serialize a question object that we're trying to insert string serializedPieceWriter = JsonConvert.SerializeObject(pieceWriter); var content = new StringContent(serializedPieceWriter); content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json"); HttpResponseMessage response = client.PutAsync("PieceWriter/" + pieceWriter.Id, content).Result; retrievedPieceWriter.LoadById(); } //Assert Assert.AreEqual(pieceWriter.ComposerTypeId, retrievedPieceWriter.ComposerTypeId); }
public void LoadById() { ComposerType composerType = new ComposerType(); ComposerTypeList composerTypes = new ComposerTypeList(); composerTypes.Load(); composerType = composerTypes.FirstOrDefault(c => c.Description == "Update"); ComposerType newComposerType = new ComposerType { Id = composerType.Id }; newComposerType.LoadById(); Assert.AreEqual(composerType.Description, newComposerType.Description); }
public void Delete() { //Setup ComposerList cl = new ComposerList(); Composer composer = new Composer(); cl.Load(); composer = cl.FirstOrDefault(c => c.FirstName == "Alex"); PieceList pl = new PieceList(); Piece piece = new Piece(); pl.Load(); piece = pl.FirstOrDefault(p => p.Name == "Pictures At An Exhibition"); ComposerTypeList ctl = new ComposerTypeList(); ComposerType arranger = new ComposerType(); ctl.Load(); arranger = ctl.FirstOrDefault(ct => ct.Description == "Arranger"); PieceWriterList pieceWriters = new PieceWriterList(); pieceWriters.Load(); int originalCount = pieceWriters.Count(); PieceWriter pieceWriter = pieceWriters.FirstOrDefault(pw => pw.ComposerId == composer.Id && pw.ComposerTypeId == arranger.Id && pw.PieceId == piece.Id); //Act if (pieceWriter != null) { HttpClient client = InitializeClient(); HttpResponseMessage response = client.DeleteAsync("PieceWriter/" + pieceWriter.Id).Result; } //Assert pieceWriters.Clear(); pieceWriters.Load(); Assert.AreEqual(originalCount - 1, pieceWriters.Count); }
public void Delete() { //Setup ComposerTypeList composerTypes = new ComposerTypeList(); composerTypes.Load(); int originalCount = composerTypes.Count(); ComposerType composerType = composerTypes.FirstOrDefault(ct => ct.Description == "SLTEST1"); //Act if (composerType != null) { HttpClient client = InitializeClient(); HttpResponseMessage response = client.DeleteAsync("ComposerType/" + composerType.Id).Result; } //Assert composerTypes.Clear(); composerTypes.Load(); Assert.AreEqual(originalCount - 1, composerTypes.Count); }
public void GetOne() { //Setup ComposerType composerType = new ComposerType(); ComposerType retrievedComposerType = new ComposerType(); ComposerTypeList composerTypes = new ComposerTypeList(); composerTypes.Load(); composerType = composerTypes.FirstOrDefault(ct => ct.Description == "Composer"); //Act if (composerType != null) { HttpClient client = InitializeClient(); HttpResponseMessage response = client.GetAsync("ComposerType/" + composerType.Id).Result; string result = response.Content.ReadAsStringAsync().Result; retrievedComposerType = JsonConvert.DeserializeObject <ComposerType>(result); } //Assert Assert.IsTrue(composerType.Description == retrievedComposerType.Description && !string.IsNullOrEmpty(retrievedComposerType.Description)); }
// PUT: api/ComposerType/5 public void Put(Guid id, ComposerType composerType) { composerType.Update(); }
// POST: api/ComposerType public void Post(ComposerType composerType) { composerType.Insert(); }