Ejemplo n.º 1
0
        public DatabaseTestBase()
        {
            var options = new DbContextOptionsBuilder <BotsContext>().UseInMemoryDatabase(Guid.NewGuid().ToString()).Options;

            _context = new BotsContext(options);
            _context.Database.EnsureCreated();
            DatabaseInitializer.Initialize(_context);
        }
Ejemplo n.º 2
0
        public static void Initialize(BotsContext context)
        {
            if (context.Bots.Any())
            {
                return;
            }

            Seed(context);
        }
Ejemplo n.º 3
0
 public RepositoryTests()
 {
     _botsContext = A.Fake <BotsContext>();
     _testeeFake  = new Repository <Bot>(_botsContext);
     _testee      = new Repository <Bot>(_context);
     _newBot      = new Bot
     {
         IP       = "155.223.25.67",
         Platform = "Linux",
         Status   = "Waiting",
         BotnetId = 1
     };
 }
Ejemplo n.º 4
0
        private static void Seed(BotsContext context)
        {
            var bots = new Bot[]
            {
                //new Bot
                //{
                //    BotnetId = 1,
                //    IP = "192.168.175.129",
                //    Platform = "Linux",
                //    Status = "Waiting",
                //},
                new Bot
                {
                    BotnetId = 1,
                    IP       = "192.168.175.135",
                    Platform = "Linux",
                    Status   = "Waiting",
                },
                new Bot
                {
                    BotnetId = 1,
                    IP       = "55.78.92.229",
                    Platform = "Windows",
                    Status   = "Waiting",
                },
                new Bot
                {
                    BotnetId = 2,
                    IP       = "52.112.45.62",
                    Platform = "Linux",
                    Status   = "Waiting",
                },
                new Bot
                {
                    BotnetId = 2,
                    IP       = "82.33.34.239",
                    Platform = "Linux",
                    Status   = "Offline",
                },
                new Bot
                {
                    BotnetId = 2,
                    IP       = "52.78.63.197",
                    Platform = "Windows",
                    Status   = "Waiting",
                },
                new Bot
                {
                    BotnetId = 3,
                    IP       = "96.128.22.47",
                    Platform = "Windows",
                    Status   = "Waiting",
                },
                new Bot
                {
                    BotnetId = 3,
                    IP       = "71.114.223.84",
                    Platform = "Linux",
                    Status   = "Waiting",
                },
                new Bot
                {
                    BotnetId = 3,
                    IP       = "34.227.32.68",
                    Platform = "Windows",
                    Status   = "Offline",
                },
                new Bot
                {
                    BotnetId = 3,
                    IP       = "88.123.22.293",
                    Platform = "Linux",
                    Status   = "Waiting",
                },
            };

            context.Bots.AddRange(bots);
            context.SaveChanges();
        }
Ejemplo n.º 5
0
 public Repository(BotsContext context)
 {
     _context = context;
 }
Ejemplo n.º 6
0
 public static void ReinitializeDbForTests(BotsContext context)
 {
     context.Bots.RemoveRange(context.Bots);
     InitializeDbForTests(context);
 }
Ejemplo n.º 7
0
 public static void InitializeDbForTests(BotsContext context)
 {
     context.Bots.AddRange(GetSeedingBots());
     context.SaveChanges();
 }
Ejemplo n.º 8
0
 public BotRepository(BotsContext context) : base(context)
 {
 }