示例#1
0
        public void Index_must_be_geq_0()
        {
            const string PATH = nameof(FilesInFolderEventRepository_tests) + "_" + nameof(Index_must_be_geq_0);

            if (Directory.Exists(PATH))
            {
                Directory.Delete(PATH, true);
            }
            using (var sut = new FilesInFolderEventRepository(PATH)) {
                Assert.Throws <InvalidOperationException>(() => sut.Store(-1, new TestEvent()));
                Assert.Equal(0, sut.Count);
            }
        }
示例#2
0
        public void No_events_in_empty_repo()
        {
            const string PATH = nameof(FilesInFolderEventRepository_tests) + "_" + nameof(No_events_in_empty_repo);

            if (Directory.Exists(PATH))
            {
                Directory.Delete(PATH, true);
            }

            using (var sut = new FilesInFolderEventRepository(PATH)) {
                Assert.Equal(0, sut.Count);
            }
        }
示例#3
0
        public void Counting_events()
        {
            const string PATH = nameof(FilesInFolderEventRepository_tests) + "_" + nameof(Counting_events);

            if (Directory.Exists(PATH))
            {
                Directory.Delete(PATH, true);
            }
            using (var sut = new FilesInFolderEventRepository(PATH)) {
                sut.Store(0, new TestEvent());
                Assert.Equal(1, sut.Count);
                sut.Store(1, new TestEvent());
                Assert.Equal(2, sut.Count);
            }
        }
示例#4
0
        public void Store_and_load()
        {
            const string PATH = nameof(FilesInFolderEventRepository_tests) + "_" + nameof(Store_and_load);

            if (Directory.Exists(PATH))
            {
                Directory.Delete(PATH, true);
            }
            using (var sut = new FilesInFolderEventRepository(PATH)) {
                var e = new TestEvent {
                    Foo = "Hello"
                };
                sut.Store(0, e);

                var result = (TestEvent)sut.Load(0);

                Assert.NotSame(e, result);
                Assert.Equal(e.Id, result.Id);
                Assert.Equal(e.Foo, result.Foo);
            }
        }
 public FilesInFolderEventstore(string path)
 {
     _repo = new FilesInFolderEventRepository(Path.Combine(path, "events"));
     _vers = new Versions(Path.Combine(path, "versions"));
     _lock = new Lock();
 }