public void InitialValue() { var property = new ManuallyRecalculatedProperty <int>(Calculator); calculations.Should().Be(1, "only calculated once, when constructing property"); property.Value.Should().Be(1); }
public void Recalculation() { var property = new ManuallyRecalculatedProperty <int>(Calculator); property.Value.Should().Be(1); property.Recalculate(); property.Value.Should().Be(2); }
private void manuallyRecalculatedProperty() { var manuallyRecalculated = new ManuallyRecalculatedProperty <long>(() => DateTimeOffset.Now.ToUnixTimeMilliseconds()); Console.WriteLine(manuallyRecalculated); // 1591651725420 Thread.Sleep(1000); manuallyRecalculated.Recalculate(); Console.WriteLine(manuallyRecalculated); // 1591651726420 }
public void EventNotFiredWhenRecalculatingSameValue() { var property = new ManuallyRecalculatedProperty <int>(() => 8); int eventsFired = 0; property.PropertyChanged += (sender, args) => eventsFired++; property.Recalculate(); eventsFired.Should().Be(0, "value did not change, so no events should be fired"); }
public void EventFiredWhenRecalculating() { var property = new ManuallyRecalculatedProperty <int>(Calculator); int eventsFired = 0; property.PropertyChanged += (sender, args) => eventsFired++; property.Recalculate(); eventsFired.Should().Be(1); }