public void GetAlbumsByUser_ShouldGetOnlyPublicAlbumsOfUserIfOtherAuthenitcatedUser() { // arrange var data = new FakeGalleryData(); this.PopulateFakeGalleryUsersData(data, 5); this.PopulateFakeGalleryAlbumsData(data, 10); string username = "******"; var album = new Album() { Name = "customAlbum0", Private = false }; var service = new AlbumsService(data); service.Add(album, username); // act var actual = service.GetAlbumsByUser(username, "user1").Count(); // assert Assert.AreEqual(1, actual); }
public void Add_ShouldThrowIfAlbumIsNull() { // arrange var data = new FakeGalleryData(); var service = new AlbumsService(data); string username = "******"; // act service.Add(null, username); }
public void Add_ShouldThrow_WhenNoCreatorSpecified() { // arrange var data = new FakeGalleryData(); this.PopulateFakeGalleryUsersData(data, 5); var service = new AlbumsService(data); var album = this.GetAlbum("myalbum", false); // act service.Add(album, null); }
public void Add_ShouldThrowIfUserWithSpecifiedUsernameIsNotFound() { // arrange var data = new FakeGalleryData(); this.PopulateFakeGalleryUsersData(data, 5); var service = new AlbumsService(data); string username = "******"; var album = this.GetAlbum("myalbum", false); // act service.Add(album, username); }
public void Add_ShouldAddAlbumWithCorrectUserWhenUsernameIsValid() { // arrange var data = new FakeGalleryData(); this.PopulateFakeGalleryUsersData(data, 5); var service = new AlbumsService(data); string username = "******"; var album = this.GetAlbum("myalbum", false); // act service.Add(album, username); var actual = service.GetAll(username).First().Owner.UserName; // assert Assert.AreEqual(username, actual); }
public void Add_ShouldReturnTheAddedAlbumId() { // arrange var data = new FakeGalleryData(); this.PopulateFakeGalleryUsersData(data, 5); var service = new AlbumsService(data); string username = "******"; var album = this.GetAlbum("myalbum", false); // act var actual = service.Add(album, username); // assert Assert.AreEqual(1, actual); }
public void Add_ShouldAddAlbumIfAlbumAndUsernameAreValid() { // arrange var data = new FakeGalleryData(); this.PopulateFakeGalleryUsersData(data, 5); var service = new AlbumsService(data); string username = "******"; var album = this.GetAlbum("myalbum", false); // act service.Add(album, username); var actual = service.GetAll(username).Count(); // assert Assert.AreEqual(1, actual); }
public void Add_ShouldCallDataSaveChanges() { // arrange var data = new FakeGalleryData(); this.PopulateFakeGalleryUsersData(data, 5); var service = new AlbumsService(data); string username = "******"; var album = this.GetAlbum("myalbum", false); // act service.Add(album, username); var actual = data.SaveChangesCallCount; // assert Assert.AreEqual(1, actual); }
public void Add_ShouldAddAlbumWithCorrectDate() { // arrange var data = new FakeGalleryData(); this.PopulateFakeGalleryUsersData(data, 5); var service = new AlbumsService(data); string username = "******"; var album = this.GetAlbum("myalbum", false); // act service.Add(album, username); var addedAlbum = service.GetAll(username).First(); var addedAlbumDate = addedAlbum.CreatedOn.Date; var addedAlbumHour = addedAlbum.CreatedOn.Hour; // assert Assert.AreEqual(DateTime.Now.Date, addedAlbumDate); }
public void GetAlbumsByUser_ShouldGetAllAlbumsOfUserIfSameIsAuthenticated() { // arrange var data = new FakeGalleryData(); this.PopulateFakeGalleryUsersData(data, 5); this.PopulateFakeGalleryAlbumsData(data, 10); string username = "******"; var album = new Album() { Name = "customAlbum0", }; var service = new AlbumsService(data); service.Add(album, username); // act var actual = service.GetAlbumsByUser(username, username).Count(); // assert Assert.AreEqual(2, actual); }