Exemple #1
0
        public void AddAndDeleteNewUserSubmitChangesTest()
        {
            var single = new User {
                UserName  = "******",
                FirstName = "Steve",
                LastName  = "Baker",
                Email     = "*****@*****.**"
            };
            string password = "******";
            string username = single.UserName;

            using (var context = new DirectoryContextMock(ConnectionString, Username, Password))
            {
                var ou = context.OrganizationUnits.First(o => o.Name == ouName);
                single.SetParent(ou);
                context.AddObject(single);
                single.SetPassword(password);
                context.SubmitChanges();

                var single1 = context.Users.Single(u => u.UserName == username);
                context.DeleteObject(single1);
                context.SubmitChanges();
                var single2 = context.Users.SingleOrDefault(u => u.UserName == username);
                Assert.IsNull(single2);
            }
        }
        public void AddAndDeleteNewGroupSubmitChangesTest()
        {
            using (var context = new DirectoryContextMock(ConnectionString, Username, Password))
            {
                var newGroup = new Group {
                    Name = "TestGroup"
                };
                newGroup.SetParent(context.OrganizationUnits.First(u => u.Name == "TestOU"));
                context.AddObject(newGroup);
                context.SubmitChanges();

                var group = context.Groups.First(u => u.Name == "TestGroup");
                context.DeleteObject(group);
                context.SubmitChanges();
            }
        }
        public void AddAndDeleteNewOuSubmitChangesTest()
        {
            using (var context = new DirectoryContextMock(ConnectionString, Username, Password))
            {
                var ou = new OU {
                    Name = "ChildOU"
                };
                ou.SetParent(context.OrganizationUnits.First(u => u.Name == "TestOU"));
                context.AddObject(ou);
                context.SubmitChanges();

                var childOu = context.OrganizationUnits.First(u => u.Name == "ChildOU");
                context.DeleteObject(childOu);
                context.SubmitChanges();
            }
        }