public void DatedBlockCanChangeFieldValue() { var reader = new BufferedReader( @"= { #Sarkel culture = khazar religion = tengri_pagan holding = tribal_holding 750.1.2 = { religion = kabarism } 1000.1.2 = { culture = cuman } }" ); var provHistoryFactory = new HistoryFactory.HistoryFactoryBuilder() .WithSimpleField("culture", "culture", null) .WithSimpleField("religion", "religion", null) .WithSimpleField("holding", "holding", "none") .Build(); var provHistory = provHistoryFactory.GetHistory(reader); Assert.Equal("tengri_pagan", provHistory.GetFieldValue("religion", new Date(750, 1, 1))); Assert.Equal("kabarism", provHistory.GetFieldValue("religion", new Date(750, 1, 2))); Assert.Equal("khazar", provHistory.GetFieldValue("culture", new Date(1000, 1, 1))); Assert.Equal("cuman", provHistory.GetFieldValue("culture", new Date(1000, 1, 3))); }
public void InitialValueIsUsedAsFallback() { var reader = new BufferedReader( @"= { #Sarkel 750.1.2 = { religion = kabarism } 1000.1.2 = { culture = cuman } }" ); var provHistoryFactory = new HistoryFactory.HistoryFactoryBuilder() .WithSimpleField("culture", "culture", "roman") .WithSimpleField("religion", "religion", "orthodox") .WithSimpleField("holding", "holding", "none") .Build(); var provHistory = provHistoryFactory.GetHistory(reader); Assert.Equal("roman", provHistory.GetFieldValue("culture", new Date(1, 1, 1))); Assert.Equal("orthodox", provHistory.GetFieldValue("religion", new Date(1, 1, 1))); Assert.Equal("none", provHistory.GetFieldValue("holding", new Date(1, 1, 1))); }
public void HistoryCanBeReadFromMultipleItems() { var reader1 = new BufferedReader( @"= { #Sarkel 750.1.2 = { religion = kabarism } 1000.1.2 = { culture = cuman } }" ); var reader2 = new BufferedReader( "= { # also Sarkel\n" + "\t800.1.1 = { holding = castle_holding }\n" + "}\n" ); var reader3 = new BufferedReader( "= { #third time's a charm\n" + "\t1100.1.1 = { culture = roman }\n" + "}\n" ); var provHistoryFactory = new HistoryFactory.HistoryFactoryBuilder() .WithSimpleField("culture", "culture", null) .WithSimpleField("religion", "religion", null) .WithSimpleField("holding", "holding", "none") .Build(); var provHistory = provHistoryFactory.GetHistory(reader1); provHistoryFactory.UpdateHistory(provHistory, reader2); provHistoryFactory.UpdateHistory(provHistory, reader3); var date = new Date(1100, 1, 1); Assert.Equal("roman", provHistory.GetFieldValue("culture", date)); Assert.Equal("kabarism", provHistory.GetFieldValue("religion", date)); Assert.Equal("castle_holding", provHistory.GetFieldValue("holding", date)); }
public void NullIsReturnedForNonExistingField() { var reader = new BufferedReader( @"= { #Sarkel 750.1.2 = { religion = kabarism } 1000.1.2 = { culture = cuman } }" ); var provHistoryFactory = new HistoryFactory.HistoryFactoryBuilder() .WithSimpleField("culture", "culture", null) .WithSimpleField("religion", "religion", null) .WithSimpleField("holding", "holding", "none") .Build(); var provHistory = provHistoryFactory.GetHistory(reader); Assert.Null(provHistory.GetFieldValue("title", new Date(1000, 1, 1))); }