public TaskModel( int id, string title, bool is_done, PriorityValue priority ) { Id = id; Title = title; IsDone = is_done; Priority = PriorityValue.critical; }
public void Changing_Value_Should_Call_OnNext() { var target = new PriorityValue("Test", typeof(string)); var subject = new BehaviorSubject <object>("foo"); bool called = false; target.Add(subject, 0); target.Changed.Subscribe(value => called = ((string)value.Item1 == "foo" && (string)value.Item2 == "bar")); subject.OnNext("bar"); Assert.IsTrue(called); }
public void Completing_A_Binding_Should_Revert_To_Next_Value() { var target = new PriorityValue("Test", typeof(string)); var subject = new BehaviorSubject <object>("bar"); target.Add(this.Single("foo"), 0); target.Add(subject, 0); Assert.AreEqual("bar", target.Value); subject.OnCompleted(); Assert.AreEqual("foo", target.Value); }
public void Completing_A_Binding_Should_Revert_To_Lower_Priority() { var target = new PriorityValue(null, TestProperty, typeof(string)); var source = new BehaviorSubject <object>("bar"); target.Add(Single("foo"), 1); target.Add(source, 0); Assert.Equal("bar", target.Value); source.OnCompleted(); Assert.Equal("foo", target.Value); }
public void Binding_Firing_Should_Override_Direct_Value() { var target = new PriorityValue(GetMockOwner().Object, TestProperty, typeof(string)); var source = new BehaviorSubject <object>("initial"); target.Add(source, 0); Assert.Equal("initial", target.Value); target.SetValue("first", 0); Assert.Equal("first", target.Value); source.OnNext("second"); Assert.Equal("second", target.Value); }
public void Completing_A_Binding_Should_Remove_BindingEntry() { var target = new PriorityValue(null, TestProperty, typeof(string)); var subject = new BehaviorSubject <object>("bar"); target.Add(Single("foo"), 0); target.Add(subject, 0); Assert.Equal(2, target.GetBindings().Count()); subject.OnCompleted(); Assert.Single(target.GetBindings()); }
public void SetValue_LocalValue_Should_Not_Add_Entries() { var target = new PriorityValue <string>( Owner, TestProperty, ValueStore); target.SetValue("1", BindingPriority.LocalValue); target.SetValue("2", BindingPriority.LocalValue); Assert.Empty(target.Entries); }
public void Value_Should_Come_From_Last_Entry() { var target = new PriorityValue <string>(Owner, TestProperty, ValueStore); var source1 = new Source("1"); var source2 = new Source("2"); var source3 = new Source("3"); target.AddBinding(source1, BindingPriority.LocalValue).Start(); target.AddBinding(source2, BindingPriority.Style).Start(); target.AddBinding(source3, BindingPriority.Style).Start(); Assert.Equal("1", target.GetValue().Value); }
public void NonAnimated_Value_Should_Be_Correct_2() { var target = new PriorityValue <string>(Owner, TestProperty, ValueStore); var source1 = new Source("1"); var source2 = new Source("2"); var source3 = new Source("3"); target.AddBinding(source1, BindingPriority.Animation).Start(); target.AddBinding(source2, BindingPriority.Style).Start(); target.AddBinding(source3, BindingPriority.Style).Start(); Assert.Equal("1", target.GetValue().Value); Assert.Equal("3", target.GetValue(BindingPriority.LocalValue).Value); }
public int CompareTo(object obj) { if (obj == null) { return(1); } if (!(obj is TicketThreadObject otherTicket)) { throw new ArgumentException("Objeto não é um ticket"); } return(PriorityValue.CompareTo(otherTicket.PriorityValue)); }
public void Earlier_Binding_Firing_Should_Not_Override_Later() { var target = new PriorityValue(GetMockOwner().Object, TestProperty, typeof(string)); var nonActive = new BehaviorSubject <object>("na"); var source = new BehaviorSubject <object>("initial"); target.Add(nonActive, 1); target.Add(source, 1); Assert.Equal("initial", target.Value); target.SetValue("first", 1); Assert.Equal("first", target.Value); nonActive.OnNext("second"); Assert.Equal("first", target.Value); }
public void Binding_Completing_Should_Revert_To_Direct_Value() { var target = new PriorityValue(null, TestProperty, typeof(string)); var source = new BehaviorSubject <object>("initial"); target.Add(source, 0); Assert.Equal("initial", target.Value); target.SetValue("first", 0); Assert.Equal("first", target.Value); source.OnNext("second"); Assert.Equal("second", target.Value); source.OnCompleted(); Assert.Equal("first", target.Value); }
public void Earlier_Binding_Firing_Should_Override_Later_Priority_0() { var target = new PriorityValue("Test", typeof(string)); var nonActive = new BehaviorSubject <object>("na"); var source = new BehaviorSubject <object>("initial"); target.Add(nonActive, 0); target.Add(source, 0); Assert.Equal("initial", target.Value); target.SetDirectValue("first", 0); Assert.Equal("first", target.Value); nonActive.OnNext("second"); Assert.Equal("second", target.Value); }
public void UnsetValue_Should_Fall_Back_To_Next_Binding() { var target = new PriorityValue(GetMockOwner().Object, TestProperty, typeof(string)); var subject = new BehaviorSubject <object>("bar"); target.Add(subject, 0); target.Add(Single("foo"), 1); Assert.Equal("bar", target.Value); subject.OnNext(AvaloniaProperty.UnsetValue); Assert.Equal("foo", target.Value); }
private bool ValuesEqual(PriorityValue a, PriorityValue b) { object valueA = CheckForDynamics(a.Value); // check for dynamics object valueB = CheckForDynamics(b.Value); // check for dynamics if (valueA == null || valueB == null) { return(valueA == valueB); } else { return(valueA.Equals(valueB)); } }
public void UnsetValue_Should_Fall_Back_To_Next_Binding() { var target = new PriorityValue("Test", typeof(string)); var subject = new BehaviorSubject <object>("bar"); target.Add(subject, 0); target.Add(this.Single("foo"), 1); Assert.AreEqual("bar", target.Value); subject.OnNext(PerspexProperty.UnsetValue); Assert.AreEqual("foo", target.Value); }
public void Revalidate_Should_ReCoerce_Value() { var max = 10; var target = new PriorityValue(GetMockOwner().Object, TestProperty, typeof(int), x => Math.Min((int)x, max)); var source = new Subject <object>(); target.Add(source, 0); source.OnNext(5); Assert.Equal(5, target.Value); source.OnNext(15); Assert.Equal(10, target.Value); max = 12; target.Revalidate(); Assert.Equal(12, target.Value); }
public void Constructor_Should_Set_Value_Based_On_Initial_Entry() { var target = new PriorityValue <string>( Owner, TestProperty, NullSink, new ConstantValueEntry <string>( TestProperty, "1", BindingPriority.StyleTrigger, NullSink)); Assert.Equal("1", target.GetValue().Value); Assert.Equal(BindingPriority.StyleTrigger, target.Priority); }
public void Priority_Should_Be_Set() { var target = new PriorityValue <string>( Owner, TestProperty, ValueStore); Assert.Equal(BindingPriority.Unset, target.Priority); target.SetValue("style", BindingPriority.Style); Assert.Equal(BindingPriority.Style, target.Priority); target.SetValue("local", BindingPriority.LocalValue); Assert.Equal(BindingPriority.LocalValue, target.Priority); target.SetValue("animation", BindingPriority.Animation); Assert.Equal(BindingPriority.Animation, target.Priority); target.SetValue("local2", BindingPriority.LocalValue); Assert.Equal(BindingPriority.Animation, target.Priority); }
public void SetValue_Non_LocalValue_Should_Add_Entries() { var target = new PriorityValue <string>( Owner, TestProperty, ValueStore); target.SetValue("1", BindingPriority.Style); target.SetValue("2", BindingPriority.Animation); var result = target.Entries .OfType <ConstantValueEntry <string> >() .Select(x => x.GetValue().Value) .ToList(); Assert.Equal(new[] { "1", "2" }, result); }
public void Set(string Key, object value, int?Order = null, KeyValuePair <string, object>[] GenData = null) { if (Order == null) { if (Conditions.ContainsKey(Key)) { Order = Conditions [Key].Order; } else { Order = 0; } } // check what order to use PriorityValue NewVal = new PriorityValue((int)Order, value); NewVal.SetGenData(GenData); Conditions [Key] = NewVal; }
public void Binding_With_Higher_Priority_Should_Be_Appended() { var target = new PriorityValue <string>(Owner, TestProperty, NullSink); var source1 = new Source("1"); var source2 = new Source("2"); target.AddBinding(source1, BindingPriority.LocalValue); target.AddBinding(source2, BindingPriority.Animation); var result = target.Entries .OfType <BindingEntry <string> >() .Select(x => x.Source) .OfType <Source>() .Select(x => x.Id) .ToList(); Assert.Equal(new[] { "1", "2" }, result); }
public void Binding_With_Lower_Priority_Should_Be_Prepended() { var target = new PriorityValue <string>(Owner, TestProperty, ValueStore); var source1 = new Source("1"); var source2 = new Source("2"); target.AddBinding(source1, BindingPriority.LocalValue); target.AddBinding(source2, BindingPriority.Style); var result = target.Entries .OfType <BindingEntry <string> >() .Select(x => x.Source) .OfType <Source>() .Select(x => x.Id) .ToList(); Assert.Equal(new[] { "2", "1" }, result); }
public void GetValue_Should_Respect_MaxPriority() { var target = new PriorityValue <string>( Owner, TestProperty, ValueStore); target.SetValue("animation", BindingPriority.Animation); target.SetValue("local", BindingPriority.LocalValue); target.SetValue("styletrigger", BindingPriority.StyleTrigger); target.SetValue("style", BindingPriority.Style); Assert.Equal("animation", target.GetValue(BindingPriority.Animation)); Assert.Equal("local", target.GetValue(BindingPriority.LocalValue)); Assert.Equal("styletrigger", target.GetValue(BindingPriority.StyleTrigger)); Assert.Equal("style", target.GetValue(BindingPriority.TemplatedParent)); Assert.Equal("style", target.GetValue(BindingPriority.Style)); }
public void Second_Binding_With_Lower_Priority_Should_Be_Inserted_In_Middle() { var target = new PriorityValue <string>(Owner, TestProperty, NullSink); var source1 = new Source("1"); var source2 = new Source("2"); var source3 = new Source("3"); target.AddBinding(source1, BindingPriority.LocalValue); target.AddBinding(source2, BindingPriority.Style); target.AddBinding(source3, BindingPriority.Style); var result = target.Entries .OfType <BindingEntry <string> >() .Select(x => x.Source) .OfType <Source>() .Select(x => x.Id) .ToList(); Assert.Equal(new[] { "2", "3", "1" }, result); }
public void Competed_Binding_Should_Be_Removed() { var target = new PriorityValue <string>(Owner, TestProperty, ValueStore); var source1 = new Source("1"); var source2 = new Source("2"); var source3 = new Source("3"); target.AddBinding(source1, BindingPriority.LocalValue).Start(); target.AddBinding(source2, BindingPriority.Style).Start(); target.AddBinding(source3, BindingPriority.Style).Start(); source3.OnCompleted(); var result = target.Entries .OfType <BindingEntry <string> >() .Select(x => x.Source) .OfType <Source>() .Select(x => x.Id) .ToList(); Assert.Equal(new[] { "2", "1" }, result); }
private void setCommandableImpl(PriorityArray priorityArray) { PriorityValue priorityValue = null; foreach (PriorityValue priv in priorityArray) { if (!priv.IsNull) { priorityValue = priv; break; } } Encodable newValue = getProperty(PropertyIdentifier.RelinquishDefault); if (priorityValue != null) { newValue = priorityValue.Value; } setPropertyImpl(PropertyIdentifier.PresentValue, newValue); }
internal void Enqueue(Action<Camera> queueAction, Camera camera, PriorityValue priority) { _queue.Enqueue(new ActionInfo(queueAction, true, _dispatcher, camera), new Priority(priority)); if (_queue.Count > 1) return; ActionInfo result = null; result = _queue.Peek(); //_queue.TryPeek(out result); if (result != null) { _queue.UpdatePriority(result, new Priority(PriorityValue.Critical)); try { result.Exec(); } catch (Exception e) { Debug.WriteLine("message: {0}; stacktrace: {1}", e.Message, e.StackTrace); } } }
public void AddTicketToThread(TicketDto ticketDto, ForwarderMessage[] forwarderMessage, PriorityValue priorityValue, CommandDeviceType commandDeviceType) { var thread = GetOrCreateTicketThread(ticketDto.Serial, commandDeviceType, out var wasCreated); thread.AddTicket(ticketDto, priorityValue, forwarderMessage); if (wasCreated) { new Thread(() => thread.Run()).Start(); } }
public void AddTicketToThread(TicketDto ticketDto, ForwarderMessage forwarderMessage, PriorityValue priorityValue, CommandDeviceType commandDeviceType) { AddTicketToThread(ticketDto, new [] { forwarderMessage }, priorityValue, commandDeviceType); }
public Project() { this._Items = new EntitySet<Task>(new Action<Task>(this.attach_Items), new Action<Task>(this.detach_Items)); this._DefaultPriority = PriorityValue.Normal; OnCreated(); }
partial void OnDefaultPriorityChanging(PriorityValue value);
public Task() { this._Attachment = new EntitySet<Attachment>(new Action<Attachment>(this.attach_Attachment), new Action<Attachment>(this.detach_Attachment)); this._Projects = default(EntityRef<Project>); this._Status = TaskStatus.NotStarted; this._Priority = PriorityValue.Normal; this._ProjectID = new Guid(Utils.ProjectIDDefault); this._LocationID = new Guid(Utils.LocationIDDefault); OnCreated(); }
partial void OnPriorityChanging(PriorityValue value);
private void QueueItem(Action queueAction, PriorityValue priority) { // _actionFactory.Enqueue(queueAction, priority); }
public void Initial_Value_Should_Be_UnsetValue() { var target = new PriorityValue("Test", typeof(string)); Assert.AreSame(PerspexProperty.UnsetValue, target.Value); }