public void SetUp() { _Collection = new StrongCacheCollection<string, MyObject>(o => o.Name); _Un = new MyObject(_1n, 1); _Deux = new MyObject(_2n, 2); _Trois = new MyObject(_3n, 3); _Quatre = new MyObject(_4n, 4); _Cinq = new MyObject(_5n, 5); _Six = new MyObject(_6n, 6); _Collection.Register(_Un); _Collection.Register(_Deux); _Collection.Register(_Trois); _Collection.Register(_Quatre); _Collection.Register(_Cinq); _Collection.Register(_Six); _Elements = new List<MyObject>(); _Elements.Add(_Un); _Elements.Add(_Deux); _Elements.Add(_Trois); _Elements.Add(_Quatre); _Elements.Add(_Cinq); _Elements.Add(_Six); _Keys = new List<string>(); _Keys.AddRange(from el in _Elements orderby el.Name select el.Name); _Collection2 = new StrongCacheCollection<string, MyObject>(o => o.Name, s => s.ToUpper(), () => new Dictionary<string, MyObject>()); _Elements.Apply(co => _Collection2.Register(co)); }
public void SetUp() { _Un = new MyObject("a", 0); _Deux = new MyObject("b", 1); _Trois = new MyObject("c", 2); _Quatre = new MyObject("d", 3); _Cinq = new MyObject("e", 4); _DecoratedOriginalElements = new List<MyObject>(); _DecoratedOriginalElements.Add(_Un); _DecoratedOriginalElements.Add(_Deux); _DecoratedOriginalElements.Add(_Trois); _DecoratedOriginalElements.Add(_Quatre); _DecoratedOriginalElements.Add(_Cinq); _ListForComparison = new List<IObject>(); _ListForComparison.AddRange(_DecoratedOriginalElements); _OriginalElements = new List<MyObject>(); _OriginalElements.AddRange(_DecoratedOriginalElements); _SCMC = SafeCollectionModifierConverter<MyObject, IObject>.GetSafeCollectionModifierConverterDerived<MyObject, IObject>(_DecoratedOriginalElements); _IML = _SCMC; _ChangedList = _IML.MofifiableCollection; _EL = new EventListener<EventArgs>(); _SCMC.OnCommit += _EL.SingleElementChangedListener; }
public void SetUp() { Init(); _Deux = new MyObject("Name1",0); _Un = new MyObject("Name1",2); _Un.ObjectChanged += Listener.SingleElementChangedListener; }
public void setUP() { _Un = new MyObject("a", 0); _Deux = new MyObject("b", 1); _Trois = new MyObject("c", 2); _Quatre = new MyObject("d", 3); _Cinq = new MyObject("e", 4); _List = new ObservableCollection<MyObject>(); }
public void SimpleFunction_Test_1() { MyObject mo = new MyObject("Simple", 98); SimpleFunction<int> sf = new SimpleFunction<int>(() => mo.Value); sf.MonitorEvents(); sf.Value.Should().Be(98); sf.ShouldNotRaisePropertyChangeFor(o=>o.Value); sf.Dispose(); }
public void TestBasic_3_0() { MyObject mo = new MyObject("dummy", 29); Action<MyObject> act = Substitute.For<Action<MyObject>>(); ICommand target = RelayCommand.Instanciate(act); target.CanExecute(null).Should().BeTrue(); target.CanExecute(mo).Should().BeTrue(); target.Execute(mo); act.Received()(mo); }
public void setUP() { IObjectAttribute io = _Un; _Un = new MyObject("a", 0); _Deux = new MyObject("b", 1); _Trois = new MyObject("c", 2); _Quatre = new MyObject("d", 3); _Cinq = new MyObject("e", 4); //int yu = 23; //_LH20 = new LambdaInspector<MyObject, string>(o=> (o.Friend==null) ? string.Empty : o.Friend.Name ); //_LH19 = new LambdaInspector<MyObject, bool>(o => o.Friend.Name.Length == _Cinq.Value); //_LH18 = new LambdaInspector<MyObject, bool>(o => o.Friend == _Cinq.Friend); //_LH15 = new LambdaInspector<MyObject, int>(o => o.Name.Length * yu + o.Value * 5 + o.Value * o.Value); //_LH17 = new LambdaInspector<MyObject, int>(o => o.Name.Length * (yu + o.Name.Length)); //_LH1 = new LambdaInspector<MyObject, string>(o => o.Name); //_LH2 = new LambdaInspector<MyObject, string>(o => "Toolbox"); //_LH22 = new LambdaInspector<MyObject, string>(o => string.Format("Toolbox{0}", o)); //_LH3 = new LambdaInspector<MyObject, int>(o => o.Value); //_LH4 = new LambdaInspector<MyObject, int>(o => 33 * o.Value + 15); //_LH5 = new LambdaInspector<MyObject, string>(o => string.Format("Toolbox{0}", o.Name)); //_LH6 = new LambdaInspector<MyObject, string>(o => Toto()); //_LH7 = new LambdaInspector<MyObject, int>(o => yu * o.Value); //_LH8 = new LambdaInspector<MyObject, string>(o => Name); //_LH9 = new LambdaInspector<MyObject, string>(o => _Cinq.Name); //_LH10 = new LambdaInspector<MyObject, string>(o => o.ToString()); //_LH11 = new LambdaInspector<MyObject, string>(o => string.Format("{1}Toolbox{0}", o.Name, o.Value)); //_LH12 = new LambdaInspector<MyObject, string>(o => string.Format("{0} Toolbox {1} Reference {2}", o.Name, o.Value, _Cinq.Name)); //MyObject m2 = new MyObject("Toolbox",33); //_LH13 = new LambdaInspector<MyObject, string>(o => string.Format("{0} Toolbox {1} Reference {2}", o.Name, o.Value, m2.Name)); //_LH14 = new LambdaInspector<MyObject, string>(o => string.Format("{0} Toolbox {1} Reference {2}", o.Name, o.Value, Name)); //_LH16 = new LambdaInspector<MyObject, bool>(o => (o.Value == (o.Name.Length + Diff))); }
public void Test_2() { IVisitIObjectAttribute iviv = Substitute.For<IVisitIObjectAttribute>(); MyObject mo = new MyObject("Simple", 65); Expression<Func<int>> myexpression = () => mo.Value; ExpressionVisitorFunction<int> evf = new ExpressionVisitorFunction<int>(myexpression); Func<IVisitIObjectAttribute, int> func = evf.Transformed.Compile(); int res = func(iviv); res.Should().Be(65); iviv.DidNotReceive().Visit(Arg.Any<INotifyCollectionChanged>()); iviv.Received().Visit(mo, Arg.Any<PropertyInfo>(), false); }
public void LiveOrderBy_Test() { IExtendedObservableCollection<MyObject> target = _Los.LiveOrderBy<MyObject, int>("Value"); target.Should().NotBeNull(); target.Should().BeEmpty(); MyObject aa = new MyObject("aa", 10); _Los.Add(aa); target.Should().Equal(aa); MyObject bb = new MyObject("bb", 1); _Los.Add(bb); target.Should().Equal(bb,aa); MyObject cc = new MyObject("cc", 5); _Los.Add(cc); target.Should().Equal(bb,cc,aa); }
public void TestBasic_3_Typed_Dynamic() { MyObject mo = new MyObject("dummy", 29); MyObject triger = new MyObject("dummy2", 1); Action<MyObject> act = Substitute.For<Action<MyObject>>(); IDynamicCommand target = RelayCommand.Instanciate(act,()=>triger.Value==1); target.CanExecute(null).Should().BeTrue(); target.CanExecute(mo).Should().BeTrue(); target.Execute(mo); act.Received()(mo); target.MonitorEvents(); triger.Value = 2; target.ShouldRaise("CanExecuteChanged").WithSender(target); target.CanExecute(null).Should().BeFalse(); target.CanExecute(mo).Should().BeFalse(); target.Dispose(); }
public void TestBasic_3_Typed_Dynamic_Async_2_Second_API_Call() { MyObject mo = new MyObject("dummy", 29); MyObject triger = new MyObject("dummy2", 1); int res = 300; Func<Task> act = () => Task.Run(()=> { Thread.Sleep(4000); res = 0; }); ICommand target = RelayCommand.InstanciateAsync(act); target.CanExecute(mo).Should().BeTrue(); target.MonitorEvents(); target.Execute(mo); Thread.Sleep(1000); target.CanExecute(mo).Should().BeFalse(); target.ShouldRaise("CanExecuteChanged").WithSender(target); Thread.Sleep(6000); res.Should().Be(0); target.CanExecute(mo).Should().BeTrue(); }
public void TestBasic_3_Typed_Dynamic_100_P_3() { MyObject mo = new MyObject("dummy", 29); MyObject mo2 = new MyObject("dummy", 1); MyObject triger = new MyObject("dummy2", 1); Action<MyObject> act = Substitute.For<Action<MyObject>>(); IDynamicCommand target = RelayCommand.Instanciate(act, (t) => triger.Value == t.Value); target.CanExecute(mo).Should().BeFalse(); target.MonitorEvents(); target.CanExecute(mo2).Should().BeTrue(); mo.Value = 1; target.ShouldNotRaise("CanExecuteChanged"); target.Dispose(); }
public void TestBasic_3_Typed_Dynamic_100_P_4() { MyObject mo = new MyObject("dummy", 29); Action<MyObject> act = Substitute.For<Action<MyObject>>(); IDynamicCommand target = RelayCommand.Instanciate(act, (t) => (( t==null) || (t.Value == 1))); target.CanExecute(null).Should().BeTrue(); target.CanExecute(mo).Should().BeFalse(); target.MonitorEvents(); mo.Value = 1; target.ShouldRaise("CanExecuteChanged"); target.CanExecute(mo).Should().BeTrue(); target.Dispose(); }
public void BasicTest_Part2() { _Collection2.Find(_1n).Should().Be(_Un); _Collection2.Find(_2n).Should().Be(_Deux); _Collection2.Find(_3n).Should().Be(_Trois); _Collection2.Find(_4n).Should().Be(_Quatre); _Collection2.Find(_5n).Should().Be(_Cinq); _Collection2.Find(_6n).Should().Be(_Six); _Collection2.Find("F").Should().Be(_Six); _Collection2.Find("f").Should().Be(_Six); Tuple<MyObject,bool> res = _Collection2.FindOrCreateValue("F", s => new MyObject(s,30)); res.Item2.Should().BeTrue(); res.Item1.Should().Be(_Six); MyObject m = null; string lol = "lololo"; res = _Collection2.FindOrCreateValue(lol, s => { m = new MyObject(s, 10); return m; }); m.Should().NotBeNull(); m.Name.Should().Be(lol.ToUpper()); res.Item2.Should().BeFalse(); res.Item1.Should().Be(m); }
static CLF0() { _Ref = new MyObject("aa", 1); _Ref.Friend = _Ref; }
public void LiveToLookUp_Test() { IObservableLookup<string, MyObject> target = _Los.LiveToLookUp(o => o.Name); target.Should().NotBeNull(); target.Should().BeEmpty(); MyObject aa = new MyObject("aa", 10); _Los.Add(aa); ILookup<string, MyObject> t = target; t.Count.Should().Be(1); t.First().Key.Should().Be("aa"); t.First().Should().Equal(aa); }
public void CompileToObservable_Test_Collection_Complex() { MyObject mo = new MyObject("Simple", 98); MyObject mi = new MyObject("Simple2", 100); mo.Friend = mi; Expression<Func<int>> ef = () => mo.Friend.MyFriends.Count(); IFunction<int> target = ef.CompileToObservable(); target.Should().NotBeNull(); target.Value.Should().Be(0); target.MonitorEvents(); mi.MyFriends.Add(mi); target.Value.Should().Be(1); target.ShouldRaisePropertyChangeFor(s => s.Value); mi.MyFriends.Add(mo); target.Value.Should().Be(2); target.ShouldRaisePropertyChangeFor(s => s.Value); mo.Friend = mo; target.Value.Should().Be(0); target.ShouldRaisePropertyChangeFor(s => s.Value); mo.MyFriends.Add(mo); target.Value.Should().Be(1); target.ShouldRaisePropertyChangeFor(s => s.Value); target.Dispose(); }
public void Test() { SetUp(); _Finder = new ItemFinder<MyObject>(_Collection, o => o.Name); IEnumerable<MyObject> res = _Finder.Search("A"); res.Should().BeNull(); res = _Finder.Search("B"); res.Should().BeNull(); res = _Finder.Search("rt"); res.Should().NotBeNull(); res.Count().Should().Be(1); res.Select(o=>o.Name).Should().Contain("ToRTo"); MyObject unres = _Finder.FindExactMatches("B").FirstOrDefault(); unres.Should().NotBeNull(); unres.Name.Should().Be("b"); res = _Finder.Search("ab"); res.Should().NotBeNull(); res.Count().Should().Be(1); res.Select(o => o.Name).Should().Contain("baBA"); res = _Finder.Search("brax"); res.Should().NotBeNull(); res.Count().Should().Be(1); res.Select(o => o.Name).Should().Contain("Anthony Braxton"); res = _Finder.Search("lac"); res.Should().NotBeNull(); res.Count().Should().Be(2); res.Select(o => o.Name).Should().Contain(new string[]{"Steve Lacy","lac"}); _Collection[0].Name = "la"; res = _Finder.Search("la"); res.Should().NotBeNull(); res.Count().Should().Be(3); res.Select(o => o.Name).Should().Contain(new string[] { "la", "Steve Lacy", "lac" }); unres = _Finder.FindExactMatches("B").FirstOrDefault(); unres.Should().BeNull(); res = _Finder.Search("aa"); res.Should().NotBeNull(); res.Count().Should().Be(1); res.Select(o => o.Name).Should().Contain(new string[] { "aaaaaa" }); _Collection[2].Name = "aa"; res = _Finder.Search("aa"); res.Should().NotBeNull(); res.Count().Should().Be(1); res.Select(o => o.Name).Should().Contain(new string[] { "aa" }); _Collection[2].Name = "BAA"; res = _Finder.Search("aa"); res.Should().NotBeNull(); res.Count().Should().Be(1); res.Select(o => o.Name).Should().Contain(new string[] { "BAA" }); _Collection.RemoveAt(2); res = _Finder.Search("aa"); res.Should().NotBeNull(); res.Should().BeEmpty(); MyObject mo = new MyObject("lac", 20); _Collection.Add(mo); res = _Finder.FindExactMatches("lac"); res.Should().NotBeNull(); res.Count().Should().Be(2); res.Should().Contain(mo); }
public void SetUp() { _My = new MyObject("Unitary",1); _SK = new SessionKeys(Path.GetFullPath(@"..\..\TestFolders\OutFolder"),false); }
public void BasicTestWithReplace() { MyObject nov = new MyObject("nov",12); _ChangedList[1] = nov; _ListForComparison[1] = nov; _DecoratedOriginalElements.Should().Equal(_OriginalElements); _ChangedList[2] = nov; _ListForComparison[2] = nov; _DecoratedOriginalElements.Should().Equal(_OriginalElements); MyObject nov2 = new MyObject("nov2", 122); _ChangedList[0] = nov2; _ListForComparison[0] = nov2; _DecoratedOriginalElements.Should().Equal(_OriginalElements); _IML.CommitChanges(); _DecoratedOriginalElements.Should().Equal(_ListForComparison); }
internal MyDummyListener3(MyObject mo) : base(mo) { }
public void SimpleFunction_Test_3() { MyObject mo = new MyObject("Simple", 98); MyObject mi = new MyObject("Simple2", 100); mo.Friend = mi; SimpleFunction<int> sf = new SimpleFunction<int>(() => mo.Friend.Value); sf.MonitorEvents(); sf.Value.Should().Be(100); sf.ShouldNotRaisePropertyChangeFor(o => o.Value); mo.Name = "Complexe"; sf.ShouldNotRaisePropertyChangeFor(o => o.Value); sf.Value.Should().Be(100); mo.Value = 120; sf.Value.Should().Be(100); sf.ShouldNotRaisePropertyChangeFor(o => o.Value); mi.Value = 130; sf.Value.Should().Be(130); sf.ShouldRaisePropertyChangeFor(o => o.Value); MyObject nf = new MyObject("nff", -255); mo.Friend = nf; sf.Value.Should().Be(-255); sf.ShouldRaisePropertyChangeFor(o => o.Value); sf.Dispose(); }
public void test13() { MyObject m2 = new MyObject("rou", 33); using (LambdaInspectorTestor<string> lib4 = new LambdaInspectorTestor<string>(o => string.Format("{0} Toolbox {1} Reference {2}", o.Name, o.Value, m2.Name), _Un)) { Assert.That(lib4.CachedValue, Is.EqualTo("a Toolbox 0 Reference rou")); Assert.That(lib4.Check, Is.True); //Assert.That(lib4.EVC, Is.EqualTo(0)); //Assert.That(lib4.AVEC, Is.EqualTo(0)); Assert.That(lib4.EVC, Is.EqualTo(0)); _Un.Name = "rou"; Assert.That(lib4.CachedValue, Is.EqualTo("rou Toolbox 0 Reference rou")); Assert.That(lib4.Check, Is.True); //Assert.That(lib4.EVC, Is.EqualTo(1)); //Assert.That(lib4.AVEC, Is.EqualTo(0)); Assert.That(lib4.EVC, Is.EqualTo(1)); _Un.Value = 2; Assert.That(lib4.CachedValue, Is.EqualTo("rou Toolbox 2 Reference rou")); Assert.That(lib4.Check, Is.True); //Assert.That(lib4.EVC, Is.EqualTo(2)); //Assert.That(lib4.AVEC, Is.EqualTo(0)); Assert.That(lib4.EVC, Is.EqualTo(2)); m2.Value = 2; Assert.That(lib4.CachedValue, Is.EqualTo("rou Toolbox 2 Reference rou")); Assert.That(lib4.Check, Is.True); //Assert.That(lib4.EVC, Is.EqualTo(2)); //Assert.That(lib4.AVEC, Is.EqualTo(0)); Assert.That(lib4.EVC, Is.EqualTo(2)); m2.Name = "a"; Assert.That(lib4.CachedValue, Is.EqualTo("rou Toolbox 2 Reference a")); Assert.That(lib4.Check, Is.True); //Assert.That(lib4.EVC, Is.EqualTo(2)); //Assert.That(lib4.AVEC, Is.EqualTo(1)); Assert.That(lib4.EVC, Is.EqualTo(3)); } }
public void test20() { using (LambdaInspectorTestor<string> lib4 = new LambdaInspectorTestor<string>(o => (o.Friend == null) ? string.Empty : o.Friend.Name, _Trois)) { Assert.That(lib4.CachedValue, Is.EqualTo(string.Empty)); Assert.That(lib4.Check, Is.True); //Assert.That(lib4.EVC, Is.EqualTo(0)); //Assert.That(lib4.AVEC, Is.EqualTo(0)); Assert.That(lib4.EVC, Is.EqualTo(0)); _Quatre = new MyObject("d", 3); _Trois.Name = "cddd"; Assert.That(lib4.CachedValue, Is.EqualTo(string.Empty)); Assert.That(lib4.Check, Is.True); //Assert.That(lib4.EVC, Is.EqualTo(0)); //Assert.That(lib4.AVEC, Is.EqualTo(0)); Assert.That(lib4.EVC, Is.EqualTo(0)); _Trois.Friend = _Quatre; Assert.That(lib4.CachedValue, Is.EqualTo("d")); Assert.That(lib4.Check, Is.True); //Assert.That(lib4.EVC, Is.EqualTo(1)); //Assert.That(lib4.AVEC, Is.EqualTo(0)); Assert.That(lib4.EVC, Is.EqualTo(1)); _Quatre.Name = "foooo"; Assert.That(lib4.CachedValue, Is.EqualTo("foooo")); Assert.That(lib4.Check, Is.True); //Assert.That(lib4.EVC, Is.EqualTo(2)); //Assert.That(lib4.AVEC, Is.EqualTo(0)); Assert.That(lib4.EVC, Is.EqualTo(2)); _Trois.Friend = _Un; Assert.That(lib4.CachedValue, Is.EqualTo(_Un.Name)); Assert.That(lib4.Check, Is.True); //Assert.That(lib4.EVC, Is.EqualTo(3)); //Assert.That(lib4.AVEC, Is.EqualTo(0)); Assert.That(lib4.EVC, Is.EqualTo(3)); _Trois.Friend = _Cinq; Assert.That(lib4.CachedValue, Is.EqualTo(_Cinq.Name)); Assert.That(lib4.Check, Is.True); //Assert.That(lib4.EVC, Is.EqualTo(4)); //Assert.That(lib4.AVEC, Is.EqualTo(0)); Assert.That(lib4.EVC, Is.EqualTo(4)); _Un.Name = "tatatattattatattata"; Assert.That(lib4.CachedValue, Is.EqualTo(_Cinq.Name)); Assert.That(lib4.Check, Is.True); //Assert.That(lib4.EVC, Is.EqualTo(4)); //Assert.That(lib4.AVEC, Is.EqualTo(0)); Assert.That(lib4.EVC, Is.EqualTo(4)); _Trois.Friend = null; Assert.That(lib4.CachedValue, Is.EqualTo(string.Empty)); Assert.That(lib4.Check, Is.True); //Assert.That(lib4.EVC, Is.EqualTo(5)); //Assert.That(lib4.AVEC, Is.EqualTo(0)); Assert.That(lib4.EVC, Is.EqualTo(5)); _Cinq.Name = "tatatattattaddtattata"; Assert.That(lib4.CachedValue, Is.EqualTo(string.Empty)); Assert.That(lib4.Check, Is.True); //Assert.That(lib4.EVC, Is.EqualTo(5)); //Assert.That(lib4.AVEC, Is.EqualTo(0)); Assert.That(lib4.EVC, Is.EqualTo(5)); lib4.Disconnect(); _Trois.Friend = _Cinq; Assert.That(lib4.CachedValue, Is.EqualTo(string.Empty)); Assert.That(lib4.RealValue, Is.EqualTo("tatatattattaddtattata")); //Assert.That(lib4.EVC, Is.EqualTo(5)); //Assert.That(lib4.AVEC, Is.EqualTo(0)); Assert.That(lib4.EVC, Is.EqualTo(5)); } }
public void TestBasic_3_Typed_Dynamic_Async_FromAction() { MyObject mo = new MyObject("dummy", 29); MyObject triger = new MyObject("dummy2", 1); int res = 300; Action<object> act = _ => { Thread.Sleep(4000); res = 0; }; ICommand target = RelayCommand.InstanciateAsync(act); target.CanExecute(mo).Should().BeTrue(); target.MonitorEvents(); target.Execute(mo); Thread.Sleep(1000); target.CanExecute(mo).Should().BeFalse(); target.ShouldRaise("CanExecuteChanged").WithSender(target); Thread.Sleep(6000); res.Should().Be(0); target.CanExecute(mo).Should().BeTrue(); }
public void TestSimple_Constructor_2() { IEnumerable<MyObject> el = new MyObject[] { _Objs[0], _Objs[1], _Objs[2], _Objs[1] }; _Target = new UISafeObservableCollectionUnic<MyObject>(el); _Target.Should().Equal(el.Distinct()); }
public void TestBasic_3_Typed_Dynamic_Async_FromTask_And_Condition() { MyObject mo = new MyObject("dummy", 29); MyObject triger = new MyObject("dummy2", 1); int res = 300; Func<MyObject, Task> act = _ => Task.Run(() => { Thread.Sleep(4000); res = 0; }); ICommand target = RelayCommand.InstanciateAsync(act,t=>t.Value==triger.Value); target.CanExecute(mo).Should().BeFalse(); target.MonitorEvents(); target.Execute(mo); Thread.Sleep(1000); mo.Value = 1; target.CanExecute(mo).Should().BeFalse(); target.ShouldRaise("CanExecuteChanged").WithSender(target); Thread.Sleep(6000); res.Should().Be(0); target.CanExecute(mo).Should().BeTrue(); }
public void LiveReadOnly_Test_2() { IExtendedObservableCollection<IObject> target = _Los.LiveReadOnly<MyObject,IObject>(); target.Should().NotBeNull(); target.Should().BeEmpty(); MyObject aa = new MyObject("aa", 10); _Los.Add(aa); target.Should().Equal(aa); MyObject bb = new MyObject("bb", 1); _Los.Add(bb); target.Should().Equal(aa, bb); }
internal MyDummyListener0(MyObject o) { _Object = o; }
public void CompileToObservable_Test_1() { MyObject mo = new MyObject("Simple", 98); Expression<Func<string>> ef = () => mo.Name; IFunction<string> target = ef.CompileToObservable(); target.Should().NotBeNull(); target.Value.Should().Be("Simple"); }