public void AddKeywordShouldAddCorrectKeywordToDB(string kw, bool useAsync)
        {
            //Arrange
            var options = new DbContextOptionsBuilder <Project2DBContext>()
                          .UseInMemoryDatabase(databaseName: "EmptyKeywordAddTesting2DB")
                          .Options;

            Keyword k = new Keyword {
                Word = kw
            };
            KeywordRepo kRepo;
            Keyword     result;

            //Act
            using (var context = new Project2DBContext(options))
            {
                kRepo = new KeywordRepo(context);
                if (useAsync)
                {
                    kRepo.AddKeywordAsync(k).Wait();
                }
                else
                {
                    kRepo.AddKeyword(k);
                }
                result = context.Keyword.Find(k.Word);
            }

            //Assert
            Assert.Equal(k, result);
        }
        public void AddKeywordShouldThrowExceptionIfKeywordIsPreset(string kw, bool useAsync)
        {
            //Arrange
            string dBName;

            if (useAsync)
            {
                dBName = "EmptyKeywordAddTestingAsync1DB";
            }
            else
            {
                dBName = "EmptyKeywordAddTesting1DB";
            }
            var options = new DbContextOptionsBuilder <Project2DBContext>()
                          .UseInMemoryDatabase(databaseName: dBName)
                          .Options;

            Keyword k = new Keyword {
                Word = kw
            };
            Keyword k2 = new Keyword {
                Word = kw
            };
            KeywordRepo kRepo;
            bool        result = false;

            using (var context = new Project2DBContext(options))
            {
                context.Keyword.Add(k2);
                context.SaveChanges();
            }

            //Act
            using (var context = new Project2DBContext(options))
            {
                kRepo = new KeywordRepo(context);
                try
                {
                    if (useAsync)
                    {
                        kRepo.AddKeywordAsync(k).Wait();
                    }
                    else
                    {
                        kRepo.AddKeyword(k);
                    }
                }
                catch (DbUpdateException)
                {
                    result = true;
                }
                catch (AggregateException)
                {
                    result = true;
                }
            }

            //Assert
            Assert.True(result);
        }