Exemplo n.º 1
0
        public void FailsForInvalidData()
        {
            // Arrange.
            var validator = new EmbeddedDocumentUniquenessValidator <TestBook, TestAuthor, string>(x => x.Title);
            var testBook  = new TestBook {
                Title = "Bar"
            };
            var documentInstance = new TestAuthor
            {
                Books = new List <TestBook>
                {
                    new TestBook {
                        Title = "Foo"
                    },
                    testBook
                }
            };
            var context = DocumentValidationContext <TestBook> .Create(testBook, documentInstance, "Books", SaveType.Any);

            // Act.
            var results = validator.Validate("Foo", context).ToList();

            // Assert.
            Assert.That(results.Count, Is.EqualTo(1));
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            TestBook.Test();

            Console.ReadKey();

            // Go to http://aka.ms/dotnet-get-started-console to continue learning how to build a console app!
        }
Exemplo n.º 3
0
 /// <summary>
 /// Установить текущую книгу
 /// </summary>
 /// <param name="bookCaption"></param>
 /// <param name="saveOnDisk"></param>
 public void SetCurrentBookByCaption([NotNull] string bookCaption, bool saveOnDisk)
 {
     RuntimeEnvironment.BookSelected = true;
     _currentBook = _allBooks.FirstOrDefault(x => x.Caption == bookCaption) ?? _allBooks.First();
     if (saveOnDisk)
     {
         Helpers.WriteDiscContent(CURRENT_BOOK_FILE, bookCaption);
     }
 }
Exemplo n.º 4
0
        private static void OfflineSetup()
        {
            var token = System.IO.File.ReadAllText("token.txt");

            Bot = new DiscordClient(new DiscordConfiguration
            {
                Token     = token,
                TokenType = TokenType.Bot
            });
            Http   = new HttpClient();
            Random = new Random();


            Bot.MessageCreated += async args =>
            {
                if (!args.MentionedUsers.Contains(Bot.CurrentUser))
                {
                    return;
                }

                UIMessage message = null;
                Console.WriteLine(args.Message.Content);

                string command = args.Message.Content.Replace(MentionSelf, "").ToLower();

                Console.WriteLine($"Received command: {command}");

                if (command.Contains("test"))
                {
                    message = new TestBook();
                }
                if (command.Contains("xkcd"))
                {
                    message = new XkcdComic();
                }

                if (message != null)
                {
                    await Task.Run(() => CreateUIMessage(message, args));
                }
            }; // TODO bot reacts to mentions and not this crap
        }
Exemplo n.º 5
0
        private List <TestBook> GetLinkEntities()
        {
            var many1   = new ManyToMany();
            var many2   = new ManyToMany();
            var book1   = new TestBook(many1);
            var book2   = new TestBook(many2);
            var author1 = new TestAuthor {
                TestAuthorId = 1
            };

            many1.SetBookAuthor(book1, author1);
            many2.SetBookAuthor(book2, author1);

            author1.Many = new List <ManyToMany> {
                many1, many2
            };

            return(new List <TestBook> {
                book1, book2
            });
        }
