public FileAlarmRepository(IFileWatcher watcher, ISharedFileFactory sharedFileFactory, IRepositorySerializer serializer, IRepositoryFilter[] filters, string path) { if (watcher == null) { throw new ArgumentNullException("watcher"); } if (sharedFileFactory == null) { throw new ArgumentNullException("sharedFileFactory"); } if (filters == null) { throw new ArgumentNullException("filters"); } if (serializer == null) { throw new ArgumentNullException("serializer"); } this.serializer = serializer; this.sharedFileFactory = sharedFileFactory; this.filters = filters; this.path = path; this.watcher = watcher; this.watcher.FileChanged += watcher_FileChanged; }
public void Setup() { this.storage = new List <IAlarm>(); this.serializeArgs = null; this.serializer = Substitute.For <IRepositorySerializer>(); this.serializer.Deserialize(null).ReturnsForAnyArgs(this.storage); this.serializer.WhenForAnyArgs(x => x.Serialize(null, null)).Do(x => this.serializeArgs = (IEnumerable <IAlarm>)x.Args()[0]); this.stream = new MemoryStream(); this.watcher = Substitute.For <IFileWatcher>(); this.sharedFileFactory = Substitute.For <ISharedFileFactory>(); this.sharedFile = Substitute.For <ISharedFile>(); this.sharedFileFactory.Write(TEST_PATH).Returns(this.sharedFile); this.sharedFileFactory.Read(TEST_PATH).Returns(this.sharedFile); this.sharedFile.Stream.Returns(this.stream); }
public FileAlarmRepository(IFileWatcher watcher, ISharedFileFactory sharedFileFactory, IRepositorySerializer serializer, IRepositoryFilter[] filters, string path) { if (watcher == null) throw new ArgumentNullException("watcher"); if (sharedFileFactory == null) throw new ArgumentNullException("sharedFileFactory"); if (filters == null) throw new ArgumentNullException("filters"); if (serializer == null) throw new ArgumentNullException("serializer"); this.serializer = serializer; this.sharedFileFactory = sharedFileFactory; this.filters = filters; this.path = path; this.watcher = watcher; this.watcher.FileChanged += watcher_FileChanged; }
public void Setup() { this.storage = new List<IAlarm>(); this.serializeArgs = null; this.serializer = Substitute.For<IRepositorySerializer>(); this.serializer.Deserialize(null).ReturnsForAnyArgs(this.storage); this.serializer.WhenForAnyArgs(x => x.Serialize(null, null)).Do(x => this.serializeArgs = (IEnumerable<IAlarm>)x.Args()[0]); this.stream = new MemoryStream(); this.watcher = Substitute.For<IFileWatcher>(); this.sharedFileFactory = Substitute.For<ISharedFileFactory>(); this.sharedFile = Substitute.For<ISharedFile>(); this.sharedFileFactory.Write(TEST_PATH).Returns(this.sharedFile); this.sharedFileFactory.Read(TEST_PATH).Returns(this.sharedFile); this.sharedFile.Stream.Returns(this.stream); }