Пример #1
0
        public void Search_InvalidPredicate_ExceptionThrown(Predicate <User> predicate)
        {
            // Arrange
            var userStorageService = new UserStorageServiceMaster(
                new UserMemoryRepository(),
                Enumerable.Empty <INotificationReceiver>());

            InitUserStoreageService(userStorageService);

            // Act
            userStorageService.Search(predicate);
        }
Пример #2
0
        public int Search_ExistingUser_FindSomeUsers(Predicate <User> predicate)
        {
            // Arrange
            var userStorageService = new UserStorageServiceMaster(
                new UserMemoryRepository(),
                Enumerable.Empty <INotificationReceiver>());

            InitUserStoreageService(userStorageService);

            // Act
            var users = userStorageService.Search(predicate);

            // Assert
            return(users.Count());
        }
Пример #3
0
        public void Search_NotExistingUser_FindNoUsers()
        {
            // Arrange
            var userStorageService = new UserStorageServiceMaster(
                new UserMemoryRepository(),
                Enumerable.Empty <INotificationReceiver>());

            InitUserStoreageService(userStorageService);
            Predicate <User> predicate = (u) => u.FirstName == "NotExistingName";

            // Act
            var users = userStorageService.Search(predicate);

            // Assert
            Assert.AreEqual(0, users.Count());
        }
Пример #4
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);
        }