Exemplo n.º 6
0
        private static void AddBook(TestBook testBook, GlyssenDblTextMetadata metadata, List <UsxDocument> usxDocuments)
        {
            var book = new Book();

            book.IncludeInScript = true;

            XmlDocument xmlDocument = new XmlDocument();

            switch (testBook)
            {
            case TestBook.JOS:
                book.Code      = "JOS";
                book.LongName  = "Joshua";
                book.ShortName = "Joshua";
                xmlDocument.LoadXml(Properties.Resources.TestJOS);
                break;

            case TestBook.RUT:
                book.Code      = "RUT";
                book.LongName  = "Ruth";
                book.ShortName = "Ruth";
                xmlDocument.LoadXml(Properties.Resources.TestRUT);
                break;

            case TestBook.OBA:
                book.Code      = "OBA";
                book.LongName  = "Obadiah";
                book.ShortName = "Obadiah";
                xmlDocument.LoadXml(Properties.Resources.TestOBAwithInterestingVerseNums);
                break;

            case TestBook.MAT:
                book.Code      = "MAT";
                book.LongName  = "Gospel of Matthew";
                book.ShortName = "Matthew";
                xmlDocument.LoadXml(Properties.Resources.TestMATcuk);
                break;

            case TestBook.MRK:
                book.Code      = "MRK";
                book.LongName  = "Gospel of Mark";
                book.ShortName = "Mark";
                xmlDocument.LoadXml(Properties.Resources.TestMRK);
                break;

            case TestBook.LUK:
                book.Code      = "LUK";
                book.LongName  = "Gospel of Luke";
                book.ShortName = "Luke";
                xmlDocument.LoadXml(Properties.Resources.TestLUK);
                break;

            case TestBook.JHN:
                book.Code      = "JHN";
                book.LongName  = "Gospel of John";
                book.ShortName = "John";
                xmlDocument.LoadXml(Properties.Resources.TestJHN);
                break;

            case TestBook.ACT:
                book.Code      = "ACT";
                book.LongName  = "The Acts of the Apostles";
                book.ShortName = "Acts";
                xmlDocument.LoadXml(Properties.Resources.TestACT);
                break;

            case TestBook.ROM_NoData:
                book.Code      = "ROM";
                book.LongName  = "The Epistle of Paul to the Romans";
                book.ShortName = "Romans";
                xmlDocument.LoadXml(String.Format(Properties.Resources.TestEmptyBook, book.Code));
                break;

            case TestBook.ICO:
                book.Code      = "1CO";
                book.LongName  = "The First Epistle of Paul to the Church of Corinth";
                book.ShortName = "1 Corinthians";
                xmlDocument.LoadXml(Properties.Resources.Test1CO);
                break;

            case TestBook.IICO_NoData:
                book.Code      = "2CO";
                book.LongName  = "The First Epistle of Paul to the Church of Corinth";
                book.ShortName = "2 Corinthians";
                xmlDocument.LoadXml(String.Format(Properties.Resources.TestEmptyBook, book.Code));
                break;

            case TestBook.GAL:
                book.Code      = "GAL";
                book.LongName  = "The Epistle of Paul to the Church of Galatia";
                book.ShortName = "Galatians";
                xmlDocument.LoadXml(Properties.Resources.TestGAL);
                break;

            case TestBook.EPH:
                book.Code      = "EPH";
                book.LongName  = "The Epistle of Paul to the Church of Ephesus";
                book.ShortName = "Ephesians";
                xmlDocument.LoadXml(Properties.Resources.TestEPH);
                break;

            case TestBook.PHP_NoData:
                book.Code      = "PHP";
                book.LongName  = "The Epistle of Paul to the Philippians";
                book.ShortName = "Philippians";
                xmlDocument.LoadXml(String.Format(Properties.Resources.TestEmptyBook, book.Code));
                break;

            case TestBook.COL_NoData:
                book.Code      = "COL";
                book.LongName  = "The Epistle of Paul to the Colossians";
                book.ShortName = "Colossians";
                xmlDocument.LoadXml(String.Format(Properties.Resources.TestEmptyBook, book.Code));
                break;

            case TestBook.ITH_NoData:
                book.Code      = "1TH";
                book.LongName  = "The First Epistle of Paul to the Thessalonians";
                book.ShortName = "1 Thessalonians";
                xmlDocument.LoadXml(String.Format(Properties.Resources.TestEmptyBook, book.Code));
                break;

            case TestBook.IITH_NoData:
                book.Code      = "2TH";
                book.LongName  = "The Second Epistle of Paul to the Thessalonians";
                book.ShortName = "2 Thessalonians";
                xmlDocument.LoadXml(String.Format(Properties.Resources.TestEmptyBook, book.Code));
                break;

            case TestBook.ITI_NoData:
                book.Code      = "1TI";
                book.LongName  = "The First Epistle of Paul to Timothy";
                book.ShortName = "1 Timothy";
                xmlDocument.LoadXml(String.Format(Properties.Resources.TestEmptyBook, book.Code));
                break;

            case TestBook.IITI_NoData:
                book.Code      = "2TI";
                book.LongName  = "The Second Epistle of Paul to Timothy";
                book.ShortName = "2 Timothy";
                xmlDocument.LoadXml(String.Format(Properties.Resources.TestEmptyBook, book.Code));
                break;

            case TestBook.TIT_NoData:
                book.Code      = "TIT";
                book.LongName  = "The Epistle of Paul to Titus";
                book.ShortName = "Titus";
                xmlDocument.LoadXml(String.Format(Properties.Resources.TestEmptyBook, book.Code));
                break;

            case TestBook.PHM:
                book.Code      = "PHM";
                book.LongName  = "Paul's Letter to Philemon";
                book.ShortName = "Philemon";
                xmlDocument.LoadXml(Properties.Resources.TestPHM);
                break;

            case TestBook.HEB:
                book.Code      = "HEB";
                book.LongName  = "Hebrews";
                book.ShortName = "Hebrews";
                xmlDocument.LoadXml(Properties.Resources.TestHEB);
                break;

            case TestBook.JAS_NoData:
                book.Code      = "JAS";
                book.LongName  = "The Epistle of James";
                book.ShortName = "James";
                xmlDocument.LoadXml(String.Format(Properties.Resources.TestEmptyBook, book.Code));
                break;

            case TestBook.IPE_NoData:
                book.Code      = "1PE";
                book.LongName  = "The First Epistle of Peter";
                book.ShortName = "1 Peter";
                xmlDocument.LoadXml(String.Format(Properties.Resources.TestEmptyBook, book.Code));
                break;

            case TestBook.IIPE_NoData:
                book.Code      = "2PE";
                book.LongName  = "The Second Epistle of Peter";
                book.ShortName = "2 Peter";
                xmlDocument.LoadXml(String.Format(Properties.Resources.TestEmptyBook, book.Code));
                break;

            case TestBook.IJN:
                book.Code      = "1JN";
                book.LongName  = "The First Epistle of John";
                book.ShortName = "1 John";
                xmlDocument.LoadXml(Properties.Resources.Test1JN);
                break;

            case TestBook.IIJN:
                book.Code      = "2JN";
                book.LongName  = "The Second Epistle of John";
                book.ShortName = "2 John";
                xmlDocument.LoadXml(Properties.Resources.Test2JN);
                break;

            case TestBook.IIIJN:
                book.Code      = "3JN";
                book.LongName  = "The Third Epistle of John";
                book.ShortName = "3 John";
                xmlDocument.LoadXml(Properties.Resources.Test3JN);
                break;

            case TestBook.JUD:
                book.Code      = "JUD";
                book.LongName  = "Jude";
                book.ShortName = "Jude";
                xmlDocument.LoadXml(Properties.Resources.TestJUD);
                break;

            case TestBook.REV:
                book.Code      = "REV";
                book.LongName  = "The Book of the Revelation of Saint John";
                book.ShortName = "Revelation";
                xmlDocument.LoadXml(Properties.Resources.TestREV);
                break;

            default:
                throw new ArgumentOutOfRangeException("testBook", testBook, null);
            }
            metadata.AvailableBooks.Add(book);

            usxDocuments.Add(new UsxDocument(xmlDocument));
        }
