Пример #1
0
        public void DeleteGroup()
        {
            //Arrange
            int initialUserCount = GetUserCount();
            CreateWritersGroup();
            var handler = new DeleteGroupHandler(Repo, Manager, Services.UserService);

            //Act
            var groups = Repo.GetAll();
            Assert.AreEqual(1, groups.Count());

            var afterAddUserCount = GetUserCount();
            Assert.AreEqual(initialUserCount + 1, afterAddUserCount);

            var theGroup = groups.First();

            //Act
            handler.Handle(theGroup.Id);

            groups = Repo.GetAll();

            //Assert
            Assert.AreEqual(0, groups.Count());

            var afterDeleteUserCount = GetUserCount();
            Assert.AreEqual(initialUserCount, afterDeleteUserCount);
        }
Пример #2
0
        public void DeleteGroupWithOverlap()
        {
            //Arrange
            var group1 = CreateWritersGroup();
            var group2 = CreateEditorsGroup();

            var handler = new DeleteGroupHandler(Repo, Manager, Services.UserService);

            //Act
            var groups = Repo.GetAll();
            Assert.AreEqual(2, groups.Count());

            var afterAddUserCount = GetUserCount();
            Assert.AreEqual(3, afterAddUserCount);

            var theGroup = groups.First(g=> g.Name == group2.Name);

            //Act
            handler.Handle(theGroup.Id);
            groups = Repo.GetAll();
            var userA = Services.UserService.GetByUsername(ADUsers.AndrewDavis.Login);

            //Assert
            Assert.AreEqual(1, groups.Count());

            var afterDeleteUserCount = GetUserCount();
            Assert.AreEqual(2, afterDeleteUserCount);

            AssertUserForGroup(userA, group1);
        }