Пример #1
0
        public void All()
        {
            var members = new Members();
            Member member = CreateAliceWithPhoneNumber();
            member = members.Insert(member);
            var donations = new Donations();
            donations.Insert(new Donation {MemberId = member.Id, Amount = 12.50m, Date = DateTime.Today});
            donations.Insert(new Donation { MemberId = member.Id, Amount = 12.50m, Date = DateTime.Today.Subtract(TimeSpan.FromDays(1)) });

            var list = members.All().ToList();
            Assert.IsNotNull(list);
            Assert.AreEqual(1, list.Count);
            member = list.FirstOrDefault();
            Assert.IsNotNull(member);
            Assert.AreEqual("ABC", member.Reference);
            Assert.AreEqual("Ms", member.Title);
            Assert.AreEqual("Alice", member.FirstName);
            Assert.AreEqual("Krige", member.LastName);
            Assert.AreEqual("Alice", member.Salutation);
            Assert.AreEqual("*****@*****.**", member.EmailAddress);
            Assert.AreEqual("Dunassimilatin", member.AddressLine1);
            Assert.AreEqual("Sector 4", member.AddressLine2);
            Assert.AreEqual("Nexus One", member.City);
            Assert.AreEqual("Delta Quadrant", member.Region);
            Assert.AreEqual("Wales", member.Country);
            Assert.AreEqual("CA1 0PP", member.PostalCode);
            Assert.AreEqual(25m, member.TotalDonations);

            Assert.AreEqual(1, member.PhoneNumbers.Count);
            PhoneNumber phone = member.PhoneNumbers.First();
            Assert.AreEqual(member.Id, phone.MemberId);
            Assert.AreEqual("Home", phone.PhoneNumberType);
            Assert.AreEqual("01234 567890", phone.Number);
        }
Пример #2
0
 internal void CheckVoting()
 {
     if (Members.All(m =>
                     m.CurriculumStatus == MemberCurriculumStatus.Accepted) && Members.Count == GroupInfo.Size)
     {
         Status = CourseStatus.Started;
     }
 }
Пример #3
0
        protected override Expression VisitProperty(PropertyExpression node)
        {
            //If we don't have this property already and this isn't a dummy expression
            if (Members.All(m => node.PropertyInfo.Name != m.PropertyInfo.Name) && node.Expression != null)
            {
                Members.Add(node);
            }

            return(node);
        }
 public void SelectMember(Guid id)
 {
     if (Members.All(memberVm => memberVm.Id != id))
     {
         return;
     }
     {
         SelectedMember = Members.SingleOrDefault(memberVm => memberVm.Id == id);
         SelectedMemberChanged?.Invoke(this, null);
     }
 }
Пример #5
0
 public void AddMember(Member member, string code)
 {
     if (Members.All(x => x.MemberId != member.Id) && code.ToUpper() == Code.ToUpper())
     {
         Members.Add(new GroupCodeMember
         {
             Member    = member,
             GroupCode = this
         });
     }
 }
Пример #6
0
        public bool CanCreateRound(BandMember sheriff)
        {
            if (sheriff == null)
            {
                throw new ArgumentNullException(nameof(sheriff));
            }

            if (!Members.Contains(sheriff))
            {
                return(false);
            }

            return(Members.All(m => m.Rounds.Count >= sheriff.Rounds.Count));
        }
Пример #7
0
        public void GetAll_Test()
        {
            //arrange
            var repoMock       = BuildMemberRepository();
            var pathHelperMock = BuildPathHelper();
            var fileHelperMock = BuildFileHelper();
            var memberService  = new MemberService(
                repoMock.Object, null, fileHelperMock.Object, pathHelperMock.Object, Mock.Of <IManagementDepartmentService>(), Mock.Of <ISecurityService>(), Mock.Of <IAppSettingHelper>());
            //act
            var result = memberService.GetAll();

            //assert
            Assert.True(Members.All(m => result.FirstOrDefault(r => r.MemberId == m.Id) != null));
        }
Пример #8
0
        private async Task SendMembers()
        {
            if (Members.Count >= 5 && Members.All(m => m.Ready))
            {
                if (await Seance())
                {
                    return;
                }
            }

            foreach (var member in Members)
            {
                await member.Socket.SendAsync("members", Members);
            }
        }
Пример #9
0
        public override bool Equals(object other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return(other.GetType() == typeof(T) && Members.All(
                       m =>
            {
                var otherValue = m.GetValue(other);
                var thisValue = m.GetValue(this);

                return m.IsNonStringEnumerable
                                                        ? GetEnumerableValues(otherValue).SequenceEqual(GetEnumerableValues(thisValue))
                                                        : otherValue?.Equals(thisValue) ?? thisValue == null;
            }
                       ));
        }
