コード例 #1
0
        public void MenuParser_ParseFromFile_ThrowsOnNullOrEmpty()
        {
            Action parseAction = () => MenuParser.ParseFromFile(null);

            parseAction.ShouldThrow <ArgumentException>("because we don't accept null for the path");

            parseAction = () => MenuParser.ParseFromFile(string.Empty);

            parseAction.ShouldThrow <ArgumentException>("because we don't accept an empty string for the path");
        }
コード例 #2
0
ファイル: MenuTests.cs プロジェクト: mildsauce45/MenuParsing
        public void Menu_FromTestFile_ProperlySetsValue(string pathToFile, string path, bool expectedResult, string reason)
        {
            var menu = MenuParser.ParseFromFile(pathToFile);

            menu.Should().NotBeNull();

            menu.SetActive(path);

            // The call would have been successful if at least one of the top level elements is set to true
            bool result = false;

            foreach (var mi in menu.Items)
            {
                result |= mi.IsActive;
            }

            result.ShouldBeEquivalentTo(expectedResult, reason);
        }
コード例 #3
0
        public void MenuParser_ParseFromFile_ThrowsOnFileNotFound()
        {
            Action parseAction = () => MenuParser.ParseFromFile(@"C:\thisdirectorydoesntexist\filenotfound.abc");

            parseAction.ShouldThrow <FileNotFoundException>();
        }