Beispiel #1
0
        public void SetChief_CheckThatAfterSettingChiefSubordinatesWillBeAdded_AddSubordinates()
        {
            var sales = DomainFactory.CreateSales(1, new DateTime(1991, 2, 28));

            var manager = DomainFactory.CreateManager(2, new DateTime(1991, 2, 28));

            sales.SetChief(manager);

            Assert.AreEqual(1, manager.Subordinates.Count);
        }
Beispiel #2
0
        public void AddSubordinates_CheckThatAfterAddingSubordinatesChiefWillBeSet_AddSubordinates()
        {
            var sales = DomainFactory.CreateSales(1, new DateTime(1991, 2, 28));

            var manager = DomainFactory.CreateManager(2, new DateTime(1991, 2, 28));

            sales.AddSubordinates(manager);

            Assert.AreEqual(1, manager.Chief.Id);
        }
Beispiel #3
0
        public void SetChief_CheckCycleDependencyForSales_CannotBeCycleDependency()
        {
            var sales1 = DomainFactory.CreateSales(1, new DateTime(1991, 2, 28));

            var manager = DomainFactory.CreateManager(2, new DateTime(1991, 2, 28));

            sales1.AddSubordinates(manager);

            var sales3 = DomainFactory.CreateSales(4, new DateTime(1991, 2, 28));

            manager.AddSubordinates(sales3);

            sales1.SetChief(sales3);

            Assert.IsNull(sales1.Chief);
            Assert.AreEqual(0, sales3.Subordinates.Count);
        }
        private void SeedTestData()
        {
            _claculationDateTime = new DateTime(2021, 2, 28);

            _workers = new List <Worker>
            {
                //230
                DomainFactory.CreateEmployee(1, new DateTime(2016, 2, 29)),
                //260
                DomainFactory.CreateEmployee(2, new DateTime(2010, 2, 28)),
                //250
                DomainFactory.CreateManager(3, new DateTime(2016, 2, 29)),
                //280
                DomainFactory.CreateManager(4, new DateTime(2012, 2, 29))
            };

            // (200 + (200 * (0.05 * 4)) = 240) + ((230 + 260 + 250 + 280) * 0.005 = 5.1) = 245.1
            var manager5 = DomainFactory.CreateManager(5, new DateTime(2017, 2, 28));

            foreach (var worker in _workers)
            {
                manager5.AddSubordinates(worker);
            }

            _workers.Add(manager5);
            // (200 + ((200 * 0,2) = 40)) = 240
            var sales6 = DomainFactory.CreateSales(6, new DateTime(2001, 2, 28));

            _workers.Add(sales6);
            // 270
            var sales7 = DomainFactory.CreateSales(7, new DateTime(1981, 2, 28));

            _workers.Add(sales7);
            // 265.3253
            var sales8 = DomainFactory.CreateSales(8, new DateTime(1991, 2, 28));

            sales8.AddSubordinates(manager5);
            sales8.AddSubordinates(sales6);
            sales8.AddSubordinates(sales7);

            _workers.Add(sales8);
        }