Пример #1
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);
        }
Пример #2
0
        /// <summary>
        /// Runs a sequence of actions on an instance of the <see cref="UserStorageService"/> class.
        /// </summary>
        public void Run()
        {
            var filePath = ConfigurationManager.AppSettings["FilePath"];

            repositoryManager.Start();

            UserStorageServiceMaster m = new UserStorageServiceMaster((IUserRepository)repositoryManager, new List <UserStorageServiceSlave>(new[] { new UserStorageServiceSlave(new UserRepositoryWithState()), new UserStorageServiceSlave(new UserRepositoryWithState()) }));

            m.AddSubscriber(new UserStorageServiceSlave((IUserRepository)repositoryManager));
            m.Add(new User()
            {
                FirstName = "a",
                LastName  = "b",
                Age       = 55
            });

            repositoryManager.Stop();
            ///_userStorageService.Remove(null);

            ///_userStorageService.Search(null);
        }