Esempio n. 1
0
        public async Task InsertAsyncTest(string titel, string description, int playtime, string link, string poster,
                                          bool expectedStatus)
        {
            var img = Image.FromFile(poster);

            byte[] arr;
            using (var ms = new MemoryStream())
            {
                img.Save(ms, ImageFormat.Jpeg);
                arr = ms.ToArray();
            }

            var movie  = new Movie();
            var status = false;

            if (expectedStatus)
            {
                movie = new Movie
                {
                    Titel       = titel,
                    Description = description,
                    Link        = link,
                    Playtime    = playtime,
                    Poster      = arr
                };

                status = await movieLogic.InsertAsync(movie);

                Assert.True(status);
            }
            else
            {
                Assert.Throws <ArgumentException>(() => movie = new Movie
                {
                    Titel       = titel,
                    Description = description,
                    Link        = link,
                    Playtime    = playtime,
                    Poster      = arr
                });

                await Assert.ThrowsAsync <ArgumentNullException>(
                    async() => status = await movieLogic.InsertAsync(movie));

                Assert.False(status);
            }
        }