Example #1
0
        public async Task DeleteGenre()
        {
            var databaseName = Guid.NewGuid().ToString();
            var context      = BuildContext(databaseName);
            var mapper       = BuildMap();

            context.Genres.Add(new Genre()
            {
                Name = "Genre 1"
            });
            context.SaveChanges();

            var context2 = BuildContext(databaseName);

            var controller = new GenresV2Controller(context2, mapper);

            var response = await controller.Delete(1);

            var result = response as StatusCodeResult;

            Assert.AreEqual(204, result.StatusCode);

            var context3 = BuildContext(databaseName);
            var exists   = await context3.Genres.AnyAsync();

            Assert.IsFalse(exists);
        }
Example #2
0
        public async Task DeleteGenreNotFound()
        {
            var databaseName = Guid.NewGuid().ToString();
            var context      = BuildContext(databaseName);
            var mapper       = BuildMap();

            var controller = new GenresV2Controller(context, mapper);

            var response = await controller.Delete(1);

            var result = response as StatusCodeResult;

            Assert.AreEqual(404, result.StatusCode);
        }