예제 #1
0
        public void DictionaryTest_Optimization()
        {
            //Arrange
            ICalculationMethod calculationMethod = new CalculationMethod();
            Calculation        calculation       = new Calculation(expenseRepository, tableRepository, calculationMethod, optymizer);

            //Act
            var dict     = calculationMethod.CalculateMembersExpenses(calculation);
            var optidict = calculationMethod.OptimizeDict(dict);

            var expecteddict = new Dictionary <string, decimal>()
            {
                { "Igor_Adam", 2.15m }, { "Adam_Heniek", 3.90m },
                { "Igor_Heniek", 6.05m }
            };
            var keylist = new List <string>()
            {
                "Igor_Adam", "Adam_Heniek", "Igor_Heniek"
            };
            var valuelist = new List <decimal>()
            {
                2.15m, 3.90m, 6.05m
            };


            //Assert
            Assert.IsNotNull(optidict);
            Assert.AreEqual(expecteddict.Count, optidict.Count);
            Assert.Contains("Igor_Adam", optidict.Keys);
            Assert.AreEqual(keylist, optidict.Keys.ToList());
            Assert.AreEqual(valuelist, optidict.Values.ToList());
        }
예제 #2
0
        public void DictionaryTest_Optimization_Simple()
        {
            //Arrange
            var simpledict = new Dictionary <string, decimal>()
            {
                { "Adam_Igor", 5.10m }, { "Igor_Adam", 3.05m }
            };
            CalculationMethod calculationMethod = new CalculationMethod();

            //Act
            var dict = calculationMethod.OptimizeDict(simpledict);

            var expecteddict = new Dictionary <string, decimal>()
            {
                { "Adam_Igor", 2.05m }
            };



            //Assert
            Assert.IsNotNull(dict);
            Assert.AreEqual(expecteddict.Count, dict.Count);
            Assert.Contains("Adam_Igor", dict.Keys);
            Assert.Contains(2.05m, dict.Values);
        }