Пример #10
0
        public MainWindowViewModel()
        {
            #region Test

            AddMemberName       = new ReactiveProperty <string>(string.Empty);
            AddMemberIsLong     = new ReactiveProperty <bool>(false);
            AddMemberIsSelected = new ReactiveProperty <bool>(false);
            RemoveMemberName    = new ReactiveProperty <string>(string.Empty);

            AddMemberCommand = new AsyncReactiveCommand();
            AddMemberCommand.Subscribe(_ => AddMember(AddMemberName.Value, AddMemberIsLong.Value, AddMemberIsSelected.Value));

            RemoveMemberCommand = new ReactiveCommand();
            RemoveMemberCommand.Subscribe(_ => RemoveMember(RemoveMemberName.Value));

            ClearMemberCommand = Members.ObserveProperty(x => x.Count).Select(x => 0 < x).ToReactiveCommand();
            ClearMemberCommand.Subscribe(_ => ClearMember());

            #endregion

            PopulateMembers();

            Members
            .ObserveElementProperty(x => x.IsLong)
            .Where(x => x.Value)
            .Subscribe(x => ShowName(x.Instance));

            Members
            .ObserveElementObservableProperty(x => x.IsSelected)
            .Where(x => x.Value)
            .Subscribe(x => ShowName(x.Instance));

            // IsAllLong: Original
            IsAllLong = Members
                        .ObserveElementProperty(x => x.IsLong)
                        .Select(_ => Members.All(x => x.IsLong))
                        .ToReactiveProperty();

            // IsAllLong: Alternative
            IFilteredReadOnlyObservableCollection <MemberViewModel> membersNotLong = Members
                                                                                     .ToFilteredReadOnlyObservableCollection(x => !x.IsLong);

            IsAllLong = membersNotLong
                        .CollectionChangedAsObservable()
                        .Select(_ => Members.Any() && (0 == membersNotLong.Count))
                        .ToReactiveProperty();

            // IsAnySelected: Original
            IsAnySelected = Members
                            .ObserveElementObservableProperty(x => x.IsSelected)
                            .Select(_ => Members.Any(x => x.IsSelected.Value))
                            .ToReactiveProperty();

            // IsAnySelected: Alternative 1
            List <MemberViewModel> membersSelected = new List <MemberViewModel>();

            IObservable <bool> elementPropertyChanged = Members
                                                        .ObserveElementObservableProperty(x => x.IsSelected)
                                                        .Do(x =>
            {
                if (!x.Value)
                {
                    membersSelected.Remove(x.Instance);
                }
                else if (!membersSelected.Contains(x.Instance))
                {
                    membersSelected.Add(x.Instance);
                }
            })
                                                        .Select(_ => 0 < membersSelected.Count);

            IObservable <bool> collectionChanged = Members
                                                   .CollectionChangedAsObservable()
                                                   .Where(x => x.Action != NotifyCollectionChangedAction.Move)
                                                   .Do(x =>
            {
                switch (x.Action)
                {
                case NotifyCollectionChangedAction.Add:
                case NotifyCollectionChangedAction.Remove:
                case NotifyCollectionChangedAction.Replace:
                    if (x.OldItems != null)
                    {
                        foreach (var instance in x.OldItems.Cast <MemberViewModel>())
                        {
                            membersSelected.Remove(instance);
                        }
                    }
                    if (x.NewItems != null)
                    {
                        foreach (var instance in x.NewItems.Cast <MemberViewModel>())
                        {
                            if (membersSelected.Contains(instance))
                            {
                                continue;
                            }

                            if (instance.IsSelected.Value)
                            {
                                membersSelected.Add(instance);
                            }
                        }
                    }
                    break;

                case NotifyCollectionChangedAction.Reset:
                    membersSelected.Clear();
                    break;
                }
            })
                                                   .Select(_ => 0 < membersSelected.Count);

            IsAnySelected = Observable.Merge(elementPropertyChanged, collectionChanged)
                            .ToReactiveProperty();

            // IsAnySelected: Alternative 2
            IsAnySelected = Members
                            .ObserveElementBooleanObservableProperty(x => x.IsSelected)
                            .Select(x => 0 < x.Count)
                            .ToReactiveProperty();

            // IsAnySelected: Alternative 3
            IsAnySelected = Members
                            .ObserveElementFilteredObservableProperty(x => x.IsSelected, x => x)
                            .Select(x => 0 < x.Count)
                            .ToReactiveProperty();
        }