Beispiel #1
0
        public async void CreateGramWorksAgain()
        {
            DbContextOptions <NetGramDbContext> options =
                new DbContextOptionsBuilder <NetGramDbContext>
                    ().UseInMemoryDatabase("Create").Options;

            using (NetGramDbContext context = new NetGramDbContext(options))
            {
                // arrange
                NetGram netGram = new NetGram();
                netGram.ID         = 2;
                netGram.NamePoster = "Jason";
                netGram.Caption    = "Seattle";


                // Act
                NetGramManager netGramManager = new NetGramManager(context);

                await netGramManager.SaveNetGram(netGram);

                var created = context.NetGrams.FirstOrDefault(n => n.ID == netGram.ID);

                // Assert
                Assert.Equal(netGram, created);
            }
        }
Beispiel #2
0
        public async void EditGramWorksAgain()
        {
            DbContextOptions <NetGramDbContext> options =
                new DbContextOptionsBuilder <NetGramDbContext>
                    ().UseInMemoryDatabase("Edits").Options;

            using (NetGramDbContext context = new NetGramDbContext(options))
            {
                // arrange
                NetGram netGram = new NetGram();
                netGram.ID         = 2;
                netGram.NamePoster = "Jason";
                netGram.Caption    = "Seattle";


                // Act
                NetGramManager netGramManager = new NetGramManager(context);

                await netGramManager.SaveNetGram(netGram);

                netGram.Caption = "Wow";

                await netGramManager.SaveNetGram(netGram);

                // Assert
                Assert.Equal("Wow", netGram.Caption);
            }
        }