public void GetAlbumInfoTest4() { RentItClient target = new RentItClient(); int id = 70; AlbumInfo actual = target.GetAlbumInfo(id); }
public void GetAllCustomerDataExceptionTestTwo() { RentItClient target = new RentItClient(); AccountCredentials credentials = new AccountCredentials { UserName = "******", HashedPassword = "******" }; target.GetAllCustomerData(credentials); }
public void GetAlbumInfoTest2() { RentItClient target = new RentItClient(); // The album indentified by id 78 has only 2 songs. int id = 78; AlbumInfo actual = target.GetAlbumInfo(id); Assert.AreEqual(2, actual.Songs.Length); }
public void GetAllCustomerDataExceptionTestOne() { RentItClient target = new RentItClient(); AccountCredentials credentials = new AccountCredentials { UserName = "******", HashedPassword = "******" }; target.GetAllCustomerData(credentials); }
public void GetAllPublisherDataExceptionTestOne() { RentItClient target = new RentItClient(); AccountCredentials credentials = new AccountCredentials { UserName = "******", HashedPassword = "******" }; target.GetAllPublisherData(credentials); }
public void CreateNewUserTest2() { RentItClient target = new RentItClient(); Account newAccount = new Account { UserName = "******", FullName = "Test Testesen", Email = "*****@*****.**", HashedPassword = "******" }; target.CreateNewUser(newAccount); }
public void GetAlbumInfoTest1() { RentItClient target = new RentItClient(); // Get the album indentified by the media id 78. int id = 78; AlbumInfo actual = target.GetAlbumInfo(id); Assert.AreNotEqual(null, actual); Assert.AreEqual("The Cure", actual.AlbumArtist); Assert.AreEqual("The Greatest Hits", actual.Title); }
public void GetAllCustomerDataTest() { RentItClient target = new RentItClient(); AccountCredentials credentials = new AccountCredentials { UserName = "******", HashedPassword = "******" }; UserAccount actual = target.GetAllCustomerData(credentials); Assert.AreEqual("user21", actual.UserName); Assert.AreEqual("*****@*****.**", actual.Email); Assert.AreEqual("user21", actual.FullName); Assert.AreEqual("a1881c06eec96db9901c7bbfe41c42a3f08e9cb4", actual.HashedPassword); Assert.AreEqual(0, actual.Credits); }
public void CreateNewUserTest() { RentItClient target = new RentItClient(); Account newAccount = new Account { UserName = "******", FullName = "Unit Testesen1", Email = "*****@*****.**", HashedPassword = "******" }; bool expected = true; bool actual; actual = target.CreateNewUser(newAccount); Assert.AreEqual(expected, actual); CleanupCreateUser(newAccount.UserName); }
public SearchResultsControl() { InitializeComponent(); rentIt = new RentItClient(); criteria = new MediaCriteria { SearchText = "", Genre = "", Type = MediaType.Any, Limit = -1, Offset = 0, Order = MediaOrder.AlphabeticalAsc }; TypeFilter.SelectedIndex = 0; }
public void AddCreditsTest() { RentItClient target = new RentItClient(); AccountCredentials credentials = new AccountCredentials { UserName = "******", HashedPassword = "******" }; int oldCredits = target.GetAllCustomerData(credentials).Credits; uint addAmount = 100; bool expected = true; bool actual = target.AddCredits(credentials, addAmount); Assert.AreEqual(expected, actual); int newCredits = target.GetAllCustomerData(credentials).Credits; Assert.AreEqual(oldCredits + addAmount, newCredits); }
public MainForm() { InitializeComponent(); var binding = new BasicHttpBinding(); var address = new EndpointAddress("http://rentit.itu.dk/rentit01/RentItService.svc"); rentItProxy = new RentItClient(binding, address); // Call a method on the web service to check for connectivity. // A potential EndpointNotFoundException is caught in Program.cs. rentItProxy.GetAllGenres(MediaType.Book); TopBar.RentItProxy = rentItProxy; TopBar.Credentials = credentials; TopBar.ContentChangeEvent += ChangeContent; TopBar.CredentialsChangeEvent += ChangeCredentials; TopBar.CreditsChangeEvent += ChangeCredits; Content = new MainScreen { RentItProxy = rentItProxy }; }
public void DeleteMediaTest1() { RentItClient target = new RentItClient(); int mediaId = 3; // Kraftwerk - The Robots AccountCredentials credentials = new AccountCredentials { UserName = "******", HashedPassword = "******" }; bool expected = true; bool actual = target.DeleteMedia(mediaId, credentials); Assert.AreEqual(expected, actual); var db = new RentItTestDatabase.RentItDatabaseDataContext(); // clean up var deletedMedia = (from m in db.Medias where m.id == mediaId select m).Single(); deletedMedia.active = true; db.SubmitChanges(); }
public void DeleteMediaTest2() { RentItClient target = new RentItClient(); int mediaId = 2; // "House of Leaves" AccountCredentials credentials = new AccountCredentials { UserName = "******", HashedPassword = "******" }; target.DeleteMedia(mediaId, credentials); // InvalidCredentialsException }
public void UpdateMediaMetadataTest() { RentItClient target = new RentItClient(); AccountCredentials credentials = new AccountCredentials { UserName = "******", HashedPassword = "******" }; int mediaId = 10; // Kraftwerk - "The Man-Machine" album AlbumInfo newAlbumData = target.GetAlbumInfo(mediaId); string albumArtist = newAlbumData.AlbumArtist; newAlbumData.AlbumArtist = newAlbumData.AlbumArtist == "Kraftwerk" ? "Craftwork" : "Kraftwerk"; bool actual = target.UpdateMediaMetadata(newAlbumData, credentials); string updatedAlbumArtist = target.GetAlbumInfo(mediaId).AlbumArtist; Assert.IsTrue(actual); Assert.IsTrue(albumArtist == "Kraftwerk"? "Craftwork" == updatedAlbumArtist : "Kraftwerk" == updatedAlbumArtist); mediaId = 1; // "The Room" MovieInfo newMovieData = target.GetMovieInfo(mediaId); string director = newMovieData.Director; newMovieData.Director = newMovieData.Director == "Tommy Wiseau" ? "Timmy Wiseau" : "Tommy Wiseau"; actual = target.UpdateMediaMetadata(newMovieData, credentials); string updatedDirector = target.GetMovieInfo(mediaId).Director; Assert.IsTrue(actual); Assert.IsTrue(director == "Tommy Wiseau" ? "Timmy Wiseau" == updatedDirector : "Tommy Wiseau" == updatedDirector); mediaId = 2; // "House of Leaves" BookInfo newBookData = target.GetBookInfo(mediaId); string author = newBookData.Author; newBookData.Author = newBookData.Author == "Mark Z. Danielewsky" ? "Mak Z. Danielewsky" : "Mark Z. Danielewsky"; actual = target.UpdateMediaMetadata(newBookData, credentials); string updatedAuthor = target.GetBookInfo(mediaId).Author; Assert.IsTrue(actual); Assert.IsTrue(author == "Mark Z. Danielewsky" ? "Mak Z. Danielewsky" == updatedAuthor : "Mark Z. Danielewsky" == updatedAuthor); }
public void UpdateAccountInfoTest1() { RentItClient target = new RentItClient(); AccountCredentials credentials = new AccountCredentials { UserName = "******", HashedPassword = "******" }; Account account = target.GetAllCustomerData(credentials); string oldEmail = account.Email; account.Email += "+"; bool expected = true; bool actual = target.UpdateAccountInfo(credentials, account); Assert.AreEqual(expected, actual); string newEmail = target.GetAllCustomerData(credentials).Email; Assert.AreEqual(oldEmail + "+", newEmail); }
public void GetAllGenresTest() { RentItClient target = new RentItClient(); MediaType mediaType = MediaType.Any; string[] expected = new string[0]; // empty list string[] actual = target.GetAllGenres(mediaType); // List<string> actual = target.GetAllGenres(mediaType); Assert.AreNotEqual(expected.Length, actual.Length); // list should not be empty mediaType = MediaType.Book; actual = target.GetAllGenres(mediaType); Assert.AreNotEqual(expected.Length, actual.Length); // list should not be empty mediaType = MediaType.Movie; actual = target.GetAllGenres(mediaType); Assert.AreNotEqual(expected.Length, actual.Length); // list should not be empty mediaType = MediaType.Album; actual = target.GetAllGenres(mediaType); Assert.AreNotEqual(expected.Length, actual.Length); // list should not be empty mediaType = MediaType.Song; actual = target.GetAllGenres(mediaType); Assert.AreNotEqual(expected.Length, actual.Length); // list should not be empty }
public void GetAllPublisherDataTest() { RentItClient target = new RentItClient(); AccountCredentials credentials = new AccountCredentials { UserName = "******", HashedPassword = "******" }; PublisherAccount actual = target.GetAllPublisherData(credentials); Assert.AreEqual("publishCorp", actual.UserName); Assert.AreEqual("*****@*****.**", actual.Email); Assert.AreEqual("Publish Corp. Publishing Division", actual.FullName); Assert.AreEqual("7110EDA4D09E062AA5E4A390B0A572AC0D2C0220", actual.HashedPassword); Assert.AreEqual("Publish Corp. International", actual.PublisherName); }
public void GetAlsoRentedItemsTest() { RentItClient target = new RentItClient(); const int Id = 1; MediaItems actual = target.GetAlsoRentedItems(Id); Assert.IsTrue(actual.Books.ToList().Exists(x => x.Id == 2 && x.Title == "House of Leaves")); Assert.IsTrue(actual.Albums.ToList().Exists(x => x.Id == 10 && x.Title == "The Man-Machine")); Assert.IsTrue(actual.Songs.Count() == 0); }
public void GetBookInfoTest1() { RentItClient target = new RentItClient(); int id = 81; BookInfo actual = target.GetBookInfo(id); Assert.AreEqual("Power Commands for Visual Studio", actual.Title); }
protected void Page_Load(object sender, EventArgs e) { int mediaId = int.Parse(Request.QueryString["mediaId"]); string mediaExtension = Request.QueryString["extension"]; string userName = Request.QueryString["userName"]; string password = Request.QueryString["password"]; Debug.WriteLine("Query string accepted."); // Check if the user name is a publisher account. var db = new RentItDatabase.RentItDatabaseDataContext(); if (!db.Publisher_accounts.Exists(acc => acc.user_name.Equals(userName))) { Response.StatusCode = 400; Response.StatusDescription = "The specified account is not authorized to upload media."; Response.End(); } // Check if the metadata of the movie has been uploaded. if (!db.Medias.Exists(media => media.id == mediaId)) { Response.StatusCode = 400; Response.StatusDescription = "Metadata for the specified media has not been uploaded." + "This is needed before it is possible to upload the data."; Response.End(); } var client = new RentItClient(); try { client.ValidateCredentials( new AccountCredentials() { UserName = userName, HashedPassword = password }); } catch (Exception) { Response.StatusCode = 400; Response.StatusDescription = "Incorrect credentials"; Response.End(); } // Get the uploaded file. HttpPostedFile uploadedFile = Request.Files.Get(0); var memoryStream = new MemoryStream(); byte[] binary; try { uploadedFile.InputStream.CopyTo(memoryStream); binary = memoryStream.ToArray(); } catch (Exception) { Response.StatusCode = 400; Response.StatusDescription = "Media upload failed. Please try again."; Response.End(); return; } RentItDatabase.Media mediaInfo = (from m in db.Medias where m.id == mediaId select m).Single(); // Create a new Media_file entry in the database and upload the file to // the database. RentItDatabase.Media_file mediaFile = new Media_file { name = mediaInfo.title, extension = mediaExtension, data = binary }; db.Media_files.InsertOnSubmit(mediaFile); db.SubmitChanges(); // Connect the Media_file tuple to the Media tuple. mediaInfo.Media_file = mediaFile; db.SubmitChanges(); }
private static RentItClient GetServiceClient() { if (RentItProxy != null) { return RentItProxy; } var binding = new BasicHttpBinding(); var address = new EndpointAddress("http://rentit.itu.dk/rentit01/RentItService.svc"); return RentItProxy = new RentItClient(binding, address); }
public void SubmitReviewExceptionTest() { RentItClient target = new RentItClient(); MediaReview review = new MediaReview { MediaId = 64, Rating = Rating.Three, ReviewText = "Bucket.", Timestamp = DateTime.Now, UserName = "******" }; AccountCredentials credentials = new AccountCredentials { UserName = "******", HashedPassword = "******" }; target.SubmitReview(review, credentials); target.SubmitReview(review, credentials); }
protected void Page_Load(object sender, EventArgs e) { Stream inputStream = Request.InputStream; int mediaId = int.Parse(Request.QueryString["mediaId"]); // string mediaExtension = Request.QueryString["extension"]; string userName = Request.QueryString["userName"]; string password = Request.QueryString["password"]; // Check if the user name is a publisher account. var db = new RentItDatabase.RentItDatabaseDataContext(); if (!db.Publisher_accounts.Exists(acc => acc.user_name.Equals(userName))) { Response.StatusCode = 400; Response.StatusDescription = "The specified account is not authorized to upload media."; } // Check if the metadata of the movie has been uploaded. if (!db.Medias.Exists(media => media.id == mediaId)) { Response.StatusCode = 400; Response.StatusDescription = "Metadata for the specified media has not been uploaded." + "This is needed before it is possible to upload the data."; Response.End(); } var client = new RentItClient(); try { client.ValidateCredentials( new AccountCredentials() { UserName = userName, HashedPassword = password }); } catch (Exception) { Response.StatusCode = 400; Response.StatusDescription = "Incorrect credentials"; Response.End(); } var memoryStream = new MemoryStream(); byte[] thumbnail; try { inputStream.CopyTo(memoryStream); thumbnail = memoryStream.ToArray(); } catch (Exception) { Response.StatusCode = 400; Response.StatusDescription = "Thumbnail upload failed. Please try again."; Response.End(); return; } RentItDatabase.Media mediaInfo = (from m in db.Medias where m.id == mediaId select m).First(); mediaInfo.thumbnail = thumbnail; db.SubmitChanges(); }
public void TestMethod1() { RentItClient client = new RentItClient(); Account acc = client.ValidateCredentials(new AccountCredentials() { UserName = "******", HashedPassword = "******" }); Assert.AreNotEqual(null, acc); }
public void DeleteMediaTest3() { RentItClient target = new RentItClient(); int mediaId = 90000; // non-existant AccountCredentials credentials = new AccountCredentials { UserName = "******", HashedPassword = "******" }; target.DeleteMedia(mediaId, credentials); // InvalidCredentialsException }
public void GetAlsoRentedItemsExceptionTest() { RentItClient target = new RentItClient(); target.GetAlsoRentedItems(-3); }
public void SubmitReviewTest() { RentItClient target = new RentItClient(); const string User = "******"; const int MediaId = 79; MediaReview review = new MediaReview { MediaId = MediaId, Rating = Rating.Three, ReviewText = "Bucketboy, yes.", Timestamp = DateTime.Now, UserName = User }; AccountCredentials credentials = new AccountCredentials { UserName = User, HashedPassword = "******" }; bool actual = target.SubmitReview(review, credentials); Assert.IsTrue(actual); this.SubmitReviewCleanup(User, MediaId); }
public void DeleteAccountTest() { var db = new RentItTestDatabase.RentItDatabaseDataContext(); RentItClient target = new RentItClient(); Account delAccount = new Account { UserName = "******", FullName = "Unit Testesen1", Email = "*****@*****.**", HashedPassword = "******" }; target.CreateNewUser(delAccount); AccountCredentials credentials = new AccountCredentials { UserName = "******", HashedPassword = "******" }; bool expected = true; bool actual; actual = target.DeleteAccount(credentials); Assert.AreEqual(expected, actual); CleanupCreateUser(credentials.UserName); }
public void GetAllPublisherDataExceptionTestTwo() { RentItClient target = new RentItClient(); AccountCredentials credentials = new AccountCredentials { UserName = "******", HashedPassword = "******" }; target.GetAllPublisherData(credentials); }