Example #1
0
        public void GetPack_ById_Success()
        {
            var options = TestUtilities.GetDbContextOptions();

            (List <Pack> packs, List <PhraseItem>, List <ServerUser>)data = TestUtilities.GeneratePackData(options);

            // Use a separate instance of the context to verify correct data was saved to database
            using (var context = new FillerDbContext(options))
            {
                var pack      = new Faker().PickRandom(data.packs);
                var repo      = new PackRepository(context);
                var savedPack = repo.GetAsync(pack.Id).GetAwaiter().GetResult();
                Assert.AreEqual(pack.Id, savedPack.Id);
                var randomPack = repo.GetAsync(int.MaxValue - 1).GetAwaiter().GetResult();
                Assert.Null(randomPack);
            }
        }
Example #2
0
        public void DeleteById_Existing_Success()
        {
            var options = TestUtilities.GetDbContextOptions();

            (List <Pack> packs, List <PhraseItem>, List <ServerUser>)data = TestUtilities.GeneratePackData(options);

            var pack = new Faker().PickRandom(data.packs);

            using (var context = new FillerDbContext(options))
            {
                new PackRepository(context).DeleteAsync(pack.Id).GetAwaiter().GetResult();
            }

            // Use a separate instance of the context to verify correct data was saved to database
            using (var context = new FillerDbContext(options))
            {
                var repo   = new PackRepository(context);
                var actual = repo.GetAsync(pack.Id).GetAwaiter().GetResult();
                Assert.Null(actual);
            }
        }