Beispiel #1
0
        public async Task GetReportsShouldGetOne()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString());
            var context = new ApplicationDbContext(options.Options);

            var guideRepository = new EfDeletableEntityRepository <Guide>(context);
            var guideService    = new GuidesService(guideRepository);
            var guideModel      = new CreateGuideInputModel()
            {
                Category    = "Action",
                Description = "someDesc",
                GameId      = "1",
                ImageUrl    = "google",
                Title       = "test",
            };
            var guideId = await guideService.CreateAsync(guideModel, "1");

            var repository = new EfRepository <Report>(context);
            var service    = new ReportsService(repository);
            var model      = new AddReportToGuideInputModel()
            {
                UserId  = "1",
                GuideId = guideId,
                Reason  = "tupooooo",
            };
            await service.AddReportToGuideAsync(model);

            var actual = await service.GetByGuideAsync <ReportForGuideViewModel>(model.GuideId);

            Assert.Single(actual);
        }
Beispiel #2
0
        public async Task AddOnReportTwiceShouldAddOne()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString());
            var context = new ApplicationDbContext(options.Options);

            var repository = new EfRepository <Report>(context);
            var service    = new ReportsService(repository);
            var model      = new AddReportToGuideInputModel()
            {
                UserId  = "1",
                GuideId = "1",
                Reason  = "tupooooo",
            };
            await service.AddReportToGuideAsync(model);

            var actual = await service.AddReportToGuideAsync(model);

            Assert.Null(actual);
        }