コード例 #1
0
        public async Task AlbumOwnerIdShouldReturnTheIdOfUserIfAlbumExists()
        {
            // Arrange
            var userId = Guid.NewGuid().ToString();
            var db     = MockManager.GetMockDatabase();
            var user   = new User
            {
                Id = userId
            };
            var album = new Album
            {
                Id   = 1,
                Name = "My album",
                User = user
            };

            await db.Albums.AddAsync(album);

            await db.SaveChangesAsync();

            var pictureService = new PictureService(db);

            // Act
            var result = await pictureService.AlbumOwnerId(1);

            // Assert
            result
            .Should()
            .NotBeNull()
            .And
            .Be(userId);
        }
コード例 #2
0
        public async Task AlbumOwnerIdShouldReturnNullIfAlbumDoesNotExist()
        {
            // Arrange
            var db = MockManager.GetMockDatabase();

            var pictureService = new PictureService(db);

            // Act
            var result = await pictureService.AlbumOwnerId(1);

            // Assert
            result
            .Should()
            .BeNull();
        }