Exemplo n.º 1
0
        public void Remove_UserIdIsNotDefined_ExceptionThrown()
        {
            UserStorageService userStorageService = new UserStorageServiceMaster(new UserRepositoryWithState());

            userStorageService.Remove(new User()
            {
                Id = Guid.Empty
            });
        }
Exemplo n.º 2
0
        public void Remove_UserIsNotInStorage_ExceptionThrown()
        {
            UserStorageServiceSlave  userStorageServiceSlave1 = new UserStorageServiceSlave(new UserRepositoryWithState());
            UserStorageServiceSlave  userStorageServiceSlave2 = new UserStorageServiceSlave(new UserRepositoryWithState());
            UserStorageServiceMaster userStorageServiceMaster = new UserStorageServiceMaster(new UserRepositoryWithState(), new List <UserStorageServiceSlave>(new[] { userStorageServiceSlave1, userStorageServiceSlave2 }));

            userStorageServiceMaster.Remove(new User()
            {
                Id = Guid.NewGuid(), FirstName = "alex", LastName = "black", Age = 24
            });
        }
Exemplo n.º 3
0
        public void Remove_InvalidPredicate_ExceptionThrown(Predicate <User> predicate)
        {
            // Arrange
            var userStorageService = new UserStorageServiceMaster(
                new UserMemoryRepository(),
                Enumerable.Empty <INotificationReceiver>());

            InitUserStoreageService(userStorageService);

            // Act
            userStorageService.Remove(predicate);
        }
Exemplo n.º 4
0
        public void Remove_ExistingUser_RemoveOneUser(User user)
        {
            // Arrange
            var userStorageService = new UserStorageServiceMaster(
                new UserMemoryRepository(),
                Enumerable.Empty <INotificationReceiver>());

            InitUserStoreageService(userStorageService);
            int oldUserCount = userStorageService.Count;

            // Act
            userStorageService.Remove((u) => u == user);

            // Assert
            Assert.AreEqual(oldUserCount - 1, userStorageService.Count);
        }
Exemplo n.º 5
0
        public void Remove_User_UserIsRemoved()
        {
            User user = new User()
            {
                Id = Guid.NewGuid(), FirstName = "Alex", LastName = "Black", Age = 25
            };

            UserStorageServiceMaster userStorageService = new UserStorageServiceMaster(new UserRepositoryWithState());
            UserStorageServiceSlave  slave1             = new UserStorageServiceSlave(new UserRepositoryWithState());
            UserStorageServiceSlave  slave2             = new UserStorageServiceSlave(new UserRepositoryWithState());

            userStorageService.AddSubscriber(slave1);
            userStorageService.AddSubscriber(slave2);
            userStorageService.Add(user);

            userStorageService.Remove(user);

            Assert.AreEqual(0, slave2.Count);
            Assert.AreEqual(0, slave1.Count);
        }
Exemplo n.º 6
0
        public void RemoveUsersToMaster_SameUsersRemoveInSlaves()
        {
            // Arrange
            var slaveServices = new[]
            {
                new UserStorageServiceSlave(new UserMemoryRepository()),
                new UserStorageServiceSlave(new UserMemoryRepository()),
            };

            var receivers     = slaveServices.Select(s => s.Receiver);
            var masterService = new UserStorageServiceMaster(new UserMemoryRepository(), receivers);

            InitUserStoreageService(masterService);

            // Act
            masterService.Remove((u) => u.Age > 12);
            var slaveUsers0 = slaveServices[0].Search((u) => true);
            var slaveUsers1 = slaveServices[1].Search((u) => true);
            var masterUsers = masterService.Search((u) => true);

            // Assert
            AssertAreEqual(masterUsers, slaveUsers0, CompareUsers);
            AssertAreEqual(masterUsers, slaveUsers1, CompareUsers);
        }
Exemplo n.º 7
0
        public void Remove_UserIsNull_ExceptionThrown()
        {
            UserStorageService userStorageService = new UserStorageServiceMaster(new UserRepositoryWithState());

            userStorageService.Remove(null);
        }