public void ValidateShouldReturnTrueGivenBudgetsWithDuplicateEffectiveDates()
        {
            BudgetCollection subject = Arrange();

            subject.Add(
                new BudgetModelFake
            {
                EffectiveFrom = subject.First().EffectiveFrom,
                Name          = Guid.NewGuid().ToString()
            });

            Assert.IsTrue(subject.Validate(new StringBuilder()));
        }
        public void ValidateShouldFixGivenBudgetsWithDuplicateEffectiveDates()
        {
            BudgetCollection subject = Arrange();

            subject.Add(
                new BudgetModelFake
            {
                EffectiveFrom = subject.First().EffectiveFrom,
                Name          = Guid.NewGuid().ToString()
            });
            subject.Validate(new StringBuilder());

            Assert.IsTrue(subject.GroupBy(b => b.EffectiveFrom).Sum(group => group.Count()) == 3);
        }
Exemplo n.º 3
0
        public static BudgetCollection GetObservableCollection()
        {
            var collection = new BudgetCollection();
            var sqlBuilder = new StringBuilder();

            sqlBuilder.AppendLine("SELECT * FROM");
            sqlBuilder.AppendLine(TABLE_NAME);
            var dataTable = DatabaseController.ExecuteSelectQuery(sqlBuilder);

            foreach (DataRow dataRow in dataTable.Rows)
            {
                var budget = new Budget();
                budget.SetPropertiesFromDataRow(dataRow);
                collection.Add(budget);
            }
            return(collection);
        }
        public void ValidateShouldReturnFalseGivenOneBadBudget()
        {
            BudgetCollection subject = Arrange();

            subject.Add(
                new BudgetModelFake
            {
                EffectiveFrom      = DateTime.Now,
                Name               = "Foo123",
                InitialiseOverride = () => { },
                ValidateOverride   = msg => false
            });

            bool result = subject.Validate(new StringBuilder());

            Assert.IsFalse(result);
        }