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

            var pack = new Pack {
                Name = "Test Pack", Description = "Test Description", Language = "ru"
            };
            const string newName        = "new name";
            const string newDescription = "new description";
            const string newLanguage    = "en";

            // Run the test against one instance of the context
            using (var context = new FillerDbContext(options))
            {
                var repo = new PackRepository(context);
                repo.InsertAsync(pack).GetAwaiter().GetResult();
                pack.Name        = newName;
                pack.Description = newDescription;
                pack.Language    = newLanguage;
                repo.UpdateAsync(pack);
            }

            using (var context = new FillerDbContext(options))
            {
                var repo = new PackRepository(context);

                var updatedPack = repo.GetAll().Single();
                Assert.AreEqual(updatedPack.Name, pack.Name);
                Assert.AreEqual(updatedPack.Language, pack.Language);
                Assert.AreEqual(updatedPack.Description, pack.Description);
            }
        }