コード例 #1
0
        public void CreateRegistrationsFromHeaders_DateHeadersHasTwoItems_ReturnsTwoHourRegistrations()
        {
            // Arrange
            var frame       = new DispatcherFrame();
            var dateHeaders = new List <ForecastRegistrationDateColumn>()
            {
                new ForecastRegistrationDateColumn(new DateTime(2013, 1, 1)),
                new ForecastRegistrationDateColumn(new DateTime(2013, 1, 2))
            };

            var viewModel = new Mock <IForecastRegistrationViewModel>();

            viewModel.SetupGet(x => x.PresenceRegistrations).Returns(new ObservableCollection <ForecastTypeRegistration>(
                                                                         dateHeaders.Select(x =>
            {
                var newItem = new ForecastTypeRegistration(ForecastTestData.ProjectHoursOnlyForecastType, null);
                x.ForecastTypeRegistration = newItem;
                return(newItem);
            }).ToList()
                                                                         ));

            var clientReg = new ProjectRegistration();

            var generator = new ForecastRegistrationDataGenerator(null, null, null);

            // Act
            var result = generator.CreateProjectHoursFromHeaders(dateHeaders, viewModel.Object, clientReg);

            // Assert
            Assert.That(result.Count, Is.EqualTo(2));
            Assert.That(result.Any(x => x.Hours != 0), Is.False);
            Assert.That(result.Any(x => !x.Parent.Equals(clientReg)), Is.False);
        }
コード例 #2
0
        public void AddPresenceRegistration_PresenceRegistrationIsAddedToCollection()
        {
            // Arrange
            new DispatcherFrame();

            var sut = new ForecastRegistrationDateColumn(new DateTime(2013, 1, 1));

            // Act
            var presenceReg = new ForecastTypeRegistration(ForecastTestData.ProjectHoursOnlyForecastType, new List <ForecastType>());

            sut.ForecastTypeRegistration = presenceReg;

            // Assert
            Assert.That(sut.ForecastTypeRegistration, Is.EqualTo(presenceReg));
        }
コード例 #3
0
        public virtual void InitializeForecastTypeRegistrations(IForecastRegistrationViewModel vm)
        {
            foreach (var dateColumn in vm.DateColumns)
            {
                var forecastTypeReg = new ForecastTypeRegistration(_forecastTypeProvider.Default, _forecastTypeProvider.ForecastTypes);
                dateColumn.ForecastTypeRegistration = forecastTypeReg;

                // Initialize commands here, since contextmenu is not part of visual-tree (cant use FindAncestor on binding)
                _copyStatusCommandHandler.InitializePresenceCopyCommands(forecastTypeReg, vm.PresenceRegistrations);

                // Selected PresenceType affects validation and commands.
                forecastTypeReg.ForecastTypeRegistrationChanged.Subscribe(_ =>
                {
                    vm.CalculateTotals();
                    vm.RaiseCanExecuteActions();
                });
            }
        }
コード例 #4
0
        public void ExecuteCopyForward_OnlyFuturePresenceRegistrationsAreAffected()
        {
            // Arrange
            new DispatcherFrame();
            var presenceTypes = ForecastTestData.ForecastTypesList;
            var dateHeaders   = new DateTime(2013, 2, 1)
                                .CreateDatesForMonth()
                                .Select(x => new ForecastRegistrationDateColumn(x))
                                .ToList();

            var hostCollection = dateHeaders
                                 .Select(x =>
            {
                var newItem = new ForecastTypeRegistration(ForecastTestData.ProjectHoursOnlyForecastType, presenceTypes);
                x.ForecastTypeRegistration = newItem;
                return(newItem);
            })
                                 .ToList();

            var source = hostCollection.Single(x => x.DateColumn.Date.Equals(new DateTime(2013, 2, 15)));

            source.SelectedForecastType = ForecastTestData.SimpleForecastType;

            var sut = new CopyStatusCommandHandler();

            // Act
            sut.ExecuteCopyForward(source, hostCollection);

            // Assert
            var preFifteenth = hostCollection.Where(x => x.DateColumn.Date < new DateTime(2013, 2, 15) && x.SelectedForecastType.Equals(ForecastTestData.ProjectHoursOnlyForecastType)).ToList();

            Assert.That(preFifteenth.Count, Is.EqualTo(14));

            var postFifteenth = hostCollection.Where(x => x.DateColumn.Date >= new DateTime(2013, 2, 15) && x.SelectedForecastType.Equals(ForecastTestData.SimpleForecastType)).ToList();

            Assert.That(postFifteenth.Count, Is.EqualTo(10)); // 10 since weekends are excluded
        }
コード例 #5
0
 private void SetForecastTypeAndDedicatedHours(ForecastTypeRegistration forecastTypeReg, ForecastType forecastType, decimal?dedicatedHours)
 {
     forecastTypeReg.SelectedForecastType = forecastType;
     forecastTypeReg.DedicatedHours       = dedicatedHours;
 }
コード例 #6
0
 public void ExecuteCopyForward(ForecastTypeRegistration source, IEnumerable <ForecastTypeRegistration> hostCollection)
 {
     ApplyForecastType(x => x.DateColumn.Date > source.DateColumn.Date && x.DateColumn.IsWorkDay, source, hostCollection);
 }
コード例 #7
0
 public void InitializePresenceCopyCommands(ForecastTypeRegistration newForecastType, IEnumerable <ForecastTypeRegistration> hostCollection)
 {
     newForecastType.CopyForwardCommand   = new DelegateCommand <object>(_ => ExecuteCopyForward(newForecastType, hostCollection));
     newForecastType.CopyBackwardsCommand = new DelegateCommand <object>(_ => ExecuteCopyBackwards(newForecastType, hostCollection));
     newForecastType.CopyToAllCommand     = new DelegateCommand <object>(_ => ExecuteCopyToAll(newForecastType, hostCollection));
 }
コード例 #8
0
 private static void ApplyForecastType(Func <ForecastTypeRegistration, bool> predicate, ForecastTypeRegistration source, IEnumerable <ForecastTypeRegistration> hostCollection)
 {
     foreach (var registration in hostCollection.Where(predicate))
     {
         registration.SilentStatusSetById(source.SelectedForecastType.Id);
         registration.DedicatedHours = source.DedicatedHours;
     }
 }
コード例 #9
0
 public void ExecuteCopyToAll(ForecastTypeRegistration source, IEnumerable <ForecastTypeRegistration> hostCollection)
 {
     ApplyForecastType(presenceReg => !presenceReg.Equals(source) && presenceReg.DateColumn.IsWorkDay, source, hostCollection);
 }