예제 #1
0
 public ReportServicesTests()
 {
     this.db = DbGenerator.GetDbContext();
     DbSeeder.SeedNormalUsers(this.db);
     DbSeeder.SeedGames(this.db);
     this.reportService = new ReportService(this.db, new GameService(this.db));
 }
예제 #2
0
        public static PixelArtWarsDbContext GetDbContext()
        {
            var options = new DbContextOptionsBuilder <PixelArtWarsDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var db = new PixelArtWarsDbContext(options);

            return(db);
        }
예제 #3
0
        public DrawingServiceTests()
        {
            this.db = DbGenerator.GetDbContext();
            DbSeeder.SeedNormalUsers(this.db);
            DbSeeder.SeedGames(this.db);

            var imageService = new Mock <IImageService>();

            imageService
            .Setup(s => s.SaveGameDrawing(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <string>()))
            .Returns(() => Task.FromResult(ImageUrl));

            this.drawingService = new DrawingService(this.db, imageService.Object);
        }
예제 #4
0
        public static void SeedNormalUsers(PixelArtWarsDbContext db)
        {
            for (int i = 0; i < 20; i++)
            {
                db.Users.Add(new User()
                {
                    UserName = i.ToString(),
                    Email    = $"bistra{i}@basheva.tues",
                    IsBanned = false
                });
            }

            db.SaveChanges();
        }
예제 #5
0
        public static void SeedGames(PixelArtWarsDbContext db)
        {
            for (int i = 0; i < 20; i++)
            {
                db.Games.Add(new Game()
                {
                    Theme        = $"StellaBasheva{i}",
                    Status       = GameStauts.Active,
                    PlayersCount = 2
                });
            }

            db.SaveChanges();
        }
예제 #6
0
 public DrawingService(PixelArtWarsDbContext db, IImageService imageService)
 {
     this.db           = db;
     this.imageService = imageService;
 }
예제 #7
0
 public GameService(PixelArtWarsDbContext db)
 {
     this.db = db;
 }
예제 #8
0
 public GameServiceTests()
 {
     this.db = DbGenerator.GetDbContext();
     DbSeeder.SeedNormalUsers(this.db);
     this.gameService = new GameService(this.db);
 }
예제 #9
0
 public ReportService(PixelArtWarsDbContext db, IGameService gameService)
 {
     this.db          = db;
     this.gameService = gameService;
 }