private void AddAllUsersMarkerAndSelect()
        {
            var allUsersDto = ForecastUserDto.AllUsersDto();

            Users.Add(allUsersDto);
            SelectedUsers.Clear();
            SelectedUsers.Add(allUsersDto);
        }
        public void IsAllUsers_DtoIsAllUsersMarker_ReturnsTrue()
        {
            // Arrange
            var sut = ForecastUserDto.AllUsersDto();

            // Act
            var result = sut.IsAllUsers;

            // Assert
            Assert.That(result, Is.True);
        }
Exemple #3
0
        private void SetUserFromUserSession()
        {
            var sessionUser = new ForecastUserDto
            {
                UserId   = _userSession.CurrentUser.Id,
                Name     = _userSession.CurrentUser.Name,
                UserName = _userSession.CurrentUser.UserName
            };

            Users = new ObservableCollection <ForecastUserDto> {
                sessionUser
            };

            SelectedUser = sessionUser;
        }
        public void IsAllUsers_DtoIsNotAllUsersMarker_ReturnsFalse()
        {
            // Arrange
            var sut = new ForecastUserDto
            {
                UserId   = 1,
                UserName = "******"
            };

            // Act
            var result = sut.IsAllUsers;

            // Assert
            Assert.That(result, Is.False);
        }
Exemple #5
0
        public void DoSearch_AllUsersMarkerSelected_InvokesGetBySearchWithAllUserIds()
        {
            // Arrange
            var forecastServiceMock = CreateMock <IForecastService>();

            var users = new[]
            {
                ForecastUserDto.AllUsersDto(),
                new ForecastUserDto {
                    UserId = 1
                },
                new ForecastUserDto {
                    UserId = 2
                },
            };

            var userSearchOptionsMock = CreateMock <ForecastOverviewUserSearchOptions>();

            userSearchOptionsMock.SetupGet(x => x.Users).Returns(new ObservableCollection <ForecastUserDto>(users));
            userSearchOptionsMock.SetupGet(x => x.SelectedUsers).Returns(new ObservableCollection <ForecastUserDto>(users.Where(x => x.IsAllUsers)));

            var sut = new ForecastOverviewSearchOptions(forecastServiceMock.Object, userSearchOptionsMock.Object)
            {
                SelectedTabIndex = ForecastOverviewViewSetup.SearchByUserTabIndex
            };

            // Act
            IEnumerable <int> invokedWithUserIds = new List <int>();

            forecastServiceMock
            .Setup(x => x.GetBySearch(1, 2013, It.IsAny <IEnumerable <int> >()))
            .Callback <int, int, IEnumerable <int> >((x, y, z) => invokedWithUserIds = z);

            sut.DoSearch(1, 2013);

            // Assert
            forecastServiceMock.Verify(x => x.GetBySearch(1, 2013, It.IsAny <IEnumerable <int> >()));
            Assert.That(invokedWithUserIds.Count(), Is.EqualTo(2));
            Assert.That(invokedWithUserIds.ElementAt(0), Is.EqualTo(1));
            Assert.That(invokedWithUserIds.ElementAt(1), Is.EqualTo(2));
        }
            public void AllUsersMarkerIsAdded()
            {
                // Arrange
                var users = new ForecastUserDto[]
                {
                    new ForecastUserDto {
                        UserId = 1, UserName = "******"
                    },
                    new ForecastUserDto {
                        UserId = 2, UserName = "******"
                    }
                };

                var sut = Fixture.Create <ForecastOverviewUserSearchOptions>();

                // Act
                sut.InitializeUsers(users);

                // Assert
                Assert.That(sut.Users.SingleOrDefault(x => x.IsAllUsers), Is.Not.Null);
                Assert.That(sut.Users.SingleOrDefault(x => x.UserId.Equals(1)), Is.Not.Null);
                Assert.That(sut.Users.SingleOrDefault(x => x.UserId.Equals(2)), Is.Not.Null);
            }