public void RawJsonCollection_NoElements_Fail(string rawFailText) { var failSup = new JsonInMemoryCollection <int, Tuple <int, string> >(new JsonInMemoryCollectionSettings <int, Tuple <int, string> >((v) => v.Item1, "TestJson", rawFailText)); failSup.Refresh(); Assert.NotNull(failSup.GetAll()); Assert.False(failSup.GetAll().Any()); }
public void FileJsonCollections_NoElements_Fail(string path) { var settings = new JsonInMemoryCollectionSettings <int, IntStringPair>((v) => v.Code, path); var sut = new JsonInMemoryCollection <int, IntStringPair>(settings); sut.Refresh(); Assert.NotNull(sut.GetAll()); Assert.False(sut.GetAll().Any()); }
public void RawJsonCollection_BadFormat_Fail(string fileSourcePath) { var rawJsonName = "TestJson"; var rawCollectionSettings = new JsonInMemoryCollectionSettings <int, Tuple <int, string> >( (v) => v.Item1, rawJsonName, File.ReadAllText(Path.Combine(Directory.GetCurrentDirectory(), fileSourcePath)).Substring(0, 15)); var failSup = new JsonInMemoryCollection <int, Tuple <int, string> >(rawCollectionSettings); failSup.Refresh(); Assert.NotNull(failSup.GetAll()); Assert.False(failSup.GetAll().Any()); }
private void TestJsonCollection <TKey, TValue>(JsonInMemoryCollectionSettings <TKey, TValue> settings) { var sut = new JsonInMemoryCollection <TKey, TValue>(settings); sut.Refresh(); Assert.True(sut.Loaded); var keys = sut.GetAllKeys(); Assert.True(keys.Count() > 0); Assert.Equal(keys.Count(), sut.GetAll().Count()); TValue value; Assert.True(sut.TryGet(keys.First(), out value)); }