Пример #1
0
        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);
        }
Пример #2
0
        public void Add_ShouldThrowIfAlbumIsNull()
        {
            // arrange
            var    data     = new FakeGalleryData();
            var    service  = new AlbumsService(data);
            string username = "******";

            // act
            service.Add(null, username);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }
Пример #6
0
        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);
        }
Пример #9
0
        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);
        }
Пример #10
0
        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);
        }
Пример #11
0
        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);
        }
Пример #12
0
        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);
        }
Пример #13
0
        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);
        }
Пример #14
0
        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);
        }
Пример #15
0
        public void Add_ShouldThrowIfAlbumIsNull()
        {
            // arrange
            var data = new FakeGalleryData();
            var service = new AlbumsService(data);
            string username = "******";

            // act
            service.Add(null, username);
        }
Пример #16
0
        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);
        }
Пример #17
0
        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);
        }
Пример #18
0
        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);
        }
Пример #19
0
        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);
        }
Пример #20
0
        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);
        }