public void testCallable() { MockRefreshable mock = new MockRefreshable(); IRefreshable helper = new RefreshHelper(mock.call); helper.Refresh(null); Assert.AreEqual(1, mock.getCallCount()); }
protected AbstractFactorizer(IDataModel dataModel) { this.dataModel = dataModel; buildMappings(); refreshHelper = new RefreshHelper( () => { buildMappings(); }); refreshHelper.AddDependency(dataModel); }
public AbstractUserNeighborhood(IUserSimilarity userSimilarity, IDataModel dataModel, double samplingRate) { //Preconditions.checkArgument(userSimilarity != null, "userSimilarity is null"); //Preconditions.checkArgument(dataModel != null, "dataModel is null"); //Preconditions.checkArgument(samplingRate > 0.0 && samplingRate <= 1.0, "samplingRate must be in (0,1]"); this.userSimilarity = userSimilarity; this.dataModel = dataModel; this.samplingRate = samplingRate; this.refreshHelper = new RefreshHelper(null); this.refreshHelper.AddDependency(this.dataModel); this.refreshHelper.AddDependency(this.userSimilarity); }
/// <p> /// Creates a possibly weighted {@link AbstractSimilarity}. /// </p> public AbstractSimilarity(IDataModel dataModel, Weighting weighting, bool centerData) : base(dataModel) { this.weighted = weighting == Weighting.WEIGHTED; this.centerData = centerData; this.cachedNumItems = dataModel.GetNumItems(); this.cachedNumUsers = dataModel.GetNumUsers(); this.refreshHelper = new RefreshHelper( () => { cachedNumItems = dataModel.GetNumItems(); cachedNumUsers = dataModel.GetNumUsers(); } ); }
public void testDependencies() { RefreshHelper helper = new RefreshHelper(null); MockRefreshable mock1 = new MockRefreshable(); MockRefreshable mock2 = new MockRefreshable(); helper.AddDependency(mock1); helper.AddDependency(mock2); helper.Refresh(null); Assert.AreEqual(1, mock1.getCallCount()); Assert.AreEqual(1, mock2.getCallCount()); }
public void testAlreadyRefreshed() { RefreshHelper helper = new RefreshHelper(null); MockRefreshable mock1 = new MockRefreshable(); MockRefreshable mock2 = new MockRefreshable(); helper.AddDependency(mock1); helper.AddDependency(mock2); IList<IRefreshable> alreadyRefreshed = new List<IRefreshable>(1); alreadyRefreshed.Add(mock1); helper.Refresh(alreadyRefreshed); Assert.AreEqual(0, mock1.getCallCount()); Assert.AreEqual(1, mock2.getCallCount()); }
public void testAlreadyRefreshed() { RefreshHelper helper = new RefreshHelper(null); MockRefreshable mock1 = new MockRefreshable(); MockRefreshable mock2 = new MockRefreshable(); helper.AddDependency(mock1); helper.AddDependency(mock2); IList <IRefreshable> alreadyRefreshed = new List <IRefreshable>(1); alreadyRefreshed.Add(mock1); helper.Refresh(alreadyRefreshed); Assert.AreEqual(0, mock1.getCallCount()); Assert.AreEqual(1, mock2.getCallCount()); }
protected AbstractItemSimilarity(IDataModel dataModel) { //Preconditions.checkArgument(dataModel != null, "dataModel is null"); this.dataModel = dataModel; this.refreshHelper = new RefreshHelper(null); refreshHelper.AddDependency(this.dataModel); }
public void testNoCallable() { IRefreshable helper = new RefreshHelper(null); helper.Refresh(null); }