public void GetAll_ShouldReturnAllGamesFromDb()
        {
            //Arrange
            var someGame = new LotteryGame
            {
                Name = Guid.NewGuid().ToString(),
                NumberOfNumbersInADraw = 6,
                MaximumNumber          = 45
            };
            var originalAmountOfGames = 0;

            using (var context = CreateDbContext())
            {
                originalAmountOfGames = context.Set <LotteryGame>().Count();

                context.Add(someGame);
                context.SaveChanges();
            }

            using (var context = CreateDbContext())
            {
                var repo = new LotteryGameRepository(context);

                //Act
                var allGames = repo.GetAll();

                //Assert
                Assert.That(allGames, Has.Count.EqualTo(originalAmountOfGames + 1), () => "Not all games in the database are returned.");
                var expectedGame = allGames.FirstOrDefault(game => game.Name == someGame.Name);
                Assert.That(expectedGame, Is.Not.Null, () => "Not all games in the database are returned.");
            }
        }
Esempio n. 2
0
        public void Setup()
        {
            _connectionFactoryMock = new Mock <IConnectionFactory>();
            _connection            = Cc();
            _connectionFactoryMock.Setup(factory => factory.CreateSqlConnection()).Returns(_connection);

            _repository = new LotteryGameRepository(_connectionFactoryMock.Object);
        }
Esempio n. 3
0
        protected override void OnStartup(StartupEventArgs e)
        {
            var connectionFactory = new ConnectionFactory();

            var lotteryGameRepository = new LotteryGameRepository(connectionFactory);
            var drawRepository        = new DrawRepository(connectionFactory);
            var drawService           = new DrawService(drawRepository);
            var lotteryWindow         = new LotteryWindow(lotteryGameRepository, drawRepository, drawService);

            lotteryWindow.Show();
        }
Esempio n. 4
0
        protected override void OnStartup(StartupEventArgs e)
        {
            var context = new LotteryContext();

            context.CreateOrUpdateDatabase();

            var lotteryGameRepository = new LotteryGameRepository(context);
            var drawRepository        = new DrawRepository(context);
            var drawService           = new DrawService(drawRepository);
            var lotteryWindow         = new LotteryWindow(lotteryGameRepository, drawRepository, drawService);

            lotteryWindow.Show();
        }