Пример #1
0
        public void Parse_ValidXml_CorrectlyParsedAccount(string extension)
        {
            var assembly = Assembly.GetExecutingAssembly();

            using (var stream = assembly.GetManifestResourceStream($"Idunn.FileShare.Testing.Unit.Parser.Resources.Sample{extension}"))
            {
                var register  = new FileShare.Parser.ParserRegister();
                var container = new ParserContainer();
                container.Initialize(register, extension);

                var parser   = register.GetRootParser();
                var accounts = parser.Parse(stream);
                Assert.That(accounts, Is.Not.Null);
                Assert.That(accounts, Is.AssignableTo <IEnumerable <Account> >());
                Assert.That(accounts, Has.Count.EqualTo(1));
            }
        }
Пример #2
0
        public void Parse_ValidXml_CorrectlyParsedFolderPermissions(string extension)
        {
            var assembly = Assembly.GetExecutingAssembly();

            using (var stream = assembly.GetManifestResourceStream($"Idunn.FileShare.Testing.Unit.Parser.Resources.Sample{extension}"))
            {
                var register  = new FileShare.Parser.ParserRegister();
                var container = new ParserContainer();
                container.Initialize(register, extension);

                var parser  = register.GetRootParser();
                var account = (parser.Parse(stream).ElementAt(0) as Account);

                var folder = account.Folders.Single(f => f.Path == "c:\\folder-001");
                Assert.That(folder.Permissions, Is.Not.Null.And.Not.Empty);
                Assert.That(folder.Permissions, Has.Count.EqualTo(1));
                Assert.That(folder.Permissions.First().Name, Is.EqualTo("LIST"));
            }
        }
Пример #3
0
        //[TestCase(".yml")]
        public void Parse_ValidXmlWithMultiplePrincipals_CorrectlyPrincipals(string extension)
        {
            var assembly = Assembly.GetExecutingAssembly();

            using (var stream = assembly.GetManifestResourceStream($"Idunn.FileShare.Testing.Unit.Parser.Resources.Multiple{extension}"))
            {
                var register  = new FileShare.Parser.ParserRegister();
                var container = new ParserContainer();
                container.Initialize(register, extension);

                var parser   = register.GetRootParser();
                var accounts = (parser.Parse(stream) as IEnumerable <Account>);

                Assert.That(accounts, Is.Not.Null);
                Assert.That(accounts, Has.Count.EqualTo(2));
                Assert.That(accounts.Any(a => a.Name == "domain\\account-001"));
                Assert.That(accounts.Any(a => a.Name == "domain\\account-002"));
                Assert.That(accounts.All(a => a.Folders.Count >= 1));
            }
        }