Exemplo n.º 7
0
        /// <summary>
        /// Получить произвольное слово по всем главам в целом
        /// </summary>
        /// <param name="testBook"></param>
        /// <param name="testKind"></param>
        /// <returns></returns>
        public static (string value, string valueTranslate) GetRandomWord([NotNull] this TestBook testBook, TestKind testKind)
        {
            var pair = testBook.AllPairs[Rnd.Next(testBook.AllPairs.Length)];

            return(testKind == TestKind.WordIsEnglish ? (pair.rus, pair.eng) : (pair.eng, pair.rus));
        }
Exemplo n.º 8
0
 public void SetBookAuthor(TestBook book, TestAuthor author)
 {
     BookLink   = book;
     AuthorLink = author;
 }
Exemplo n.º 9
0
 /// <summary>
 /// Конструктор закрыт, т.к. явное создание этого объекта запрещено
 /// </summary>
 private TestsManager([NotNull] Activity activity)
 {
     _allBooks    = ChaptersContent.LoadAllBooks(activity).ToArray();
     _currentBook = _allBooks.First();
 }
Exemplo n.º 10
0
        private static void AddBook(TestBook testBook, GlyssenDblTextMetadata metadata, List <UsxDocument> usxDocuments)
        {
            var book = new Book();

            book.IncludeInScript = true;

            XmlDocument xmlDocument = new XmlDocument();

            switch (testBook)
            {
            case TestBook.MRK:
                book.Code      = "MRK";
                book.LongName  = "Gospel of Mark";
                book.ShortName = "Mark";
                xmlDocument.LoadXml(Properties.Resources.TestMRK);
                break;

            case TestBook.LUK:
                book.Code      = "LUK";
                book.LongName  = "Gospel of Luke";
                book.ShortName = "Luke";
                xmlDocument.LoadXml(Properties.Resources.TestLUK);
                break;

            case TestBook.ACT:
                book.Code      = "ACT";
                book.LongName  = "The Acts of the Apostles";
                book.ShortName = "Acts";
                xmlDocument.LoadXml(Properties.Resources.TestACT);
                break;

            case TestBook.GAL:
                book.Code      = "GAL";
                book.LongName  = "The Epistle of Paul to the Church of Galatia";
                book.ShortName = "Galatians";
                xmlDocument.LoadXml(Properties.Resources.TestGAL);
                break;

            case TestBook.EPH:
                book.Code      = "EPH";
                book.LongName  = "The Epistle of Paul to the Church of Ephesus";
                book.ShortName = "Ephesians";
                xmlDocument.LoadXml(Properties.Resources.TestEPH);
                break;

            case TestBook.PHM:
                book.Code      = "PHM";
                book.LongName  = "Paul's Letter to Philemon";
                book.ShortName = "Philemon";
                xmlDocument.LoadXml(Properties.Resources.TestPHM);
                break;

            case TestBook.HEB:
                book.Code      = "HEB";
                book.LongName  = "Hebrews";
                book.ShortName = "Hebrews";
                xmlDocument.LoadXml(Properties.Resources.TestHEB);
                break;

            case TestBook.IJN:
                book.Code      = "1JN";
                book.LongName  = "The First Epistle of John";
                book.ShortName = "1 John";
                xmlDocument.LoadXml(Properties.Resources.Test1JN);
                break;

            case TestBook.IIJN:
                book.Code      = "2JN";
                book.LongName  = "The Second Epistle of John";
                book.ShortName = "2 John";
                xmlDocument.LoadXml(Properties.Resources.Test2JN);
                break;

            case TestBook.IIIJN:
                book.Code      = "3JN";
                book.LongName  = "The Third Epistle of John";
                book.ShortName = "3 John";
                xmlDocument.LoadXml(Properties.Resources.Test3JN);
                break;

            case TestBook.JUD:
                book.Code      = "JUD";
                book.LongName  = "Jude";
                book.ShortName = "Jude";
                xmlDocument.LoadXml(Properties.Resources.TestJUD);
                break;

            case TestBook.REV:
                book.Code      = "REV";
                book.LongName  = "The Book of the Revelation of Saint John";
                book.ShortName = "Revelation";
                xmlDocument.LoadXml(Properties.Resources.TestREV);
                break;

            default:
                throw new ArgumentOutOfRangeException("testBook", testBook, null);
            }
            metadata.AvailableBooks.Add(book);

            usxDocuments.Add(new UsxDocument(xmlDocument));
        }